-->
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.  [ 1 post ] 
Author Message
 Post subject: lifecycle - caching/retrieving user object
PostPosted: Tue May 04, 2004 2:33 pm 
Beginner
Beginner

Joined: Thu Sep 11, 2003 12:53 pm
Posts: 23
Hi,

When I save my business object (e.g. Employee), I stamp the record with a "last_modified_date" value and a "last_modified_user" reference. (which links to the User class of system users). This allows my reports to say
Last modified by wglass 5/4/04.

Right now, every time my business logic saves the Employee object, it has to update these two fields. It occurs to me that it'd be nice if my domain logic (e.g. the Employee object) could handle this automatically.

To make this work, I can implement Lifecycle use the onSave and onUpdate methods. This will allow me to set the "last_update_date", but it looks impossible to set the "last_modified_user" field as it has no access to the current user object (stored in the HttpSession).

Here's my question. When I open the Hibernate session at the start of my HTTP request, I'd like to attach the user object to the Hibernate session. Then, all my business objects can have access to it in the onSave/onUpdate methods for automatic timestamping. This would simplify my code as it would allow each persistent object to manage the "last modified" info instead of the business logic attaching the user and stamping the date. I'm looking for a setAttribute/getAttribute type of functionality.

Is this feasible? Recommendations appreciated.

Best, WILL


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.