-->
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.  [ 6 posts ] 
Author Message
 Post subject: FindByCriteria returns delete instance
PostPosted: Fri May 26, 2006 10:52 am 
Newbie

Joined: Fri May 26, 2006 10:33 am
Posts: 3
Location: Teddington, London
I am evaluating the use of Hibernate and cannot work out how to do the following. My database is a single user database running locally on the users PC.

I wish to interact with the user as follows:
Start a transaction.
Use performs change to a table (insert, updates, deleted)
User then chooses to apply changes or cancel.
To apply, the transaction is commited, to cancel the transaction is rolledback.

While the user is performing operations, I would like any queries to return the objects current state. However, if the user has deleted an object it is still returned by my findbycriteria.

Any suggestions???

Thanks,

Neal


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 11:17 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
I was wondering which was the purpose of Session.flush().
Maybe this is an example that would make sense to that method.

Try experimenting with Session.flush() and Session.setFlushMode(flushMode).


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 11:23 am 
Newbie

Joined: Fri May 26, 2006 10:33 am
Posts: 3
Location: Teddington, London
I was actually just having a look at this but it seems to flush any outstanding session changes to the database. It is called during the transaction commit processing.

I'm actually looking into rollback now as a solution.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 11:26 am 
Beginner
Beginner

Joined: Wed May 17, 2006 3:38 am
Posts: 45
Transaction.commit() automatically call flush()....So perhaps calling flush() explicitly is not required here [BTW, flush() synchronises the database state


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 11:50 am 
Newbie

Joined: Fri May 26, 2006 10:33 am
Posts: 3
Location: Teddington, London
Rollback is the solution!

When the user applies or cancel then I commit of rollback the changes and the find performs as I require.

Thanks for the suggestions.

Neal


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 11:52 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
...


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