-->
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.  [ 3 posts ] 
Author Message
 Post subject: Strange problem with hibernate set
PostPosted: Fri Jun 18, 2004 9:43 am 
Beginner
Beginner

Joined: Thu Jun 10, 2004 6:52 am
Posts: 29
I have something like this in an application:

User (1) -> (*) UserContact (1 to n User - > UserContact) and after that:
UserContact (1) -> (1) Contact ( 1 to 1 UserContact ->Contact ) where Contact is itself a User

the problem I have is this: When I remove a UserContact from the User's userContacts set, IT DOESN'T UPDATE the relationship in the db. It should remove the link from User to UserContact according to the hibernate docs. Also when I iterate over the userContacts collection and get an element from it and test userContacts.contains(an element from iterator) IT RETURNS FALSE. How can it not be here if I get it with the collection's iterator ? what am I missing here ?

Hibernate 2.1.1

- User mapping

<set
name="userContacts"
lazy="true"
inverse="true"
>
<key>
<column name="user_id" />
</key>
<one-to-many
class="com.ags.mobilechat.model.UserContact"
/>
</set>

- UserContact mapping

<many-to-one
name="contact"
class="com.ags.mobilechat.model.User"
>
<column name="contact_id" />
</many-to-one>

<many-to-one
name="user"
class="com.ags.mobilechat.model.User"
>
<column name="user_id" />
</many-to-one>

Here's the code:

try {
session = sessionFactory.getSession();
tx = session.beginTransaction();
result = callback.executeInSession(session);
tx.commit();
} catch (Exception e) {
.....
}

An I am implementing the callback.executeInSession for each transactional operation I need to perform


Top
 Profile  
 
 Post subject: Strange problem with hibernate set (UPDATE)
PostPosted: Fri Jun 18, 2004 9:46 am 
Beginner
Beginner

Joined: Thu Jun 10, 2004 6:52 am
Posts: 29
I tried also with cascade delete-orphan and all-delete-orphan. I doesn't remove the UserContact form user_contacts table


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 3:31 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Read the Parent child relationship chapter and this one http://www.hibernate.org/155.html

_________________
Emmanuel


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