-->
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.  [ 4 posts ] 
Author Message
 Post subject: criteria.list() in flushDirty()
PostPosted: Tue Mar 02, 2004 2:55 pm 
Beginner
Beginner

Joined: Thu Dec 11, 2003 11:59 am
Posts: 24
Here's my situation.

I have a bunch of persisted objects. When flushDirty() is called on any of them, I do some work (e.g. send an email), but only if a certain value is set to true for the current transaction. I decided to store that value in an object that I persist with Hibernate. In the flushDirty(), query for the object and do a criteria.list().

The problem is that this triggers the whole flushDirty process again (to maintain consistency before the criteria.list), and the code goes into an infinite loop. Is there some way that I can get around this and do a query from a flushDirty?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 2:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Use another session

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2004 11:51 am 
Beginner
Beginner

Joined: Thu Dec 11, 2003 11:59 am
Posts: 24
If I use another session, I won't get any changes that have been made during the current transaction.

1) Start transaction
2) Set the "do some work" flag in the transaction local object to true.
3) Modify some objects
4) Commit transaction

The transaction local has not been stored in the database yet when the flushDirty() is called on the modified objects because changes to the transaction local are part of the transaction, whether its a new session or night (right?). Setting the transaction local cannot be performed before the start of the transaction for obvious reasons.

Is there a way that I can open a new session (still using my handy Hibernate MBean) but keep it from being linked to the container managed transaction? If I can't, I don't see how using another session is going to help me.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 5:16 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you can use the same connection for 2 sessions. Be careful however

_________________
Emmanuel


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