File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "unable to access cmr field" Watch "unable to access cmr field" New topic

unable to access cmr field

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

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

Joined: Nov 08, 2003
Posts: 3479

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?

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.
I agree. Here's the link:
subject: unable to access cmr field
jQuery in Action, 3rd edition