The relationship between the User entity and UserType etity is as follows:
1 User can only have 1 UserType, but 1 UserType can belong to many Users. Furthermore, 
User maintains a reference to UserType, but UserType does not have a reference to 
User. So in ejb-jar.xml, we have defined the one-to-many unidirectional relationship 
between the UserEJB and the UserTypeEJB is as follows:

 
   <ejb-relation>
     <ejb-relation-name>User-UserType</ejb-relation-name>
     <ejb-relationship-role>
       One
       <relationship-role-source>
         <ejb-name>UserTypeEJB</ejb-name>
       </relationship-role-source>
     </ejb-relationship-role>
     <ejb-relationship-role>
       <ejb-relationship-role-name>User-has-a-UserType</ejb-relationship-role-name>
       Many
       <relationship-role-source>
         <ejb-name>UserEJB</ejb-name>
       </relationship-role-source>
       <cmr-field>
         <cmr-field-name>userTypeLocal</cmr-field-name>
       </cmr-field>
     </ejb-relationship-role>
     <ejb-relationship-role-name>UserType-has-many-Users</ejb-relationship-role-name>
   </ejb-relation>
  


I have also added the following to jbosscmp-jdbc.xml:

 
     <ejb-relation>
        <ejb-relation-name>User-UserType</ejb-relation-name>
        <foreign-key-mapping/>
        <ejb-relationship-role>
          
<ejb-relationship-role-name>UserType-has-many-Users</ejb-relationship-role-name>
        </ejb-relationship-role>
        <ejb-relationship-role>
          <ejb-relationship-role-name>User-has-a-UserType</ejb-relationship-role-name>
           <fk-constraint>true</fk-constraint>
            <key-fields>
             <key-field>
               <field-name>userTypeLocal</field-name>
               <column-name>user_type_id</column-name>
             </key-field>
           </key-fields>
        </ejb-relationship-role>
     </ejb-relation>
 


However, when the inserting the above xml fragment into jbosscmp-jdbc.xml, I get an 
error saying that there is no ejb-relationship-tag-name element.  I do not know the 
reason for this, as I have followed the dtd for jbosscmp-jdbc.xml, and confirmed that 
the ejb-relationship-role-name tags match in both jbosscmp-jdbc.xml and ejb-jar.xml.

Another modification I have tried is removing the relationships tag altogether from 
jbosscmp-jdbc.xml.  This allowed me to deploy my beans.  I also added the following 
cmp-field to the 'user' entity in jbosscmp-jdbc.xml:
        <cmp-field>
           <field-name>userTypeLocal</field-name>
           <column-name>UTL</column-name>
           
             <property-name>type</property-name>
             <column-name>user_type</column-name>
             <jdbc-type>VARCHAR</jdbc-type>
             <sql-type>VARCHAR(20)</sql-type>
           
        </cmp-field>
This xml fragment is in jbosscmp.xml.  The result of this is that there is a field 
called utl in the user_types table in the database. But the value being inserted into 
this field is not the foreign key integer id of the user_types table, but a serialized 
version of the UserTypeEJB. 

Please advise on the following issues described above:
1. no ejb-relationship-role-name defined error.
2. serialized UserType being stored in RDBMS table users, instead of foreign key 
integer.

Thank you.

Amar
[EMAIL PROTECTED]

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3840181#3840181

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3840181


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to