This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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 ??
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?
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--