Hello Jonathan,
Tuesday, December 31, 2002, 4:01:53 PM, you wrote:
JOCxd> Alex,
JOCxd> Let me repeat what I think happens during entity bean creation:
JOCxd> In ejbCreate we set all primary key fields.
JOCxd> In ejbPostCreate we can set up any CMR fields.
Yes
JOCxd> Any CMR fields set in ejbCreate are ignored, and must be set again in
JOCxd> ejbPostCreate.
No. If you try to establish relationships in ejbCreate, an exception
will be thrown indicating that it's not allowed. Relationships are
setup only in ejbPostCreate as the spec says.
JOCxd> Now if we have a table, T1, with PK = {pkCol1, pkCol2}, and pkCol1 acts
JOCxd> as a foreign key to another table, T2, then our entity bean will have a
JOCxd> problem, because the field mapped to pkCol1 will also be marked as a CMR
JOCxd> field, and so it will be blanked out at the end of ejbCreate (actually
JOCxd> throws the IllegalStateException seen below).
No. Both pkCol1 and pkCol2 will be setup correctly (won't be null) in
ejbCreate. And in ejbPostCreate you'll have relationships _already_
established if there is an entity with pk in T2 equal to the pkCol1 of
the created entity in T1.
JOCxd> So, can we instead only nullify CMR fields that are not mapped to primary
JOCxd> key fields.
It works this way.
JOCxd> This should work fine if T1-T2 is many to one or one to one
JOCxd> relationship. Many to many is not a problem in this case because we are
JOCxd> using foreign key constraints and not a mapping table to implement the
JOCxd> relationship.
JOCxd> So, in Frank's example, he sets up the two parts of the primary key in
JOCxd> ejbCreate, and does nothing in ejbPostCreate. He can use his CMR getter no
JOCxd> problem. Of course, the CMR setter would throw an exception as you can't
JOCxd> change the primary key.
Exactly.
alex
JOCxd> Have I missed anything?
JOCxd> Happy New Year,
JOCxd> Jonathan
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user