Hi,

I'm working on what is supposed to be a simple demonstration of J2EE. As such, i've come up with a two beans that have a relationship: a person bean and a title bean (titles like Dr. Mrs. Miss. Mr.). Each title has an integer titleId as its primary key, and the person table has a foreign key titleId column. Bean clients should be able to get the title bean from the person, but a title bean shouldn't know anything about people.

Here's the code I'm using:

/**
* This returns the title for this person. It is based on the
*
relationship between MrPerson and MrTitles.
*
* @ejb.interface-method view-type="local"
*
* @ejb.relation name="Person-Title"
* role-name="person-has-title"
* cascade-delete="no"
* target-ejb="MrTitlesBean"
* target-role-name="title-of-person"
* target-cascade-delete="no"
*
* @jboss.relation related-pk-field="titleId"
* fk-column="titleId"
* fk-constraint="true"
*/

public abstract MrTitles getTitle();
/**
* This returns the title for this person. It is based on the
*
relationship between MrPerson and MrTitles.
*
* @ejb.interface-method view-type="local"
*/

public abstract void setTitle( MrTitles newTitle );

When I try to run cactus tests (I'm using maven as the build manager), I get the following exception in JBoss:

org.jboss.deployment.DeploymentException: Both roles of a relation-table mapped relationship must have key fields: ejb-relation-name=Person-Title

So JBoss is not aware I'm trying to use foreign key mapping here. Looking at the generated files, I have:

------------------------------ ejb-jar.xml ------------------------------
<!-- Relationships -->
<relationships >
<ejb-relation >

</ejb-relation-name>

<ejb-relationship-role >

</ejb-relationship-role-name>

</multiplicity>

<relationship-role-source >

</ejb-name>

</relationship-role-source>
<cmr-field >

</cmr-field-name>
</cmr-field>
</ejb-relationship-role>

<ejb-relationship-role >

</ejb-relationship-role-name>

</multiplicity>

<relationship-role-source >

</ejb-name>

</relationship-role-source>
</ejb-relationship-role>

</ejb-relation>

------------------------------ jbosscmp-jdbc.xml ------------------------------
<ejb-relation>

</ejb-relation-name>

<ejb-relationship-role>

</ejb-relationship-role-name>

</fk-constraint>
<key-fields/>

</ejb-relationship-role>
<ejb-relationship-role>

</ejb-relationship-role-name>
<key-fields>
<key-field>

</field-name>

</column-name>
</key-field>
</key-fields>

</ejb-relationship-role>
</ejb-relation>


Reading the JBoss documentation, it seems there's supposed to be a tag "< foreign-key-mapping />" in the jbosscmp-jdbc.xml, but for some reason, XDoclet isn't putting it there. What tag am I missing here? Or am I using one/more of the tags incorrectly?

Thanks!

Mark

Reply via email to