The string primary key inserted by mybatis becomes 0?

Record a magical thing, I haven't used it like this before. Originally, the character primary key I inserted was 000000, but the inserted SQL displayed 0. Outrageous isn't it?

 

Let me tell you the reason directly. The primary key I inserted originally had a value, but SQL wrote the operation of assigning the primary key. It is the following sentence. But this is reverse generated by mybatis, I didn't expect that there would be problems.

<selectKey resultType="java.lang.String" keyProperty="snNo" order="BEFORE" >
SELECT LAST_INSERT_ID()
</selectKey>

 Originally there is no value, the result is the default value 0, and the value is reassigned to the original entity class

下图就是赋值操作

Guess you like

Origin blog.csdn.net/haoweng4800/article/details/128371926