• Post Reply Bookmark Topic Watch Topic
  • New Topic

My last piece of CMR puzzle

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey ranchers.
I have some questions about CMP & CMR.
assume we have the following 2 CMP beans.
TeamBean contains the following fields : name and city
and its database schema is : NAME , CITY
PlayerBean contains id, mail
and its database schema is : ID, EMAIL, FK_NAME
as you note FK_NAME is a FK to Team schema.
now, if I called :
player.setTeam(team);
the container will manage the relationship and INSERT a value at FK_NAME column, right ?
I just want to know this please.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, someone come to help.
 
Olexiy Prokhorenko
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be it's just quite hard to understand what exactly are you asking. :-)

Can you clarify a bit?
Let's talk virtually not about "beans", but about "tables".
What will be one table, what will be another? What is the relationship between? On which field?
 
Sebastian Hennebrueder
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,

you will have to create the FK entry before. But then you can set the relation with your setTeam method.

If you want a team be created when inserting a player, you may check if the team exist in the ejbcreate method of the player bean. If not create it and then you can set it.

Regards Sebastian
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Todd:
player.setTeam(team);
the container will manage the relationship and INSERT a value at FK_NAME column, right ?

If you are asking if the container will set the FK_NAME column on the new PLAYER row, the answer is yes. This is precisely what CMR is designed to do: manage your relationships' foreign keys. It also provides navigatability in your finders and beans themselves.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!