mybatis / mybatis-3

MyBatis SQL mapper framework for Java
http://mybatis.github.io/mybatis-3/
Apache License 2.0
19.84k stars 12.87k forks source link

Can typehandler be separated from mybatis? #3304

Open Ai-010 opened 5 days ago

Ai-010 commented 5 days ago

I have already open sourced a framework called "mybatis-mp" based on mybatis. My entity class annotations need to rely on mybatis' typehandler, and I hope the annotation module of "mybatis-mp" can be made smaller and less dependent, but the typehandler property depends on mybatis dependencies. I hope mybatis can extract the typehandler from mybatis and make it a small module. My open source address is:

https://github.com/mybatis-mp/mybatis-mp

@Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface TableField { Class<? extends TypeHandler<?>> typeHandler() default UnknownTypeHandler.class; ...... }

Mybatis mp is currently very user-friendly:

Pager<SysUser> pager= QueryChain.of(sysUserMapper) .like(SysUser::getUserName,"abc") .paging(Pager.of(1));

hazendaz commented 5 days ago

I cannot answer for others, but I think splitting a few things from the mybatis core making other modules would be a good improvement as we get a lot of requests for type handles we don't want to support but honestly we should. Me being a direct contributor, I even have type-handlers at work that should be in mybatis. So if others agree (2 or 3 others) then maybe that could happen.

Ai-010 commented 5 days ago

I cannot answer for others, but I think splitting a few things from the mybatis core making other modules would be a good improvement as we get a lot of requests for type handles we don't want to support but honestly we should. Me being a direct contributor, I even have type-handlers at work that should be in mybatis. So if others agree (2 or 3 others) then maybe that could happen.

Thank you for your reply;If this can be done, it is indeed beneficial for expanding based on mybatis, although some changes are needed for mybatis。

harawata commented 5 days ago

What does "separate type handlers" mean? I'm not sure how you design your project, but we will not move the TypeHandler interface out of the core.

Ai-010 commented 5 days ago

What does "separate type handlers" mean? I'm not sure how you design your project, but we will not move the TypeHandler interface out of the core.

Just a suggestion,More friendly to open source frameworks based on MyBatis;I believe other open source projects also have similar requirements。