-->
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: currently inserted value from table with in a transaction
PostPosted: Sun Feb 14, 2010 8:48 pm 
Newbie

Joined: Tue Jun 17, 2008 11:01 pm
Posts: 16
I need currently inserted value from table with in a transaction.

In the particular scenario I cannot use any locking mechanism, because locking all affected in transaction commit,

Actually am inserting a value to a table, just after that I need that inserted value ….

Eg:
Begin Transaction

Insert - value to table
select the value from table

Commit transaction
.......
Rollback transaction


I cannot get the value before the execution of transaction commit .

I found before commit data which are inserted is not reflecting to table, how can i get the reflected data ? also if roll back is executed need to remove the inserted data .. can u please suggest how to do this,



I found auto-commit property – but I d’t understood what it is.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: currently inserted value from table with in a transaction
PostPosted: Sun Feb 14, 2010 9:51 pm 
Newbie

Joined: Sun Feb 14, 2010 8:08 am
Posts: 12
If I am correct, you want the id generated for the insert statement in our query, for this the best place to go through is at http://docs.jboss.org/hibernate/stable/core/reference/en/html/mapping.html#mapping-declaration-idwhich talks about the id generations and there mapping.


Top
 Profile  
 
 Post subject: Re: currently inserted value from table with in a transaction
PostPosted: Mon Feb 15, 2010 3:22 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
After the insert, force Hibernate to write the changes to the database with
Session.flush(). Then, read the following chapter in the documentation to understand why you have to do this: http://docs.jboss.org/hibernate/stable/ ... e-flushing


Top
 Profile  
 
 Post subject: Re: currently inserted value from table with in a transaction
PostPosted: Tue Mar 16, 2010 5:50 am 
Newbie

Joined: Tue Jun 17, 2008 11:01 pm
Posts: 16
Thanks for your replay

Here am using declarative transaction for hibernate, so Session.flush() is not working for me, I think this is due to declarative transaction (dispatcher servlet).

So how can i do this here in my code ?


Top
 Profile  
 
 Post subject: Re: currently inserted value from table with in a transaction
PostPosted: Tue Apr 20, 2010 2:19 am 
Newbie

Joined: Tue Jun 17, 2008 11:01 pm
Posts: 16
Hai all

Till now it is not working , then how can i apply Session.flush() in my code.

Thanks in advance.


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.