Hibernate.hbm.xml

1、should be mapped with insert="false" update="false":存在重复映射的字段;

2、Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]:

配置文件与实体文件映射错误,多了字段或少了字段或少些了getter 方法;

3、org.hibernate.LazyInitializationException: could not initialize proxy - no Session:映射关系中加上 lazy="false";

4、org.hibernate.ObjectNotFoundException: No row with the given identifier exists:根据外键id查询不到映射表的相应数据;

5、Could not determine type for: String, for columns: [org.hibernate.mapping.Column(XXX)]:type指的是*.hbm.xml配置文件中的类型,string要小写;

6、nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists:映射表中数据的主键id不匹配;

7、org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of XXX:配置文件与实体类字段类型不一致;

8、org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1:级联新增,打印出来的sql语句显示主表为insert,从表为update  可以将配置文件中自增id设置 unsaved-value="0";

9、ConstraintViolationException: Could not execute JDBC batch update:两个表建立了外键约束,删除约束后操作成功;

10、 nested exception is org.springframework.beans.NotWritablePropertyException:

11、org.springframework.beans.factory.BeanCreationException:Spring中的“asm-2.2.3.jar”和Hibernate中的“asm.jar”包冲突。解决办法是移除Spring2.0 AOP Libraries中的“asm-2.2.3.jar”即可

12、org.springframework.beans.MethodInvocationException: 在classes目录有一个以前的类,但现在的类的路径已经发生了变化,发生变化的类全部封装在 jar 里面,但class loader 是优先装载 classes 目录下的类,所以存在装载时发生“NoClassDefFoundError”错误!只要把classes下的class文件删除即可。

13、com.sun.faces.mgbean.ManagedBeanCreationException:数据问题

14、a different object with the same identifier value was already associated with the session:getHibernateTemplate().merge(object);http://chenying.blog.51cto.com/614874/134702

15、not-found="ignore" 忽略ObjectNotFound异常;

转载地址:http://blog.csdn.net/hardwin/article/details/4329652

我们项目里面配了很多many-to-one的关联,后台在查询数据时已经作了健全性判断,但还是经常抛出对象找不到异常:org.hibernate.ObjectNotFoundException: No row with the given identifier exists

因为系统给用户使用过程中库表的数据会常发生变化,最常见的是人员变化,原先引用的User 在库表没了,hibernate 多对一关联,多的这端引用的一的那端,如此引用值在一的那端找不到数据,默认就会抛出异常;而后台判断控制不了此问题。解决办法就是在many-to- one的这端加上属性:not-found=ignore

hibernate many-to-one的属性not-found,用来指定引用的外键不存在时如何处理:

它有两个取值,exception(默认)抛出异常,ignore 忽略。

posted on 2012-12-26 15:19  双面煎蛋  阅读(3546)  评论(0编辑  收藏  举报