• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

My last piece of CMR puzzle  RSS feed

 
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.
 
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?
 
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
 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!