This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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.
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
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: 1865
posted
0
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