The sql in the mapper.xml file changed when it was executed.

12 views
Skip to first unread message

yongle lv

unread,
May 8, 2020, 5:49:41 AM5/8/20
to mybatis-user
The sql in the mapper.xml file changed when it was executed.


mapper.xml:

select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark 
from sys_dict_data
where status = '0' and dict_type = #{dictType} order by dict_sort asc

log:

87a5c914a63e9c2400277c12badeef3.jpg






Guy Rouillier

unread,
May 8, 2020, 11:25:54 PM5/8/20
to mybati...@googlegroups.com
Well, you know what they say about "never say never", but this is a pretty fundamental flaw, and seems like it would have come up before now given how widely used MyBatis is.  For those who can't see the itsy-bitsy type in the included image, here is what it says:

### The error occurred while setting parameters
### SQL: SELECT dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark FROM sys_dict_data
WHERE status = '0' AND dict_type = ? order by detail_id desc LIMIT ?
### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'detail_id' in 'order clause

Notice that in addition to the order by clause changing from "dict_sort asc" to "detail_id desc", other changes appear in the SQL.  Keywords SELECT, FROM, WHERE and AND have been capitalized, but not "order by". And the order by clause also has a LIMIT added.  The logging function in MyBatis does not change capitalization when logging SQL statements.

I'm suspicious that the SQL file being used is not the same as the one you are looking at.  Either a different version ended up in the netcat-system-0.0.1-SNAPSHOT.jar, or the SQL is being picked up from another location.  Start by unzipping the deployed JAR file and inspecting the included SysDictDataMapper.xml file, and also look for another copy of this file somewhere in that deployment.

--
Guy Rouillier
--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/3c1f770b-a047-4e9c-8279-0dc155eb59e9%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages