• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF confusion page 403

 
Keith Rosenfield
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
On page 403 of HF it shows the method signature
public abstract Collection ejbSelectGetAllMovies() throws finderException;
followed by the EJB-QL query
SELECT OBJECT(m) FROM MovieSchema m WHERE m.genre = ?1
It seems to me that this Select query is not the correct one for the above method. For 2 reasons
1) The name of the method implies that all movies should be returned, not just ones in a certain genre
2) There is no genre parameter to the method.
This confusion is compounded by the quote on the bottom of the page that says
Give me all the Movie beans that are in the genre matching the first parameter to the ejbSelectGetAllMovies method

As I just stated, there are no parameters to that method.
I seems to me that the appropriate method for this query is the findByGenre(String genre) method.
Is this truly an error or am I reading it wrong?
Thanks
[ January 27, 2004: Message edited by: Keith Rosenfield ]
[ January 27, 2004: Message edited by: Keith Rosenfield ]
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Rosenfield:
Hi all,
On page 403 of HF it shows the method signature
public abstract Collection ejbSelectGetAllMovies() throws finderException;
followed by the EJB-QL query
SELECT OBJECT(m) FROM MovieSchema m WHERE m.genre = ?1
I seems to me that the appropriate method for this query is the findByGenre(String genre) method.
Is this truly an error or am I reading it wrong?

No, you've got it right. Thee method for the bean class is my cut-n-paste error (it's the method from the previous page.). YOUR method is correct for the home interface.
Good spot!
-Kathy
[ January 27, 2004: Message edited by: Kathy Sierra ]
 
Keith Rosenfield
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kathy,
Still confused. Are find methods supposed to be declared in the bean class. I thought that you only declare them in the home interface and let the container implement them?

Thanx.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just trying to make it as confusing as possible for you Keith. Builds character. Gets you ready for the Real Test
No, you're right -- you wouldn't put that in the bean class since we're obviously talking CMP!
I just changed it.
cheers,
kathy
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Keith,
I seems to me that the appropriate method for this query is the findByGenre(String genre) method.

Who is now confusing here ?
Some ejbSelectGetAllMoviesByGenre(String genre) would have been perfect IMO.
Best regards,
Phil.
[ January 27, 2004: Message edited by: Philippe Maquet ]
 
Prasad Kuppa
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Phil is right. All this can be corrected by changing the abstract method signature like :
public abstract Collection ejbSelectGetAllMovies(String pGenre) throws FinderException ;
-Prasad
[ January 27, 2004: Message edited by: Prasad Kuppa ]
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, sure, you could do it the EASY way
ejbSelectGetAllMoviesByGenre(String genre) would have been perfect IMO
I'm not writing anything else until I've had more sleep...
cheers,
Kathy
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I stumbled over HFEJB p. 403 I came across this wonderful thread with comments from Kathy Sierra and the wonderful Philippe Maquet (may his soul be happy in heaven).

Regards,
Darya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic