mybatis / mybatis-3

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

Cannot work a JDBC standard generated keys at <update> #1255

Open kazuki43zoo opened 6 years ago

kazuki43zoo commented 6 years ago

When the Configuration#useGeneratedKeys set to true and omit the useGeneratedKeys attribute at <update>, a JDBC standard generated keys feature does not work.

Probably, following code is the root cause.

https://github.com/mybatis/mybatis-3/blob/adbcd98d17b993af6d19997aa81da82ae507669e/src/main/java/org/apache/ibatis/builder/xml/XMLStatementBuilder.java#L104-L106

Is this behavior specification or not?

MyBatis version

3.4.6

Database vendor and version

Any

Notes

The <insert> works fine in the same condition.

jiangrongbo commented 6 years ago

i think useGeneratedKeys property depend on dbms auto generated key , if a sql statement can't generate auto increment primary key ,the feature would not be work.