duplicate columns created - revisited
dward2 Mar 25, 2002 2:08 PMI'm having a problem where JBossCMP is creating (somehow successfully in Hypersonic DB!) duplicate column names. This is using JBoss 3.0.0beta2 from CVS (pulled down late last week) on a Red Hat 7.1 Linux, kernel 2.4.9-31,i686 box using Sun JDK 1.3.1_02.
I have a bidirectional one-2-many relationship between Groups and Images.
My jbosscmp-jdbc.xml has this so I can specify my own column names:
<enterprise-beans>
<ejb-name>Group</ejb-name>
<table-name>GROUPS</table-name>
<cmp-field>
<field-name>groupKey</field-name>
<column-name>GRP_KEY</column-name>
</cmp-field>
<cmp-field>
<field-name>ownerKey</field-name>
<column-name>OWN_KEY</column-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>NAME</column-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<column-name>DESCRIP</column-name>
</cmp-field>
<ejb-name>Image</ejb-name>
<table-name>IMAGES</table-name>
<cmp-field>
<field-name>imageKey</field-name>
<column-name>IMG_KEY</column-name>
</cmp-field>
<cmp-field>
<field-name>groupKey</field-name>
<column-name>GRP_KEY</column-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>NAME</column-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<column-name>DESCRIP</column-name>
</cmp-field>
</enterprise-beans>
<ejb-relation>
<ejb-relation-name>Group-Image</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>
<ejb-relationship-role-name>Group-Has-Images</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>groupKey</field-name>
<column-name>GRP_KEY</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Image-Has-Group</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
</ejb-relation>
What I end up with is an IMAGES table with two columns called GRP_KEY!!! (I didn't think a DB would allow this ?!?!) This is the debug in the server.log:
2002-03-25 13:24:23,535 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.Image] Executing SQL: CREATE TABLE IMAGES (IMG_KEY INTEGER NOT NULL, GRP_KEY INTEGER, NAME VARCHAR(256), DESCRIP VARCHAR(256), GRP_KEY INTEGER, CONSTRAINT pk_IMAGES PRIMARY KEY (IMG_KEY))
$$ I bought the JBossCMP documentation from Flashline and noticed:
1) It uses the Alpha dtd for jbosscmp-jdbc.xml, using the old foreign-key-fields and ejb-relationship-role inside a foreign-key-mapping. Also the foreign-key-field entity placement is reversed, again a change from alpha to beta.
2) The classic Order-LineItem relationship (which is the bidirectional one-2-many I'm emulating in my problem) is different from mine in that it doesn't define the LineItemEJB entity mapping in the jbosscmp-jdbc.xml file - but I want to define my own column names.
By looking at the SQL CREATE statement, my gut feeling is that this is a bug, but I'm not sure.
Thanks for any and all help,
David
PS: As a side question, why can't I / don't I have to specify the key-field for imageKey in the Image-Has-Group relationship?