Two Laptop Bag*
The moose likes EJB and other Java EE Technologies and the fly likes need help with CMR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "need help with CMR" Watch "need help with CMR" New topic
Author

need help with CMR

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

I have two entity beans: PlayerBean and TeamBean.
the realtionship between these beans is : one to many (many players to one team).
I am using CMP 2.0 model and the relationship is bidirectional.
the fields of Team table in the database are :
teamname, teamcity
the fields of Player table in the database are:
pid, pname, psalary, pteam (pteam is a string and it serves as a FK).
in the PlayerLocal interface I wrote :
All the codes are inspired from Mastering EJB

in the PlayerBean I wrote:

using J2EE RI, I don't persist the pteam..
are there any things wrong with this design ?
if there is a better way to perform this realtionship please tell me.
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Hi John

using J2EE RI, I don't persist the pteam..

What error you are getting?
Here are my observations for your code,
1. In your first ejbCreate() I don't see setTeam(LocalTeam) call even though you pass the LocalTeam object in there
2. I have not called one ejbCreate() from another so far. I guess it would be better if you call create() from the second ejbCreate()...Though that should not be creating problem for you...
Please provide more input on your problem.
Regards
Maulin
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

1. In your first ejbCreate() I don't see setTeam(LocalTeam) call even though you pass the LocalTeam object in there

Mastering EJB don't do this.
if I called setTeamLocal from ejbCreate, then how the container will filed the pteam field value (in the database) ?
there is something I don't understand:
Player table has a pteam field(String)
in my PalyerBean I have a playerTeam field which is a relation field (the container will not persist it).
so when calling setPlayerTeam(TeamLocal) from the ejbCreate method, how the container will store a value in the database ??
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Hi John

so when calling setPlayerTeam(TeamLocal) from the ejbCreate method, how the container will store a value in the database ??

Exactly for that reason we have CMR It will know what to update in the table for Player when you do setPlayerTeam()...
Try it and see if it works for you.
Regards
Maulin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help with CMR
 
Similar Threads
Confused a little, alot
unable to access cmr field
Problem with accessing a CMR field, SOS
need help here
Need explaination