-->
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: can changes in parent set cause changes in mapped child tbl?
PostPosted: Tue Mar 01, 2005 4:38 pm 
Newbie

Joined: Tue Mar 01, 2005 3:58 pm
Posts: 1
given the mapping below, i want to be able to do this:

CommunityBean cb = getCommunityBean(s); // from CommunityBean community where community.name = ?
Set users = cb.getUsers();
users.removeAll(oldUsers);
cb.setUsers(users);
s.update(cb);

i also want to maintain the ability to query within the user set based on the communityName field:

from CommunityUserBean user where user.communityName = ? and ...

i seem to be missing something fundamental. as i have things right now, the CommunityBean class is meaningless. what i really want is a bidirectional mapping between CommunityBean and a set of CommunityUserBeans ... such that i can query for CUBs based on the parent (CommunityBean) name, and cause updates in the CB's users set by modifying the CB's users Set (in the example above, i don't want to delete each CUB).

any help is appreciated.

Hibernate version: 3.0 beta 4

Mapping documents:

<hibernate-mapping package="com.sun.portal.community.impl.hibernate">
<class name="CommunityBean" table="COMMUNITY">
<id name="name" type="string">
<column name="NAME" not-null="true"/>
<generator class="assigned"/>
</id>

<set name="users" table="COMMUNITY_USERS" inverse="true" lazy="true" cascade="all">
<key column="COMMUNITY_NAME" not-null="true"/>
<one-to-many class="com.sun.portal.community.impl.hibernate.CommunityUserBean"/>
</set>
</class>
</hibernate-mapping>

<hibernate-mapping package="com.sun.portal.community.impl.hibernate">
<class name="CommunityUserBean" table="COMMUNITY_USERS">
<id name="userName" type="string">
<column name="USER_NAME" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="roleName" column="ROLE_NAME"/>
<property name="communityName" column="COMMUNITY_NAME"/>
</class>
</hibernate-mapping>

Name and version of the database you are using: derby 10.0.0.2.1


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.