• 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

My last piece of CMR puzzle

 
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
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
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
Please, someone come to help.
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
grapes are vegan food pellets. Eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic