I have spring-boot application with MyBatis ORM. In java I write like
@Mapper
@Repository
public interface FooMapper {
@SelectProvider(type = SqlProviderAdapter.class, method = "select")
@Results(id = "resultFoo", value = {
@Result(property = "rowId", column = "ROW_ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "lastUpdated", column = "LAST_UPD"),
@Result(property = "fooId", column = "FOO_ID"),
})
Foo findBy(SelectStatementProvider selectStatement);
@SelectProvider(type = SqlProviderAdapter.class, method = "select")
@Results(value = {
@Result(property = "rowId", column = "ROW_ID"),
@Result(property = "created", column = "CREATED"),
@Result(property = "lastUpdated", column = "LAST_UPD"),
@Result(property = "fooId", column = "FOO_ID"),
})
List<Foo> findListBy(SelectStatementProvider selectStatement);
@SelectProvider(type = SqlProviderAdapter.class, method = "select")
@Results(value = {
@Result(property = "fooId", column = "FOO_ID")
})
List<String> findFooListBy(SelectStatementProvider selectStatement);
@InsertProvider(type = SqlProviderAdapter.class, method = "insert")
@Options(useGeneratedKeys = true, keyProperty = "record.rowId", keyColumn = "row_id")
int insert(InsertStatementProvider<Foo> insertStatement);
@UpdateProvider(type = SqlProviderAdapter.class, method = "update")
int update(UpdateStatementProvider updateStatement);
}
This works great!
But I need to convert all my application to Kotlin. I tried the following code:
@Mapper
@Repository
interface FooMapper {
@SelectProvider(type = SqlProviderAdapter::class, method = "select")
@Results(
id = "resultReferralActivation",
value = [Result(property = "rowId", column = "ROW_ID"), Result(
property = "created",
column = "CREATED"
), Result(property = "lastUpdated", column = "LAST_UPD"), Result(
property = "fooId",
column = "FOO_ID"
)]
)
fun findBy(selectStatement: SelectStatementProvider?): Foo?
@SelectProvider(type = SqlProviderAdapter::class, method = "select")
@Results(
value = [Result(property = "rowId", column = "ROW_ID"), Result(
property = "created",
column = "CREATED"
), Result(property = "lastUpdated", column = "LAST_UPD"), Result(
property = "fooId",
column = "FOO_ID"
)]
)
fun findListBy(selectStatement: SelectStatementProvider?): List<Foo?>?
@SelectProvider(type = SqlProviderAdapter::class, method = "select")
@Results(value = [Result(property = "fooId", column = "FOO_ID")])
fun findFooListBy(selectStatement: InsertStatementProvider?): List<String?>?
@InsertProvider(type = SqlProviderAdapter::class, method = "insert")
@Options(useGeneratedKeys = true, keyProperty = "record.rowId", keyColumn = "row_id")
fun insert(insertStatement: InsertStatementProvider<Foo?>?): Int
@UpdateProvider(type = SqlProviderAdapter::class, method = "update")
fun update(updateStatement: UpdateStatementProvider?): Int
}
But it doesn't work. If I trying awtowired FooMapper in java or kotlin class aplication failed on start with message like: can't find bean FooMapper. If I commented my autowired attemption, application starts, but when i check spring-bean-list i see that bean FooMapper doesn't exists.
How to convert my java mapper to Konlin?
Thanks for your help!
The problem was how the "idea" created folders. When I manually created the correct folder structure that my mapper search configuration was configured for, then everything worked