Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New @Mapper marker annotation for DI frameworks #629

Closed
emacarron opened this issue Apr 9, 2016 · 10 comments
Closed

New @Mapper marker annotation for DI frameworks #629

emacarron opened this issue Apr 9, 2016 · 10 comments
Assignees
Labels
enhancement Improve a feature or add a new feature
Milestone

Comments

@emacarron
Copy link
Member

A new annotation has been created so they can use it for scanning purposes.

Change in b6977e6

Know about the history in mybatis/spring-boot-starter#46

@emacarron emacarron self-assigned this Apr 9, 2016
@emacarron emacarron added the enhancement Improve a feature or add a new feature label Apr 9, 2016
@emacarron emacarron added this to the 3.4.0 milestone Apr 9, 2016
@jefffangji
Copy link

The @Mapper annotation is not showed in Mapper Annotations of document http://www.mybatis.org/mybatis-3/java-api.html. Is the annotation public to the users without using spring, boot or CDI?

@mnesarco
Copy link
Member

mnesarco commented Apr 21, 2017 via email

@jefffangji
Copy link

Hi Mnesarco, I'm not using mybatis-cdi. Actually, I want to scan the mapper interfaces by myself with the new added @Mapper interface, but the annotation seems not be displayed in mybatis document. Is it recommended to use the annotation for scanning mapper interfaces for regular users(not mybatis-cdi or spring-boot developer)?

@harawata
Copy link
Member

@mnesarco ,
I am not sure if it actually causes issue or not, but it probably makes more sense to use the one in the core.

@jefffangji ,
What happens if your project adopt MyBatis-CDI or Spring in future?
If there is no change required, it may be fine to use this annotation.
Otherwise, it would be safer to use a custom marker annotation.

@jefffangji
Copy link

Our project is based on Play and MyBatis-Guice. And I don't find there is mapper auto-scan functionality in MyBatis-Guice. That's why I need to scan the mappers by myself.

@mnesarco
Copy link
Member

@harawata ,
The Annotation in the core is a little different from the one in cdi. To make the Annotation work friendly with cdi containers it should be annotated with Stereotype, also the annotation in cdi is only targeted to TYPE. What I propose is to make cdi aware of both annotations, but it will work better with the annotation in cdi. I am afraid the annotation in the core was created without a real use case, it was created just in case for future use and is not included in documentation. I prefer each DI framework to have their own annotations.

@harawata
Copy link
Member

@mnesarco ,
Thank you for the explanation.

I prefer each DI framework to have their own annotations.

Now I agree with you.
I assumed that @Mapper in the core can be used in CDI as well, but if that's not the case, it may be better to 1) have one in each module and 2) deprecate the core one.
It could be a confusing change to mybatis-spring-boot users, though.

@emacarron @eddumelendez @kazuki43zoo @jeffgbutler
Any thoughts?

@jefffangji ,
As you can see, you should create and use your own annotation :)

@kazuki43zoo
Copy link
Member

@harawata @mnesarco
I agree with you.

It could be a confusing change to mybatis-spring-boot users, though.

I think so. I think we should be provide a migration period for mybatis-spring-boot users. (e.g. Change to deprecated annotation (+ provide a new annotation) -> Remove @Mapper annotation in core)

@kazuki43zoo
Copy link
Member

@harawata @eddumelendez

I will propose adding new @Mapper annotation on mybatis-spring (not rather than mybatis-spring-boot) because mapper scaning feature provide by mybatis-spring.

@harawata
Copy link
Member

harawata commented May 1, 2017

@kazuki43zoo Sounds good to me.
You should create a PR on mybatis-spring and ask others for a review.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
Development

No branches or pull requests

5 participants