-->
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: Detached Objects
PostPosted: Tue May 26, 2009 2:26 pm 
Newbie

Joined: Wed May 20, 2009 3:00 am
Posts: 5
I have the following scenario:

The User object and the user's Roles on various projects are persisted in the database. The User object and the Role objects are loaded using hibernate when the user logs into the application. Now, if the admin user logs in and changes the Role of the user on a project, then the change is affected only in the subsequent login of the user since the application uses the user and role objects stored in the http session. Whereas i want the changes to reflect instantly. Since the data is present in the detached objects it does not get synchronized when the data is changed in the database.

The question i have now is whether the role objects should always be fetched from the database instead of caching them in memory as objects?

Secondly, what would be the better design approach to fetch the data in various parts of the applications. I had 2 options in mind:

1. Expose a method in the business layer to get roles of a given user and use it wherever the user roles are required. Since this is an existing application, this option would be change in lot of places.
2. Change the implementation of the getRoles() method in the User class to fetch the role objects associated to the user objects from the database every time instead of caching. This would mean that the User class will need access to the DAO. Would it be odd to access a DAO from a domain object.


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.