-->
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: Not committing transaction blocks multiple sessions
PostPosted: Mon Jul 05, 2004 8:42 am 
Newbie

Joined: Mon Jul 05, 2004 8:37 am
Posts: 15
Hello,

I'm very new to hibernate and I wanted to get some clarification on something. I have two connection factories and I created a session from each factory. I forgot to commit a transaction on the first session and it blocked both sessions from committing my data to the database. Is this supposed to happen? I would have thought the second session, that I closed correctly, would have updated in the database since it is a seperate transaction.

Thanks,
twufire


Top
 Profile  
 
 Post subject: Not committing transaction blocks multiple sessions
PostPosted: Mon Jul 05, 2004 9:17 am 
Newbie

Joined: Mon Jul 05, 2004 8:37 am
Posts: 15
I forgot to mention I'm running hibernate as a service of JBoss. These hibernate calls are being made from within the jboss vm in my servlet.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 05, 2004 10:23 am 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
twufire, what I am assuming happened is that whatever you were doing you managed to get yourself into a deadlocked state.

So yes, if you had 2 transactions going it IS possible that you blocked yourself on the database level.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 05, 2004 1:50 pm 
Newbie

Joined: Mon Jul 05, 2004 8:37 am
Posts: 15
I'm unsure what I'm doing wrong. Here is my code snippet. If you notice I forget to close the transaction, transa. This causes the second session from factoryb not to commit as well. As soon as I commit the transaction and run it again it works. Perhaps because I'm running under jboss and it is managing transactions. I tried XA drivers but they did not work either.

<code>

Session sessa = facotrya.openSession();

Transaction transa = sessa.beginTransaction();

Test testa= (Test) sessa.load(Test.class, new BigDecimal(1));
testa.setTestText("ROC");

// part 2//

Session sessb = facotryb.openSession();

Stuff sb = new Stuff(new BigDecimal(17), "Record 17...");

sessb.save(sb);
sessb.flush();
sessb.close();

</code>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 07, 2004 9:58 am 
Newbie

Joined: Mon Jul 05, 2004 8:37 am
Posts: 15
I'm trying to use two different transactions for two different data sources. I have two mbeans setup in my jboss-service.xml file. They both have the same user transactino attribute:

<attribute name="UserTransactionName">UserTransaction</attribute>

Could this be the problem? Does this need to be different for different data sources.


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.