mybatis / mybatis-3

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

Allow custom mapper methods to initiate dynamic injection #3243

Open qmdx opened 1 month ago

qmdx commented 1 month ago

This dynamic injection method is the core principle of mybatis-plus, and we hope that the official mybatis can adopt it, Thank you for checking

hazendaz commented 1 month ago

@harawata Thoughts? Looks ok to me.

coveralls commented 1 month ago

Coverage Status

coverage: 87.178% (+0.03%) from 87.153% when pulling 0e883d6afaf37a12a6ba2040904493cfaa1c0c3f on baomidou:master into c3fd28c24fd160b9fc18b8c6b9033b2cbd461a50 on mybatis:master.

harawata commented 1 month ago

Adding a mapper method at runtime is not a good idea. If you want to generate SQL dynamically, please use SQL provider.

qmdx commented 1 month ago

Adding a mapper method at runtime is not a good idea. If you want to generate SQL dynamically, please use SQL provider.

hi @harawata The injection method provided by PR is an XML simulation injection method, which has more secure SQL protection, Performance may be better in ordinary simple crud situations,Every time the SQL Provider method is called, the SQL statement is regenerated, which may result in additional parsing time, especially for complex SQL generation logic. I hope to carefully consider my suggestion and provide an additional injection solution, which is not a bad thing for MyBatis itself. Thank you for your reply

harawata commented 1 month ago

I'm sorry, but I still think this is a bad idea.