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
|