小妹求救:诡异的hibernate问题,插入数据时:null id in XXX entry 在线等~~~~
各位大侠:小妹遇见一个让人很无奈的问题,
小妹写了个用hibernate插数据的方法,如果运行一次的话,可以插入成功,如果批量运行100次得时候,也可以完全成功,可是如果运行100+的话,就报错啦~~~呜呜呜~~~~~求各位大侠帮帮忙啊~~
报错日志如下:
[ERROR] 2011-08-11 10:44:31,781 [org.hibernate.AssertionFailure :22] - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null id in com.test.car.CarLog entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:55)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:164)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:120)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.test.tools.DAO.saveOrUpdate(DAO.java:52)
at com.test.Car.InCar(Car.java:257)
at org.xsocket.connection.HandlerAdapter.performOnData(HandlerAdapter.java:232)
at org.xsocket.connection.HandlerAdapter.access$200(HandlerAdapter.java:40)
at org.xsocket.connection.HandlerAdapter$PerformOnDataTask.run(HandlerAdapter.java:200)
at org.xsocket.SerializedTaskQueue.performPendingTasks(SerializedTaskQueue.java:161)
at org.xsocket.SerializedTaskQueue.access$100(SerializedTaskQueue.java:40)
at org.xsocket.SerializedTaskQueue$MultithreadedTaskProcessor.run(SerializedTaskQueue.java:189)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
--------------------编程问答-------------------- 救命啊~~~ --------------------编程问答-------------------- 代码贴出来看看 --------------------编程问答-------------------- 没遇到过。提示this may indicate a bug in Hibernate --------------------编程问答-------------------- http://xiaogui9317170.iteye.com/blog/327876
对你有帮助 --------------------编程问答-------------------- 又是小妹? --------------------编程问答-------------------- 谢谢各位啊~~~ --------------------编程问答-------------------- Hibernate总是有一些诡异的问题 应该是你调用那个增加方法的时候 产生了休眠 你把你那个增加方法代码贴出来 --------------------编程问答-------------------- 我查询的时候都诡异了 查同一条记录 查到几千次的时候 就报这种错 --------------------编程问答-------------------- (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
是不是session的问题,看看session没关闭还是怎么回事
--------------------编程问答-------------------- null id in com.test.car.CarLog entry这是你异常的的一段信息。。。 --------------------编程问答-------------------- hibernate 批量插入的时候事务提交问题,执行插入操作的时候里面的数据先放到一个池里面,然后提交事务,池肯定有一个容量的,当超过了这个容量,执行的时候就会出错。 --------------------编程问答-------------------- 没有代码只能告猜了,
连接池配了没,配了改大点。
补充:Java , Java EE