This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes unable to access cmr field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "unable to access cmr field" Watch "unable to access cmr field" New topic
Author

unable to access cmr field

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Hi all.
I have the following cmp entity beans: TeamBean and PlayerBean
the relationship is 1 : * (one team, many players) bidirectional.
the TeamBean has to CMR field: getPlayers( ) and setPlayers(Collection)
and I have a session bean LeagueBean (session facade) and this bean has
the following method :

but when calling findPlayersWithinTeam method, nothing displayed at all,
and there is no exception.
so I think maybe because getPlayers is CMR field so I can't use it outside.
so I created the following method in TeamBean:

and the EJBQL for ejbSelectPlayers method is :
SELECT OBJECT(P) FROM TeamBean AS T, in (T.players) AS P WHERE T = ?1
and calling findPlayersWithinTeam method, nothing displayed and no exception !!
WHY ???
How can I get the players for a specific team ??
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Help PLEASE ...............
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Everything looks good to me. Can you successfully add and retrieve regular items from your CMR collection? Your EJB-QL looks fine to me. Have you done any testing, or were you expecting somebody (me?) to just jump in here and fix it all for you?


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
John, I finally got my RI fixed and just like I said offline, you are responsible for implementation of all of your "set" methods, and it looks like the only ones you did were the cmp fields. Nobody in the universe is calling "setPlayerTeam(TeamLocal team)", nor is anyone calling "setPlayers(Collection col)". See where TeamBean has two sets called in the ejbCreate, but three virtual get/set pairs? Same in PlayerBean. Four set methods called, but five get/set pairs. The missing ones, of course, are the cmR fields, and as you pointed out, you do that in the ejbPostCreate (ejbCreate is too soon because you have to wait until after the data has been inserted). So in each of your post creates, you would lookup the other guy's home, call a method on the home with whatever key you have in your parameter list, and you get back whatever the input parameter for your set method would be.
The application works as long as you have capslock "on" for your keys. I'm not sure what's going on there, but I don't think it matters.
--Dale--
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: unable to access cmr field
 
Similar Threads
Confused a little, alot
Problem with accessing a CMR field, SOS
need help with CMR
Need explaination
Odd exception