-->
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.  [ 1 post ] 
Author Message
 Post subject: transaction.commit not flushing data to DB
PostPosted: Fri Dec 16, 2011 6:00 pm 
Newbie

Joined: Thu Jun 02, 2011 4:36 pm
Posts: 2
Hi,

I have a method in which I first persist an entity to a table (enclosed in a transaction and using transaction.commit). Then I issue a statement to retrieve all the entities in the table and use that entry to add another entity to a different table.

Code:
method()
{
    (using transaction)
    {
         save to table1 using tx.commit(); //step 1
    }
    (using transaction)
    {
         retrieve above entry from database(); //step 2
         save another entity to table2 with a relation to the entity in table1 using tx.commit(); //step 3
     }
}   


The issue that I am facing is that in step 3, it is saying that it cannot find the item created in step1. This happens intermittently. To investigate this I setup a sql trace. When the method works correctly, the insert query from step 1 is issued first followed by the retrieve query from step2. But when the method fails, the corresponding trace shows that the query from step 2 is being issued first followed by the insert query from step 1.

The nHibernate documentation states that if a commit is done in a transaction, the query is sent immediately to the database. If that is the case, why are the sql statements being issued in that order?

Thanks,
Sandeep


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

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.