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: many-to-one synchronization issue (parent ref not updated)
PostPosted: Tue Jun 08, 2004 5:50 pm 
Newbie

Joined: Wed Apr 21, 2004 12:45 am
Posts: 11
MySQL 4.0.20
Hibernate 2.1.4
Tomcat 5.0.19


Summary:
User has the property "userStatus" which references a "UserStatus" object. User -> UserStatus is mapped as a many-to-one since a User will have a UserStatus assigned to them.

All of this works, however in the case when the administrator goes and edits the UserStatus directly (e.g. to change the name), when the admin then goes back to view the User list, the UserStatus name is not updated. After about 5 mins then the User gets the new values for UserStatus, but it is not immediate.


Question:
How/can I setup my mappings such that the Parent > Child relationship between User and UserStatus actually UPDATES the parent when the child is modified? I was under the impression that hibernate took care of this kind of stuff, but I must admit Hibernate is still a black box to me as I'm learning it.


Detail:
User has the follow many-to-one mapping to UserStatus:
Code:
<many-to-one
            name="userStatusDTO"
            class="com.kallasoft.paloverde.dto.user.UserStatusDTO"
            cascade="none"
            outer-join="auto"
            column="user_status_id"
        />



UserStatus is just a straight DTO that contains an id, name and description from the DB.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 6:02 pm 
Newbie

Joined: Wed Apr 21, 2004 12:45 am
Posts: 11
The way I originally had User defined was just a simple DTO of values, and from the User I would get the "userStatusID" and then turn around and ask my DAO to load the respective UserStatus given the ID...

I've been reading the forums more and more and I'm wondering if what might be best in my case is to keep my Hibernate objects simple DTOs like they were, make use of the DAO's to load the UserStatus (and other child attributes) whenever I need them via ID, but this time, enable a 2nd level cache like EH to help speed up the extra load operations when loading those child attributes via their IDs.... what do you guys think? Is this the 'right' way to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 6:49 pm 
Newbie

Joined: Wed Apr 21, 2004 12:45 am
Posts: 11
I'm starting to think that moving back to using the ID's and querying against the DAO's (which are sped up by the cache) are the way to do... because then when the admin manually edits the UserStatus for example, the update from the UserStatusDAO to the userStatus object in question would cause the entity in the cache it be updated/invalidated, so the next time the User requested its UserStatus by ID, the cache would contain the updated version that would be loaded up immediately.

Where as now because I'm using many-to-one relationships, my User is not seeing the updated UserStatus, and infact has to wait 5-10 minutes for the cache to update the value (default timeout I guess).

Any comments? Am I approaching this correctly?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 9:32 pm 
Newbie

Joined: Wed Apr 21, 2004 12:45 am
Posts: 11
Following this thread: http://forum.hibernate.org/viewtopic.php?p=2205148#2205148

It seems that my current situation where I'm using the Parent > Child relationship is not possible to do and have Hibernate keep everything in sycn for me... the thread above shows that an object has to explicitly resync with the database, but that means when my child updates, I need my parent to resync with the database, BUT the child doesn't have a reference to the parent, so it can't ask it to resync....

I feel like either I'm missing something big, or I'm asking something impossible...


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.