-
1. Re: java.lang.ClassCastException
sesques May 17, 2004 2:37 PM (in response to nacho2004)Hi,
Post your code and jbosscmp-jdbc.xml.
Also the full error log.
Pascal -
2. Re: java.lang.ClassCastException
nacho2004 May 17, 2004 2:42 PM (in response to nacho2004)
<ejb-relation>
<ejb-relation-name>EDocuments-EDocMetaData</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>
<ejb-relationship-role-name>EDocuments-has-one-EDocMetadata</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>EDocMetadata-has-one-EDocuments</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>docid</field-name>
<column-name>docid</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
</ejb-relation> -
3. Re: java.lang.ClassCastException
sesques May 17, 2004 3:12 PM (in response to nacho2004)Hi,
Your relation defined as a one-one looks like a one-many.
The ClassCastException can occur if the result is a collection, not a single row.
Try to define your relation as a one-many, with a collection as return type of the getter.
Pascal -
4. Re: java.lang.ClassCastException
nacho2004 May 17, 2004 3:35 PM (in response to nacho2004)do you have any document to implement a one-to-one relationships
I think the @ejb.relation is good in both case (2 beans) but I can't understand why I can't call one bean to other by getDocidMetaData() method.
thanks in advance -
5. Re: java.lang.ClassCastException
sesques May 17, 2004 3:55 PM (in response to nacho2004)Your relation is a good one.
I tell you the problem can occurs if the result of the query (managed by the container for the relationship) is a multi-row instead of a single row.
Do you have potentially many EDocMetaData for one EDocuments ?
In this case, your relation MUST BE a one-many.
With the informations you give, this is the only problem I think about.
I ask you to post your code and the whole descriptors, not only a snippet.
But you cannot set a one-one relationship if it is a many-one in reality.
Seems more clear ?
Pascal -
6. Re: java.lang.ClassCastException
nacho2004 May 17, 2004 4:02 PM (in response to nacho2004)But in my case both tables contain the same amount of row
And the data model for those tables is one-to-one relationships -
7. Re: java.lang.ClassCastException
john_anderson_ii May 19, 2004 5:37 PM (in response to nacho2004)I don't know very much about CMR, I'm learning that now. But I think the ClassCastException could possibly come from these lines:
Collection col = myBean.getAllDocumentByCategoryId(11);
-----SNIP ------------
EDocuments element = ((EDocuments) iter.next());
Unless you can guaruntee that every item in the collection returned by getAllDocumentsByCategoryId is of type Edocuments, or can be cast to type Edocuments.