-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: commit session crashes
PostPosted: Mon Aug 13, 2007 11:26 am 
Beginner
Beginner

Joined: Thu Aug 09, 2007 3:48 pm
Posts: 38
Hibernate version: 3.2

Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtil.getSession();
session.beginTransaction();
for (MyObjA o : MyObjASet)
session.save(o);
session.update(MyObjB);
MyObjB.getMyObjAList().addAll(MyObjASet);
session.getTransaction().commit();

Full stack trace of any exception that occurs:
13/08/2007 18:16:06 [ERROR] org.hibernate.util.JDBCExceptionReporter - failed batch
13/08/2007 18:16:06 [ERROR] org.hibernate.util.JDBCExceptionReporter - failed batch
13/08/2007 18:16:06 [ERROR] 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)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)

Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 69 more

Name and version of the database you are using: HSQLDB


I am adding a set of new objects to the session and then adding them to some other object that holds set of these objects and the commit fails.
Any idea why it can fail?

The definition in the Entity of MyObjB:
@CollectionOfElements
@OrderBy("colOrder")
@Fetch(value = FetchMode.JOIN)
@Cascade(org.hibernate.annotations.CascadeType.ALL)
public List<MyObjA> getMyObjAList()
{
...
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 11:48 am 
Beginner
Beginner

Joined: Sat Jan 14, 2006 10:05 am
Posts: 22
Location: spb.ru
try this

Code:
Session session = HibernateUtil.getSession();
session.beginTransaction();
MyObjB.getMyObjAList().addAll(MyObjASet);
session.update(MyObjB);
session.getTransaction().commit();


use hibernate.show_sql=true option to get hibernate's sql in console


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 11:57 am 
Beginner
Beginner

Joined: Thu Aug 09, 2007 3:48 pm
Posts: 38
Quote:
Session session = HibernateUtil.getSession();
session.beginTransaction();
MyObjB.getMyObjAList().addAll(MyObjASet);
session.update(MyObjB);
session.getTransaction().commit();


will the above code add MyObjASet to its own table i addition to adding it to the mapping table between MyObjA and MyObjB?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.