org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.
摘要:今天报了这个异常,这是页面报的org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.控制台报18:52:35,859 ERROR SqlExceptionHelper:147 - Cannot delete or update a parent row: a foreign key constraint fails (`zl_cms`.`t_chann
阅读全文
posted @
2014-02-07 18:59
c3tc3tc3t
阅读(32603)
推荐(0)
转 Hibernate中cascade和inverse的作用
摘要:Inverse和cascade是Hibernate映射中最难掌握的两个属性。两者都在对象的关联操作中发挥作用。1.明确inverse和cascade的作用inverse 决定是否把对对象中集合的改动反映到数据库中,所以inverse只对集合起作用,也就是只对one-to-many或many-to-many有效(因 为只有这两种关联关系包含集合,而one-to-one和many-to-one只含有关系对方的一个引用)。cascade决定是否把对对象的改动反映到数据库中,所以cascade对所有的关联关系都起作用(因为关联关系就是指对象之间的关联关系)。2.inverse属性 :inverse所描
阅读全文
posted @
2014-01-15 14:09
c3tc3tc3t
阅读(243)
推荐(0)
遇到Caused by: java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider
摘要:今天在做spring和hibernate整合的时候遇到这个问题网上搜找到这里有解决办法http://blog.csdn.net/jueshengtianya/article/details/12223869参考 http://stackoverflow.com/questions/14730329/jpa-2-0-exception-to-use-javax-validation-package-in-jpa-2-01. 由于hibernate-validator-5.x.x已经不兼容validation-api-1.0.x,这是因为在hibernate- validator-5.x.xhib
阅读全文
posted @
2014-01-14 15:24
c3tc3tc3t
阅读(14989)
推荐(0)
hibernate抓取问题
摘要:当使用xml配置类之间的关系时 ,例如 学生 班级,多对一关系 /** * 默认情况会发出2条SQL语句,一条取student,一条取Classroom,其实这只需要一条sql * 解决办法 通过设置XML中的 //默认fetch=select * 可以完成对抓取的设置 */ session = HibernateUtil.openSession(); Student stu = (Student)session.load(Student.class, 1); //只查一个学生 System.out.println(stu.getName()+","...
阅读全文
posted @
2014-01-09 13:47
c3tc3tc3t
阅读(263)
推荐(0)