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

复用wrapper,当增加新的查询条件后,sql未重新生成 #123

Closed
wants to merge 2 commits into from

Conversation

agui001
Copy link

@agui001 agui001 commented Mar 22, 2024

该Pull Request关联的Issue

修改描述

复用wrapper,当增加新的查询条件后,sql未重新生成

测试用例

@Test public void testReuseWrapper() { MPJLambdaWrapper wrapper = new MPJLambdaWrapper() .select(UserDO::getName); List dos = userService.list(wrapper); System.out.println(1); wrapper.select(UserDO::getAddressId); dos = userService.list(wrapper); }

修复效果的截屏

修复前的sql输出日志:

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58a2b917] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@1328705686 wrapping conn0: url=jdbc:h2:mem:test user=ROOT] will not be managed by Spring
==> Preparing: SELECT t.name FROM user t WHERE t.del = false
==> Parameters:
<== Columns: NAME
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Total: 22
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58a2b917]
1
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3a3ed300] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@972404515 wrapping conn0: url=jdbc:h2:mem:test user=ROOT] will not be managed by Spring
==> Preparing: SELECT t.name FROM user t WHERE t.del = false
=====================这里的sql没有查询t.address_id字段========================
==> Parameters:
<== Columns: NAME
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Total: 22
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3a3ed300]

修复后的sql输出日志:

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58a2b917] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@1328705686 wrapping conn0: url=jdbc:h2:mem:test user=ROOT] will not be managed by Spring
==> Preparing: SELECT t.name FROM user t WHERE t.del = false
==> Parameters:
<== Columns: NAME
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Row: {"aa":"aaa","bb":"bbb"}
<== Total: 22
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@58a2b917]
1
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3a3ed300] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@972404515 wrapping conn0: url=jdbc:h2:mem:test user=ROOT] will not be managed by Spring
==> Preparing: SELECT t.name, t.address_id FROM user t WHERE t.del = false
==> Parameters:
<== Columns: NAME, ADDRESS_ID
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Row: {"aa":"aaa","bb":"bbb"}, 1
<== Total: 22
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3a3ed300]

@yulichang yulichang closed this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants