• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need help with CMR

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic