Hibernate DataException : could not update
I have received an exception from a live deployment of a web application (JBoss, Turbine, Hibernate). I can not reproduce the exception, therefore I can not fix the bug. Here is the exception that I get:
org.hibernate.exception.DataException: could not update: [com.myproject.project.mypackage.objects.MyObject#1190]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2425)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
The interesting thing is that I get this could not update error when the following hql is executed:
select sum(开发者_JAVA技巧entity.totalPrice) from Entity entity where entity.parent.id = :parentId and deleted is null
Several entities belong to one parent. This hql is a part of a bigger update process. I need the sum of totalPrices to update with it another entity. Is it possible that the could not update refers to the update process? I do not think this is the case since the error occurs before the update is executed. More exactly, the exception occurs when the list() method is called on the Query object which holds the hql.
I have tried to reproduce the exception with totalPrice of the entities set to null, but that does not give any exception. If I have a lot of entities attached to the same parent and the sum of their totalPrice exceeds the limit I get a could not insert exception. I can not figure out what is the problem.
I think first attribute name supposed to be entity.parent_id
and entity.deleted
instead of simply deleted.
final query supposed to be something like...
select sum(entity.totalPrice) from Entity entity where entity.parent_id = :parentId and entity.deleted is null
make sure that parent_id attribute name is correct.
精彩评论