Discussion:
CMP, CMR, FK and Referential Integrity
(too old to reply)
Andre Serodio
2005-01-25 14:14:00 UTC
Permalink
Hi,
I need some help on understanding CMR and FK that do not accept nulls.
I have a composition in my model. It is also implemented in my database (Oracle 9i).
Whenever I try to call the create() method on the child entity I receive a SQL Exception telling that I cannot insert null values in my FK.
If I try to set the value of the FK "by hand" I receive the following..

javax.ejb.TransactionRolledbackLocalException: EJB Exception:; nested exception is: javax.ejb.EJBException: [EJB:010145]When a cmp-field and a cmr-field (relationship) are mapped to the same column, the setXXX method for the cmp-field may not be called. The cmp-field is read-only.

What should I do?
Thank you in advance...
André
bill kemp
2005-01-25 22:34:20 UTC
Permalink
You shouldn't have a cmp-field and a cmr-field mapped to the same column.
I'm pretty sure the spec prohibits that. In this case it appears that you
are attempting to have a foreign key setter in the parent be able to change
the primary key of the child. Setters for primary keys cannot exist, even if
it is the setter of the FK in the parent relation that maps to the PK in the
child.

Bill
Post by Andre Serodio
Hi,
I need some help on understanding CMR and FK that do not accept nulls.
I have a composition in my model. It is also implemented in my database (Oracle 9i).
Whenever I try to call the create() method on the child entity I receive a
SQL Exception telling that I cannot insert null values in my FK.
Post by Andre Serodio
If I try to set the value of the FK "by hand" I receive the following..
javax.ejb.TransactionRolledbackLocalException: EJB Exception:; nested
exception is: javax.ejb.EJBException: [EJB:010145]When a cmp-field and a
cmr-field (relationship) are mapped to the same column, the setXXX method
for the cmp-field may not be called. The cmp-field is read-only.
Post by Andre Serodio
What should I do?
Thank you in advance...
André
Loading...