-->
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.  [ 8 posts ] 
Author Message
 Post subject: Seam and Extended persistent context....
PostPosted: Thu Oct 06, 2005 1:25 pm 
Beginner
Beginner

Joined: Tue Aug 03, 2004 1:13 pm
Posts: 23
Ive looked over the Seam docs and examples, and dont quite see how you would implement the editing of a db backed entity. I understand editing a new (transient) one, but dont see how the incremental changes to the persistent one wont get persisted untill you are done.

Given :

Statefull bean gets created
Extened persistence context gets injected
Methods are called to locate the entity to be edited which gets stored in the bean and exposed.
User interacts with the system and modifies the entity.

>>What happens when a transactional method (say to go lookup some other data that might be needed while editing) is called on that statful bean, wont the entity get flushed and commited since its dirty?


This doesnt relate only to Seam, the same condition can occur anytime you modify an entity outside of a transactional method, then call a transaction method.

Is there someway to demark a method as being readonly in reguards to the transaction such that it will only read data and never cause a commit?

Or should those methods be defined as REQUIRES_NEW instead of REQUIRED? Does requires new use a different EntityManager (ie Hibernate session)? If so wont there be issues with the original entity that is to be saved at some point referencing db backed entities loaded from a different session?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 1:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
huh??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 1:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
oh i get it

You need to use @FlushMode(NEVER) or, mark the methods NOT_SUPPORTED.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 1:38 pm 
Beginner
Beginner

Joined: Tue Aug 03, 2004 1:13 pm
Posts: 23
That way the methods that i consider readonly never cause a flush.

On the NOT_SUPPORTED option wouldnt that mean that the EM wouldnt have a current transaction and therefore cant be used or am I missing something?


BTW Seam looks pretty dang cool, addresses exactly what i been fighting with in jsf. Only problem is Im stuck on H2.1 and J1.4 =(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 1:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can run queries outside of tx context in EJB3.

But actually, I don't think this is the best solution really, since you wont be able to call persist() to save new objects.

FlushMode.NEVER is the best solution.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 1:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
BTW, HB2.1 and JDK5 have been out for over 6 months now. Time to upgrade.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 2:06 pm 
Beginner
Beginner

Joined: Tue Aug 03, 2004 1:13 pm
Posts: 23
I know, but the powers that be dont like change. Especially if its going to affect the timeline =)


Thanks for the help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 6:21 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
cmrudd wrote:
I know, but the powers that be dont like change. Especially if its going to affect the timeline =)


Year, that might speed up your project, safe choice not to try ;-p

_________________
Emmanuel


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