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.  [ 2 posts ] 
Author Message
 Post subject: @Transient question
PostPosted: Fri Dec 05, 2008 2:53 pm 
Newbie

Joined: Wed Oct 08, 2008 3:06 pm
Posts: 13
Location: Seattle
I have a question about how to use @Transient.. I have an object containing a @Transient property name user. This property doesn't map any fields in the database and I just use it to store user information for some purposes.

I am able to get the user information for saving because I basically work on the same object which has the @Transient user information from the beginning to the end. But I have a problem with the delete because I have to load and delete in the same session. Whenever I did a load, the @Transient user information became null since that's not something in the database.

Is there a way that I can keep that @Transient field value in session and I can use it whenever I want without losing it?

Thank you..


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2008 12:22 am 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
One way that makes sense to me is the following:

1. you start the interaction and have the ID or some other property

2. at once you load the object from the database and start using

3. as part of using the object you set it's transient field

4. when you delete from the db you still have the transient field (with the rest of the object in memory)

It doesn't make sense to me that you would set the transient field on an object that is not the proper object. Either the transient field is tightly coupled to the object and you know before hand which object that is, or this field is not tightly coupled to the object in which case you can store it in some other data structure that you manage.

Maybe you are using this as part of some framework like Struts2 and the transient property comes from a form field. In that case you can either store into a different object in the action object or if you insist on storing in the persistent object you have to save a copy before loading the object then storing back in the object. Even better load into a new variable and copy/merge the relevant fields from the old variable.

Hope this helps.


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