Kristoffer Moe
2002-10-02 12:19:41 UTC
This problem may or may not have anything to do with middlegen, but is in
any case as follows:
Three tables A, B, C have bi-directional 1:n relationship between A and B,
ditto between B and C. Tables A and C have single attribute PKs, but B has
compound PK, composed of foreign keys to A and C tables' PK's. In effect,
this is a m:n relationship between A and C, with som additional information
(ie a description) attached to table B.
Result is that entity bean for B gets FK/PK fields acting both as CMR and
CMP fields. Rules are approx. as follows: 1) a CMR field is read-only in
ejbCreate(...), but may be set in ejbPostCreate(...), which is what
middlegen-generated code does 2) PK fields must be set by ejbCreate(...),
otherwise weblogic refuses to create bean. Since the setXXX methods in this
case are the same for PK fields and CMR fields, an attempt to call CMP
setXX in ejbCreate is denied, since it is assumed to be a CMR set, which is
not allowed. Also, since the table has no id attribute by itself which can
be auto-counted or whatever, there is only possible to create an instance
by supplying already extisting A and B beans. In other words, it is not
possible to first create a B and then attach an A and C afterwards.
Any ideas?
Regards,
Kristoffer Moe
Senior Consultant
Elan It ReSource
any case as follows:
Three tables A, B, C have bi-directional 1:n relationship between A and B,
ditto between B and C. Tables A and C have single attribute PKs, but B has
compound PK, composed of foreign keys to A and C tables' PK's. In effect,
this is a m:n relationship between A and C, with som additional information
(ie a description) attached to table B.
Result is that entity bean for B gets FK/PK fields acting both as CMR and
CMP fields. Rules are approx. as follows: 1) a CMR field is read-only in
ejbCreate(...), but may be set in ejbPostCreate(...), which is what
middlegen-generated code does 2) PK fields must be set by ejbCreate(...),
otherwise weblogic refuses to create bean. Since the setXXX methods in this
case are the same for PK fields and CMR fields, an attempt to call CMP
setXX in ejbCreate is denied, since it is assumed to be a CMR set, which is
not allowed. Also, since the table has no id attribute by itself which can
be auto-counted or whatever, there is only possible to create an instance
by supplying already extisting A and B beans. In other words, it is not
possible to first create a B and then attach an A and C afterwards.
Any ideas?
Regards,
Kristoffer Moe
Senior Consultant
Elan It ReSource