Mybatis annotations in complex applications

I am currently working on a project that uses MyBatis annotations in mapper interfaces, as I prefer this for XML files, but I had problems with mapping associations.

i.e. loading a collection for one to many associations using a join table.

I know that annotations do not support some association mappings. Is it possible to use MyBatis with mapper interfaces in Java in any moderately complex application without resorting to xml mapping files, given the limitations?

Are there any issues combining mapper interfaces with xml mapping files.

+2
source share
1 answer

The user manual assumes that the format of annotations becomes cumbersome for complex queries. But you can combine annotations and XML query definitions, and this requirement ends up with no more than one definition with the same name, no matter how it is defined.

I am currently working through MyBatis Koans - which I find quite useful. Exercise 8 includes a mapper interface with annotations for removal methods and a mapper XML file for updating, inserting, and selecting. He worked for me without any problems as soon as I finished the exercise.

+3
source

All Articles