八月 12, 2016 11:00:49 上午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [zyg] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.transaction.TransactionSy…
在使用hibernate创建数据库的表格时,出现了如下报错: 十二月 28, 2016 10:17:02 上午 org.hibernate.tool.hbm2ddl.SchemaExport performERROR: HHH000389: Unsuccessful: create table NEWS (ID integer not null auto_increment, TITLE varchar(255), AUTHOR varchar(255), DATE datetime, DESC…
今日在开发时遇到一个比较奇怪的问题,保存时报这个异常: org.hibernate.AssertionFailure: null id in com.aa.TShoucang null id,这个是什么回事呢?数据库是自动增长了,hibernate映射文件也一切正常的了,看了后台也打印出了insert into ....这个的语句了,但为什么就是插入不成功呢? 本着知之为知之,不知google之的精神,google了一下,都是说数据库与映射文件不对应,数据库设置了不为null,但hibernat…
1.错误描写叙述 org.hibernate.AssertionFailure: null id in com.you.model.User entry (don't flush the Session after an exception occurs) at org.hibernate.event.internal.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:77) at org.h…
网上找了很久,发现造成原因有很多种,后来终于发现了端倪:看提示是发生了异常,查看业务代码,发现有这个逻辑:先插入记录,如果有唯一键约束异常(并发造成),catch时查询已存在的记录,查询的时候就报了此错误. 原因:异常后,再次查询的时候触发了autoFlush,先前保存失败的记录会再次保存,导致抛出如标题所述异常. 解决方法:数据库是mysql,改为采用 insert ignore into语句进行插入 当然有很多处理方法,就不赘述了…
我的是字段编码和数据库不匹配,是爬的微博数据…
对象属性有Blob类型: 而Blob需在输入流中读取: InputStream in = new FileInputStream(url.getFile()); Blob bookPic = lobHelper.createBlob(in, in.available()); book.setBookPic(bookPic); book2.setBookPic(bookPic); 如对象bookPic第二次使用的时候以无法再从in 中读取信息,因此报错 改进方法: 重新获取一次in 或使用 in.…
本片博文整理关于Hibernate中级联策略cascade和它导致的异常: Exception in thread "main" org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.mao.Address 关于这个异常应该是Hibernate初学者经常遇到的,导致…
struts2 + Spring +hibernate Hibernate工作原理及为什么要用?   原理:   1.读取并解析配置文件   2.读取并解析映射信息,创建SessionFactory   3.打开Sesssion   4.创建事务Transation  5.持久化操作   6.提交事务   7.关闭Session   8.关闭SesstionFactory    为什么要用:   1. 对JDBC访问数据库的代码做了封装,大大简化了数据访问层繁琐的重复性代码.    2. Hib…
异常一:org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined 此异常原因多半是因为一的一方的Set没有选类型 异常二:org.hibernate.AnnotationException: mappedBy reference an unknown target entity property 此异常很多情况下是因为@ManyToMany(…