[OJB-developers] non-decomposed m:n-mappings update problem
Brought to you by:
thma
From: Hoang, H. <Hai...@co...> - 2002-05-28 14:40:47
|
I've a many-to-many relationship as shown by the following tables, repository.xml, and the java files: The problems I encountered: 1. Update the Role object to include the permissions collection doesn't work 2. Update the parentId on the role object doesn't work 3. What is this tag <inverse_fk_descriptor_ids>999</inverse_fk_descriptor_ids> means? ---------------------------------------------------------------------------- ------------------ HTG_PERMISSION HTG_ROLE HTG_ROLE_PERMISSION ---------------------------------------------------------------------------- ------------------ And the repository.xml file: <ClassDescriptor id="1"> <class.name>com.htg.base.bo.PermissionImpl</class.name> <table.name>htg_permission</table.name> <FieldDescriptor id="1"> <field.name>id</field.name> <column.name>permission_id</column.name> <jdbc_type>BIGINT</jdbc_type> <PrimaryKey>true</PrimaryKey> <autoincrement>true</autoincrement> </FieldDescriptor> <FieldDescriptor id="2"> <field.name>name</field.name> <column.name>permission_name</column.name> <jdbc_type>VARCHAR</jdbc_type> </FieldDescriptor> <FieldDescriptor id="3"> <field.name>description</field.name> <column.name>description</column.name> <jdbc_type>VARCHAR</jdbc_type> </FieldDescriptor> <CollectionDescriptor id="1"> <cdfield.name>roles</cdfield.name> <items.class>com.htg.base.bo.RoleImpl</items.class> <inverse_fk_descriptor_ids>999</inverse_fk_descriptor_ids> <indirection_table>htg_role_permission</indirection_table> <fks_pointing_to_this_class>permission_id</fks_pointing_to_this_class> <fks_pointing_to_items_class>role_id</fks_pointing_to_items_class> <auto.retrieve>true</auto.retrieve> <auto.update>false</auto.update> <auto.delete>false</auto.delete> <orderby sort="ASC">name</orderby> </CollectionDescriptor> </ClassDescriptor> <ClassDescriptor id="2"> <class.name>com.htg.base.bo.RoleImpl</class.name> <table.name>htg_role</table.name> <FieldDescriptor id="1"> <field.name>id</field.name> <column.name>role_id</column.name> <jdbc_type>BIGINT</jdbc_type> <PrimaryKey>true</PrimaryKey> <autoincrement>true</autoincrement> </FieldDescriptor> <FieldDescriptor id="2"> <field.name>name</field.name> <column.name>role_name</column.name> <jdbc_type>VARCHAR</jdbc_type> </FieldDescriptor> <FieldDescriptor id="3"> <field.name>description</field.name> <column.name>description</column.name> <jdbc_type>VARCHAR</jdbc_type> </FieldDescriptor> <FieldDescriptor id="4"> <field.name>parentId</field.name> <column.name>parent_id</column.name> <jdbc_type>BIGINT</jdbc_type> </FieldDescriptor> <CollectionDescriptor id="1"> <cdfield.name>permissions</cdfield.name> <items.class>com.htg.base.bo.PermissionImpl</items.class> <inverse_fk_descriptor_ids>999</inverse_fk_descriptor_ids> <indirection_table>htg_role_permission</indirection_table> <fks_pointing_to_this_class>role_id</fks_pointing_to_this_class> <fks_pointing_to_items_class>permission_id</fks_pointing_to_items_class> <auto.retrieve>true</auto.retrieve> <auto.update>true</auto.update> <auto.delete>false</auto.delete> <orderby sort="ASC">name</orderby> </CollectionDescriptor> </ClassDescriptor> ---------------------------------------------------------------------------- ------------------ public class PermissionImpl implements Permission, Serializable { private Collection roles; public PermissionImpl() {} public PermissionImpl(Long id, String name, String description) { this.id = id; this.name = name; this.description = description; } ... public Collection getRoles() { return roles; } public void setRoles(Collection roles) { this.roles = roles; } } ---------------------------------------------------------------------------- ------------------ public class RoleImpl implements Role, Serializable { private Long parentId; private Collection permissions; public RoleImpl() {} public RoleImpl(Long id, String name, String description, Long parentId) { this.id = id; this.name = name; this.description = description; this.parentId = parentId; } ... /** * @see Role#setParentId(Long) */ public void setParentId(Long Id) { this.parentId = id; } /** * @see Role#getParentId() */ public Long getParentId() { return parentId; } /** * @see Role#getPermissions() */ public Collection getPermissions() { return permissions; } /** * @see Role#setPermissions(Collection) */ public void setPermissions(Collection permissions) { this.permissions = permissions; } } ---------------------------------------------------------------------------- ------------------ |