Hi, I'm trying to set up a relationship between account and role, for DatabaseServerLoginModule, for new user registration.
My T_ROLES table is username, userRoles, roleGroup and my T_ACCOUNT table is userId, pwd All three columns in T_ROLES form the primary key, and userId is the primary key for T_ACCOUNT. The entities are declared as follows in ejb-jar.xml anonymous wrote : | <![CDATA[]]> | | <ejb-name>Account</ejb-name> | | <local-home>xpetstore.domain.signon.interfaces.AccountLocalHome</local-home> | xpetstore.domain.signon.interfaces.AccountLocal | | <ejb-class>xpetstore.domain.signon.ejb.AccountCMP</ejb-class> | <persistence-type>Container</persistence-type> | <prim-key-class>java.lang.String</prim-key-class> | False | <cmp-version>2.x</cmp-version> | <abstract-schema-name>Account</abstract-schema-name> | <cmp-field > | <![CDATA[]]> | <field-name>userId</field-name> | </cmp-field> | <cmp-field > | <![CDATA[]]> | <field-name>passwordHash</field-name> | </cmp-field> | <primkey-field>userId</primkey-field> | | <!-- Write a file named ejb-finders-AccountEJB.xml if you want to define extra finders. --> | | anonymous wrote : | <![CDATA[]]> | | <ejb-name>Role</ejb-name> | | <local-home>xpetstore.domain.signon.interfaces.RoleLocalHome</local-home> | xpetstore.domain.signon.interfaces.RoleLocal | | <ejb-class>xpetstore.domain.signon.ejb.RoleCMP</ejb-class> | <persistence-type>Container</persistence-type> | <prim-key-class>xpetstore.domain.signon.interfaces.RolePK</prim-key-class> | False | <cmp-version>2.x</cmp-version> | <abstract-schema-name>Role</abstract-schema-name> | <cmp-field > | <![CDATA[]]> | <field-name>userId</field-name> | </cmp-field> | <cmp-field > | <![CDATA[]]> | <field-name>userRoles</field-name> | </cmp-field> | <cmp-field > | <![CDATA[]]> | <field-name>roleGroup</field-name> | </cmp-field> | | <!-- Write a file named ejb-finders-RoleEJB.xml if you want to define extra finders. --> | | The relationship is anonymous wrote : <ejb-relation > | <ejb-relation-name>account-roles</ejb-relation-name> | | <ejb-relationship-role > | <ejb-relationship-role-name>account-has-roles</ejb-relationship-role-name> | One | <relationship-role-source > | <ejb-name>Account</ejb-name> | </relationship-role-source> | <cmr-field > | <cmr-field-name>roles</cmr-field-name> | <cmr-field-type>java.util.Collection</cmr-field-type> | </cmr-field> | </ejb-relationship-role> | | <ejb-relationship-role > | <ejb-relationship-role-name>role-belongs_to-account</ejb-relationship-role-name> | Many | <cascade-delete/> | <relationship-role-source > | <ejb-name>Role</ejb-name> | </relationship-role-source> | </ejb-relationship-role> | | </ejb-relation> | jbosscmp-jdbc.xml relationship is anonymous wrote : <ejb-relation> | <ejb-relation-name>account-roles</ejb-relation-name> | | <foreign-key-mapping/> | | <ejb-relationship-role> | <ejb-relationship-role-name>account-has-roles</ejb-relationship-role-name> | <key-fields> | <key-field> | <field-name>userId</field-name> | <column-name>username</column-name> | </key-field> | </key-fields> | | </ejb-relationship-role> | <ejb-relationship-role> | <ejb-relationship-role-name>role-belongs_to-account</ejb-relationship-role-name> | <key-fields/> | | </ejb-relationship-role> | </ejb-relation> | What I find is that the userId is being written to the roleGroup field, even though I set the RolePK as follows: anonymous wrote : RolePK r=new RolePK(account.getUserId(),"customer","Roles"); | roles.add(getRoleLocalHome().create(r)); | r=new RolePK(account.getUserId(),"caller_"+account.getUserId(),"CallerPrincipal"); | roles.add(getRoleLocalHome().create(r)); | // this stuff requires admin privilege | account.setRoles(roles); | I presume this error has something to do with it being a compound primary key, and is the last field of the key - I dont know. Can anyone shed some light on why the userGroup fields don't have the values I set for them, but the value of userId instead. (RolePK is autogenerated by xdoclet) Thanks Martin <a href="http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3825644#3825644">View the original post</a> <a href="http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3825644>Reply to the post</a> ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user