ya ! There lies the problem.
You are not suppossed to map the FKs in the table to some of the cmps in the
CMP-Entity bean(which is importing the FKs). The referential integrity will
be taken care by the container itself. All you need to do is set appropriate
relationships and map only non-FK fields using the Vendor Provided tools for
APS(abstract Persistence schema)-DB. The container will take care of the
refrential integrity. If you want to change the FK then use that entity
which has been mapped to the table from where this FK has been imported,
this should change all the FKs of various tables appropriately. Depends on
how you map, the design of DB and MiddleTier components' structure.
  Hope this helps.

Regards,
kris


-----Original Message-----
From: Alvin Wang [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 8:44 PM
To: [EMAIL PROTECTED]
Subject: Re: An CMR related exception


Daniel, I feel that my problem is not initializing a PK, but any field that
is mapped to a CMR. Again, the exception is as below:
"javax.ejb.EJBException: 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."

Yeah, the XXX happens to be a foreign key in my case


-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Daniel De Luca
Sent: Monday, March 11, 2002 9:52 AM
To: [EMAIL PROTECTED]
Subject: Re: An CMR related exception


Alvin

Yes entityA is an existing instance which has a PK.
It won't be possible for you to use your PK in a relationship between
entities.
If your instanceA PK and instanceB PK are used for the relationship
between each other, you need to change the PK of the corresponding
entities to make them relationship independent. This mean, create a new
CMP field in both entities that will be used as PK. Then use the old PKs
as "normal" fields (non used as PK) in order to be able to used them as
CMR and without being forced to initialize them in the ejbCreate method.

If this is not giving you a solution to your problem, could you send the
code of your entities (puttin in comment which are the field that are
used in your relationship and which one are PKs).

Hope this help

Daniel

-----Original Message-----
From: Alvin Wang [mailto:[EMAIL PROTECTED]]
Sent: lundi 11 mars 2002 15:44
To: Daniel De Luca; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: An CMR related exception


Daniel, I read the section you pointed out. I did not find either how it
is related to my problem and how your solution solves my problem.

in "entityBRef.getREntityA().add(entityARef)", is entityARef an existing
Bean A instance initialized with PK? Then when/how did that XXX field
INITIALIZED?

I'm a little slow. Please give me details. Thanks!



-----Original Message-----
From: Daniel De Luca [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 4:08 AM
To: [EMAIL PROTECTED]
Subject: RE: An CMR related exception


Alvin,

Yes that's right.
Why? Well that's how the specs are defined and how the App Server
container have to do things. Check the EJB 2.0 specs for more details:
10.3.8 Collections managed by the Container, 10.3.6 Semantics of
assignment for relationships

Daniel

-----Original Message-----
From: Alvin Wang [mailto:[EMAIL PROTECTED]]
Sent: samedi 9 mars 2002 2:23
To: Daniel De Luca; [EMAIL PROTECTED]
Subject: RE: An CMR related exception


Deniel, thanks for replying. Do you mean
"entityBRef.getREntityA().add(entityARef)" will initialize that field?
Why? Or when and how that field will be initialized in later time?
Please give more details!

Thanks!


-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Daniel De Luca
Sent: Friday, March 08, 2002 11:58 AM
To: [EMAIL PROTECTED]
Subject: Re: An CMR related exception


Alvin,

You can't apply a Set method on a cmp-field that is used in a
relationship between 2 entities. You don't necessarily need to
initialize that field in the ejbCreate method. What you have to do is
create the Entity bean and initialize only the PK.

Then suppose EntityA has a relation with EntityB and the CMR fields are
rEntityB (in EntityA) and rEntityA (in  EntityB) In order to "set" the
relationship between the 2 you need to use the
entityBRef.getREntityA().add(entityARef).
After that your CMP-field will be up to date.


I would suggest you to read the EJB 2.0 Spec, everything is explained
there.

Hope this help.

Daniel

-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]] On Behalf Of Alvin Wang
Sent: vendredi 8 mars 2002 16:12
To: [EMAIL PROTECTED]
Subject: An CMR related exception


Hi! I am using Weblogic 6.1 SP2 and EJB 2.0. I built a CMR between two
Entity Beans. However, I got the following exception while running:

"javax.ejb.EJBException: 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."

However, in the ejbCreate() method in CMP in EJB 2.0, I have to use
setXXX method to initialize the XXX cmp-field. Am I wrong?

Can any guru help? thanks!

========================================================================
===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body of the message "signoff EJB-INTEREST".  For general help, send
email to [EMAIL PROTECTED] and include in the body of the message
"help".

========================================================================
===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body of the message "signoff EJB-INTEREST".  For general help, send
email to [EMAIL PROTECTED] and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to