Hibernate version: hibernate-3.2.5.ga
Name and version of the database you are using: HQL
I have a class named
User that holds collection of
Category.
Now i want to remove one category from the user.
When i am doing that i see in the sql log performed and i see it first
deletes the entry then tries to update it and thus gets exception.
Anyone can explain this to me? (Code is following)
The code of User.java that defines category collection
Code:
@CollectionOfElements
@OrderBy("name")
@Fetch(value = FetchMode.JOIN)
@IndexColumn(name = "categories_index")
public List<Category> getCategories()
{
return this.categories;
}
Code deleting the category from the user:
Code:
Session session = HibernateUtil.getSession();
session.beginTransaction();
user.getCategories().remove(category);
session.update(user);
session.getTransaction().commit();
The log of org.hibernate.SQL which is weird to me:
Code:
org.hibernate.SQL - delete from User_category where User_id=? and categories_index=?
org.hibernate.SQL - update User_category set categories_id=? where User_id=? and categories_index=?
org.hibernate.util.JDBCExceptionReporter - failed batch
org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
Notice first the delete and then the unexplained update....
Thanks