How do I get a class "Many" in a Relationship?
rafonso Dec 4, 2002 3:23 PMHi,
I have a bean called Country, whose primary key is called countryId and it is a BigDecimal. I have another bean called CountryStates that has a attribute called countryId that is obviously related with Country bean. In my JBuilder 7 I created a Relationship from Country to CountryStates. Thus there is a collection in Country that I called countryStates.
In ejb-jar.xml, this relationship is showed like above:
<ejb-relation>
<ejb-relation-name>country-countryState</ejb-relation-name>
<ejb-relationship-role>
country
<ejb-relationship-role-name>CountryRelationshipRole</ejb-relationship-role-name>
One
<relationship-role-source>
country
<ejb-name>Country</ejb-name>
</relationship-role-source>
<cmr-field>
countryState
<cmr-field-name>countryStates</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
countryState
<ejb-relationship-role-name>CountryStateRelationshipRole</ejb-relationship-role-name>
Many
<relationship-role-source>
countryState
<ejb-name>CountryState</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
And in jbosscmp-jdbc.xml, this relationship is showed like above:
<ejb-relation>
<ejb-relation-name>country-countryState</ejb-relation-name>
<foreign-key-mapping />
<ejb-relationship-role>
<ejb-relationship-role-name>CountryRelationshipRole</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>countryId</field-name>
<column-name>country_id</column-name>
</key-field>
</key-fields>
<ejb-designer-id>Country</ejb-designer-id>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>CountryStateRelationshipRole</ejb-relationship-role-name>
</ejb-relationship-role>
</ejb-relation>
Well, the Collection countryStates in Country can't has a remote interface (Why? I don't understand this). So to have access to this collection I created a method with remote interface that returns countryStates. When I runned a Client Test, I get this message error: java.lang.reflect.UndeclaredThrowableException: java.io.NotSerializableException: org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet
.
So how can I correct this? Better: How Can I have access to countryStates Collection?
Thanks,
Rafael U. C. Afonso