Hibernate
LGF124241877
这个作者很懒,什么都没留下…
展开
-
Hibernate 插入数据时候会覆盖原来的数据,每次就一条数据
最近刚刚开始学hibernate,每次插入数据数据时候发现插入同样的主键不会报错。查看表后发现每次新插入的数据都会替换上一条记录,具体原因是:在[size=large]M01_Student.hbm.xml[/size]配置文件中设置了下面的一句[code="java"] create[/code]把这句删除就可以了。原因: ...原创 2011-06-27 00:42:50 · 699 阅读 · 0 评论 -
org.hibernate.HibernateException: No CurrentSessionContext configured!
在配置好的hibernate中运行时候发现了下面的错误[code="java"]Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.impl.SessionFactoryImpl.getCurrentSessi...原创 2011-06-27 00:47:26 · 119 阅读 · 0 评论 -
org.hibernate.MappingException: An AnnotationConfiguration instance is required
在一次调试运行中爆下面的错误:[img]http://124241877-qq-com.iteye.com/upload/picture/pic/93184/b5879856-a4a6-37e4-9aeb-d73a9f0fc835.jpg[/img]已过一番查找后发现在使用了Annotation所以必须把原来的[code="java"]Configuration confi...原创 2011-06-27 00:53:47 · 138 阅读 · 0 评论 -
a different object with the same identifier value was already associated with th
最近在做批量更新的时候发现如下问题:[code="java"]Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.xxx.db.hibernate.m...原创 2012-11-08 10:53:21 · 110 阅读 · 0 评论 -
Hibernate 原生SQL查询反射到POJO
在使用hibernate过程中有许多查询需要用到sql原生语句进行查询。同时又希望查询结果可以直接保存到POJO对象中。下面给出hibernate的实现方式。需求: 查询如下表:[img]http://dl.iteye.com/upload/attachment/0080/5743/3d05c753-841d-3685-8e3c-e88c39762fa1.jpg[/img]...原创 2013-02-19 10:40:45 · 165 阅读 · 0 评论