Error updating database. Cause: java.sql.SQLFeatureNotSupportedException: Only NO_GENERATED_KEYS is supported
Error updating database. Cause: java.sql.SQLFeatureNotSupportedException: Only NO_GENERATED_KEYS is supported
解决方法:
把insert的自动生成key改成false
useGeneratedKeys = false
取值范围true|false(默认值),设置是否使用JDBC的getGenereatedKeys方法获取主键并赋值到keyProperty设置的领域模型属性中。MySQL和SQLServer执行auto-generated key field,因此当数据库设置好自增长主键后,可通过JDBC的getGeneratedKeys方法获取。但像Oralce等不支持auto-generated key field的数据库就不能用这种方法获取主键了
博客内容讲述了在遇到'Error updating database',具体原因是'java.sql.SQLFeatureNotSupportedException: Only NO_GENERATED_KEYS is supported'时,如何解决这个问题。解决方案是将插入操作的自动生成键设置为false,即useGeneratedKeys=false。这适用于不支持自动获取生成键的数据库,如Oracle,而在MySQL和SQLServer等支持的数据库中,可以使用getGeneratedKeys方法获取主键。
1万+





