hibernate常见错误

来源:互联网 发布:手机淘宝怎么做 编辑:程序博客网 时间:2024/06/03 20:43
1、Exception in thread "main" java.lang.ClassCastException: com.jiang.entity.UserBean_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy
外键设置懒加载:其中lazy="true",默认为true,只要自己主动设置为false即可;


2、ERROR: 无效的列类型: 16
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not insert: [com.jiang.entity.UserBean]
16对应的boolean类型,所以错误原因是无法为boolean添加默认数据,只要在表上面添加dynamic-insert="true",或者在添加数据的时候主动添加上使用了boolean类型的数据即可


3、Exception in thread "main" org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.jiang.entity.UserBean#2]
主键值找不到,比如说我想修改主键为6L的这一条数据,但是6L不存在,那么就会报这个异常