We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
有没有对外接口,可以自定义实现对象字段填充, 比如: 我要在插入一条记录的时候,将创建时间赋值为当前时间,创建人取当前线程的用户ID, 在更新记录时候,可以将更新时间赋值为当前时间,更新人取当前线程的用户ID
The text was updated successfully, but these errors were encountered:
好想法,这种扩展特性可以通过扩展SQLExecutor 实现,然后通过Databases.installSQLExecutor 方法将自定义类注入ObjectiveSQL。
SQLExecutor
Databases.installSQLExecutor
SQLExecutor 中insert 对应SQL 语句中的INSERT,execute 方法对应UPDATE 和DELETE。
在insert 和execute 方法中,需要获取业务上下文,例如:current_user 等,通过ThreadLocal 的方式进行传递,并及时清空,具体可以参考:Databases.java 中的 connectionThreadLocal 的使用方法
ThreadLocal
connectionThreadLocal
Sorry, something went wrong.
1)通过扩展SQLExecutor 是在SQL 结构已经固定,只需要补充相关参数的值的时候使用。 2)如果SQL 结构跟随业务特性变化,则需要扩展Persistence ,在内部调整SQL 结构和相关参数
我是这样实现的
catchex
No branches or pull requests
有没有对外接口,可以自定义实现对象字段填充,
比如:
我要在插入一条记录的时候,将创建时间赋值为当前时间,创建人取当前线程的用户ID,
在更新记录时候,可以将更新时间赋值为当前时间,更新人取当前线程的用户ID
The text was updated successfully, but these errors were encountered: