-->
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.  [ 5 posts ] 
Author Message
 Post subject: Couple of quick questions Please
PostPosted: Mon Dec 15, 2003 6:01 pm 
Beginner
Beginner

Joined: Thu Sep 11, 2003 8:41 am
Posts: 35
Location: Atlanta, GA
I'm working on doing a transaction with several save/update statements within it.

I'm not sure what's going on, but it performs the first insert perfectly, then on the next insert I get a "net.sf.hibernate.HibernateException: Session is currently disconnected"

Then when trying to commit, I get ...

2003-12-15 16:59:36,075 [http8080-Processor24] ERROR: Could not synchronize database state with session
net.sf.hibernate.HibernateException: Session is currently disconnected
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3277)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:57)
at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:105)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:515)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:498)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:28)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2362)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2316)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2258)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:57)

Can anyone give me any info on what this may be and how I can go about fixing it. Maybe I'm forgetting something.

_________________
I am the reason spellcheck was created!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 8:38 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Quote:
Maybe I'm forgetting something.


Maybe. But who knows it if you are not showing your code?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 9:46 pm 
Beginner
Beginner

Joined: Thu Sep 11, 2003 8:41 am
Posts: 35
Location: Atlanta, GA
dimas wrote:
Maybe. But who knows it if you are not showing your code?


Was rushing into a meeting. Just wanted to get the post out there to see if someone who has seen it before could give me ideas until I got the chance to post the code.

Code:
      Session session = null;
      Transaction txn = null;
      try {
         session = getSession();
         txn = session.beginTransaction();
         
         Party party = new Party();
         session.save( party );

         PartyRole role = new PartyRole();
         session.save( role );
         
         PartyRelationship rel = new PartyRelationship();
         session.save( rel );
         txn.commit();
      }
      catch ( Exception e ) {
         txn.rollback();
      }
      finally {
         session.close();         
      }


That's it. Nothing fancy.

Any ideas?

_________________
I am the reason spellcheck was created!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 10:10 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Quote:
I'm not sure what's going on, but it performs the first insert perfectly, then on the next insert I get a "net.sf.hibernate.HibernateException: Session is currently disconnected"

Then when trying to commit, I get ...


I do not understand how do you arrive to commit() if you are getting exception on second insert (second session.save() or what?). In the case of Hibernate exception you should immediately leave try block so you just can not perform commit().

To be honest I have no idea why this code may fail (unless you are doing some BAD THINGS with interceprors / custom persisters or other "advenced" stuff).

Do I understand correctly what code you shown here being the only content of "main" method (except for session factory preparation of course) causes this exception? Could you paste debug log here?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 10:16 pm 
Beginner
Beginner

Joined: Thu Sep 11, 2003 8:41 am
Posts: 35
Location: Atlanta, GA
I found the problem. It was an oversite after a copy - paste.

Sorry, thanks for your time!

By the way, the way I know it was throwing an exception before the commit, for debugging purposes, I put try - catch blocks around each save and saw the error pop up in my console.

_________________
I am the reason spellcheck was created!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.