目前遇到的有几种情况会导致这样的问题
1、对应的数据表没有设置主键
解决方案:
设置主键
2、使用了 mysql-connector-java-8.0.15.jar 或 其他高版本的mysql数据库驱动
解决方案:
在jdbcConnection中添加userInformationSchema属性,并设值为true
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC"
userId="root" password="root">
<property name="useInformationSchema" value="true"/>
</jdbcConnection>
3、table属性中设置了enable*ByPrimaryKey = "false"属性
<table tableName="user_detail_info" domainObjectName="UserDetailInfo"
enableDeleteByPrimaryKey="false"
enableSelectByPrimaryKey="false"
enableUpdateByPrimaryKey="false"
enableCountByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
enableUpdateByExample="false">
</table>
解决方案:
去除enable*ByPrimaryKey = "false"属性,或者设置为true
本文探讨了数据表问题的三种常见原因:未设置主键、使用高版本数据库驱动和table属性设置错误。提供了针对性的解决方案,包括设置主键、调整jdbc连接参数和修正实体映射配置。
3593

被折叠的 条评论
为什么被折叠?



