I found the solution to my problem, so i thought i'd post it in case anyone
else runs into the same problem.

In the jbosscmp-jdbc.xml file, for the field-name fields, instead of the cmr
fields that i was specifying, you need to specify the primarykey fields for
the related beans. 

Thus this:

<ejb-relation>
            <ejb-relation-name>User-Roles</ejb-relation-name>
            <relation-table-mapping>
                <table-name>User_Role</table-name>
            </relation-table-mapping>

            <ejb-relationship-role>
 
<ejb-relationship-role-name>Role-Belongs-To-User</ejb-relationship-role-name
>
                <key-fields>
                    <key-field>
                        <field-name>roles</field-name>
                        <column-name>role_name</column-name>
                    </key-field>
                </key-fields>
            </ejb-relationship-role>
            <ejb-relationship-role>
 
<ejb-relationship-role-name>User-has-multiple-Roles</ejb-relationship-role-n
ame>
                <key-fields>
                    <key-field>
                        <field-name>users</field-name>
                        <column-name>user_name</column-name>
                    </key-field>
                </key-fields>
            </ejb-relationship-role>
        </ejb-relation>

Becomes this:

<ejb-relation>
            <ejb-relation-name>User-Roles</ejb-relation-name>
            <relation-table-mapping>
                <table-name>User_Role</table-name>
            </relation-table-mapping>

            <ejb-relationship-role>
 
<ejb-relationship-role-name>Role-Belongs-To-User</ejb-relationship-role-name
>
                <key-fields>
                    <key-field>
                        <field-name>name</field-name>
                        <column-name>role_name</column-name>
                    </key-field>
                </key-fields>
            </ejb-relationship-role>
            <ejb-relationship-role>
 
<ejb-relationship-role-name>User-has-multiple-Roles</ejb-relationship-role-n
ame>
                <key-fields>
                    <key-field>
                        <field-name>userName</field-name>
                        <column-name>user_name</column-name>
                    </key-field>
                </key-fields>
            </ejb-relationship-role>
        </ejb-relation>


To figure it out, I used middlegen to reverse engineer my dbschema, at which
point i noticed that the field-names weren't what I was doing.

.peter

-----Original Message-----
From: Alex Loubyansky [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 11:13 AM
To: Luttrell, Peter
Subject: Re[2]: [JBoss-user] JBossCMP Change Column Names in CMR


AFAIK, DD's are correct (with my remark). Do you really have in the
beans abstract accessors for cmr users and roles?

Wednesday, July 31, 2002, 6:47:55 PM, you wrote:


LP> I actually tried that and it didn't work either. 
LP> The only difference is that instead of complaining that it couldn't find
LP> "roles", now it complains that it can't find "users".

LP> Any other ideas?

LP> thanks.
LP> .peter

LP> -----Original Message-----
LP> From: Alex Loubyansky [mailto:[EMAIL PROTECTED]]
LP> Sent: Wednesday, July 31, 2002 1:11 AM
LP> To: Peter Luttrell
LP> Subject: Re: [JBoss-user] JBossCMP Change Column Names in CMR


LP> You need to interchange key-fields for ejb-relationship-role's in
LP> jbosscmp-jdbc.xml.

LP> I.e.
LP>
<ejb-relationship-role-name>Role-Belongs-To-User</ejb-relationship-role-name
>>
LP>    <key-fields>
LP>       <key-field>
LP>          <field-name>roles</field-name>
LP>          <column-name>role_name</column-name>
LP>       </key-field>
LP>    </key-fields>
LP> ...

LP> alex

LP> Wednesday, July 31, 2002, 1:45:57 AM, you wrote:

PL>> How do you change the column names for a table generated by a
LP> MANY-to-MANY
PL>> CMR?

PL>> Here's an example of what i've tried:

PL>> ejb-jar.xml:

PL>> <ejb-relation>
PL>>             <ejb-relation-name>User-Roles</ejb-relation-name>
PL>>             <ejb-relationship-role>
PL>>
LP>
<ejb-relationship-role-name>User-has-multiple-Roles</ejb-relationship-role-n
ame>>
PL>>                 <multiplicity>Many</multiplicity>
PL>>                 <relationship-role-source>
PL>>                     <ejb-name>Users</ejb-name>
PL>>                 </relationship-role-source>
PL>>                 <cmr-field>
PL>>                     <cmr-field-name>roles</cmr-field-name>
PL>>                     <cmr-field-type>java.util.Set</cmr-field-type>
PL>>                 </cmr-field>
PL>>             </ejb-relationship-role>
PL>>             <ejb-relationship-role>
PL>>
LP>
<ejb-relationship-role-name>Role-Belongs-To-User</ejb-relationship-role-name
>>
PL>>                 <multiplicity>Many</multiplicity>
PL>>                 <relationship-role-source>
PL>>                     <ejb-name>Roles</ejb-name>
PL>>                 </relationship-role-source>
PL>>                 <cmr-field>
PL>>                     <cmr-field-name>users</cmr-field-name>
PL>>                     <cmr-field-type>java.util.Set</cmr-field-type>
PL>>                 </cmr-field>
PL>>             </ejb-relationship-role>
PL>>         </ejb-relation>

PL>> My understanding of how to do this is via this entry in
LP> jbosscmp-jdbc.xml:

PL>> <ejb-relation>
PL>>             <ejb-relation-name>User-Roles</ejb-relation-name>
PL>>             <relation-table-mapping>
PL>>                 <table-name>User_Role</table-name>
PL>>             </relation-table-mapping>

PL>>             <ejb-relationship-role>
PL>>
LP>
<ejb-relationship-role-name>Role-Belongs-To-User</ejb-relationship-role-name
>>
PL>>                 <key-fields>
PL>>                     <key-field>
PL>>                         <field-name>users</field-name>
PL>>                         <column-name>user_name</column-name>
PL>>                     </key-field>
PL>>                 </key-fields>
PL>>             </ejb-relationship-role>
PL>>             <ejb-relationship-role>
PL>>
LP>
<ejb-relationship-role-name>User-has-multiple-Roles</ejb-relationship-role-n
ame>>
PL>>                 <key-fields>
PL>>                     <key-field>
PL>>                         <field-name>roles</field-name>
PL>>                         <column-name>role_name</column-name>
PL>>                     </key-field>
PL>>                 </key-fields>
PL>>             </ejb-relationship-role>
PL>>         </ejb-relation>


PL>> But the problem is that jboss complains ~ It doesn't seam to be able to
PL>> locate the "users" or "roles" field-name's that i've declared. Here's
LP> the
PL>> summary error:
PL>> [ObjectName: jboss.j2ee:service=EJB,jndiName=myBEAN
PL>>  state: FAILED
PL>>  I Depend On:
PL>>  Depends On Me: org.jboss.deployment.DeploymentException: CMP field for
PL>> key not found: field name=roles, ObjectName:
PL>> jboss.j2ee:service=EJB,jndiName=myBEAN

PL>> with the following exception:

PL>> 17:34:33,434 WARN  [ServiceController] Problem starting service
PL>> jboss.j2ee:service=EJB,jndiName=myBEAN
PL>> org.jboss.deployment.DeploymentException: CMP field for key not found:
PL>> field name=roles
PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.loadKey
LP> Fields(JDBCRe
PL>> lationshipRoleMetaData.java:374)
PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.init(JD
LP> BCRelationshi
PL>> pRoleMetaData.java:157)
PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.<init>(JDBCRela
LP> tionMetaData.
PL>> java:308)
PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCA
LP> pplicationMet
PL>> aData.java:383)
PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLo
LP> ader.java:75)

PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCS
LP> toreManager.j
PL>> ava:677)
PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreMa
LP> nager.java:38
PL>> 9)
PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:
LP> 339)
PL>>         at
PL>>
LP>
org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java
LP> :198)
PL>>         at
org.jboss.ejb.EntityContainer.start(EntityContainer.java:376)
PL>>         at org.jboss.ejb.Container.invoke(Container.java:793)
PL>>         at
LP> org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
PL>>         at
PL>> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
PL>>         at
PL>>
LP>
org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.jav
LP> a:950)
PL>>         at $Proxy6.start(Unknown Source)
PL>>         at
PL>> org.jboss.system.ServiceController.start(ServiceController.java:384)
PL>>         at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
PL>>         at
PL>>
LP>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
LP> .java:25)
PL>>         at java.lang.reflect.Method.invoke(Method.java:324)
PL>>         at
PL>>
LP>
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispat
LP> cher.java:284
PL>> )
PL>>         at
PL>> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
PL>>         at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
PL>>         at $Proxy224.start(Unknown Source)
PL>>         at org.jboss.ejb.EjbModule.startService(EjbModule.java:440)
PL>>         at
PL>>
org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:164)
PL>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
PL>>         at
PL>>
LP>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
LP> )
PL>>         at
PL>>
LP>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
LP> .java:25)
PL>>         at java.lang.reflect.Method.invoke(Method.java:324)
PL>>         at
PL>>
LP>
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispat
LP> cher.java:284
PL>> )
PL>>         at
PL>> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
PL>>         at
PL>>
LP>
org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.jav
LP> a:950)
PL>>         at $Proxy6.start(Unknown Source)
PL>>         at
PL>> org.jboss.system.ServiceController.start(ServiceController.java:384)
PL>>         at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
PL>>         at
PL>>
LP>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
LP> .java:25)
PL>>         at java.lang.reflect.Method.invoke(Method.java:324)
PL>>         at
PL>>
LP>
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispat
LP> cher.java:284
PL>> )
PL>>         at
PL>> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
PL>>         at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
PL>>         at $Proxy5.start(Unknown Source)
PL>>         at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:397)
PL>>         at
LP> org.jboss.deployment.MainDeployer.start(MainDeployer.java:786)
PL>>         at
LP> org.jboss.deployment.MainDeployer.start(MainDeployer.java:779)
PL>>         at
LP> org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:615)
PL>>         at
LP> org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:581)
PL>>         at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
PL>>         at
PL>>
LP>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
LP> .java:25)
PL>>         at java.lang.reflect.Method.invoke(Method.java:324)
PL>>         at
PL>>
LP>
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispat
LP> cher.java:284
PL>> )
PL>>         at
PL>> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
PL>>         at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
PL>>         at $Proxy4.deploy(Unknown Source)
PL>>         at
PL>>
LP>
org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanne
LP> r.java:412)
PL>>         at
PL>>
LP>
org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.
LP> java:530)
PL>>         at
PL>>
LP>
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(Ab
LP> stractDeploym
PL>> entScanner.java:202)
PL>>         at
PL>>
LP>
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(Abs
LP> tractDeployme
PL>> ntScanner.java:191)

PL>> With the <ejb-relationship-role> elements commented out of the
PL>> jbosscmp-jdbc.xml, it works fine. It generates a table called USER_ROLE
PL>> with these 2 columns: USERS and ROLES, which my dbas can't seam to
LP> handle.


PL>> Does anyone know how to solve this?

PL>> thanks.
PL>> ..peter




PL>> -------------------------------------------------------
PL>> This sf.net email is sponsored by: Dice - The leading online job board
PL>> for high-tech professionals. Search and apply for tech jobs today!
PL>> http://seeker.dice.com/seeker.epl?rel_code=31
PL>> _______________________________________________
PL>> JBoss-user mailing list
PL>> [EMAIL PROTECTED]
PL>> https://lists.sourceforge.net/lists/listinfo/jboss-user

-- 
Best regards,
 Alex Loubyansky




-------------------------------------------------------
This sf.net email is sponsored by: Dice - The leading online job board
for high-tech professionals. Search and apply for tech jobs today!
http://seeker.dice.com/seeker.epl?rel_code=31
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



This transmission contains information solely for intended recipient and may
be privileged, confidential and/or otherwise protect from disclosure.  If
you are not the intended recipient, please contact the sender and delete all
copies of this transmission.  This message and/or the materials contained
herein are not an offer to sell, or a solicitation of an offer to buy, any
securities or other instruments.  The information has been obtained or
derived from sources believed by us to be reliable, but we do not represent
that it is accurate or complete.  Any opinions or estimates contained in
this information constitute our judgment as of this date and are subject to
change without notice.  Any information you share with us will be used in
the operation of our business, and we do not request and do not want any
material, nonpublic information. Absent an express prior written agreement,
we are not agreeing to treat any information confidentially and will use any
and all information and reserve the right to publish or disclose any
information you share with us.


-------------------------------------------------------
This sf.net email is sponsored by: Dice - The leading online job board
for high-tech professionals. Search and apply for tech jobs today!
http://seeker.dice.com/seeker.epl?rel_code=31
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to