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 and other Java EE Technologies and the fly likes 2 questions about EJB-QL 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 » Java » EJB and other Java EE Technologies
Bookmark "2 questions about EJB-QL" Watch "2 questions about EJB-QL" New topic
Author

2 questions about EJB-QL

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Hi, all. I am confusing the EJB-QL.
1. Function is:
public abstract Collection ejbSelectAllMovies() throws FinderException
QL is:
select OBJECT(m) FROM MovieSchema m WHERE m.genre = ?1
actually, in the method, there is NO any parameter, which one is parameter 1 ?
//-----------
2.
QL is
SELECT DISTINCT OBJECT (m) FROM MovieSchema m
Actually what I am confusing is "DINSTINCT". MovieSchema, a database with primary key, is IMPOSSIBLE to contain a same data in a row because of different primary key value.
so, it is resonable to change to this
SELECT DISTINCT m.title FROM MovieSchema m
if the m.title is not primary key.
Am I right?
//-------
Thanks.
Edward
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
in the method, there is NO any parameter, which one is parameter 1 ?

There has to be a method parameter... In other words, either add a method parameter or hardcode the value of "genre" into the EJB-QL.
[ January 02, 2004: Message edited by: Lasse Koskela ]

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
2.
QL is
SELECT DISTINCT OBJECT (m) FROM MovieSchema m
Actually what I am confusing is "DINSTINCT". MovieSchema, a database with primary key, is IMPOSSIBLE to contain a same data in a row because of different primary key value.
so, it is resonable to change to this
SELECT DISTINCT m.title FROM MovieSchema m
if the m.title is not primary key.
Am I right?

The two EJB-QLs you posted return a different thing (a Movie object versus a String, most likely) so it's really difficult to say whether the change is reasonable or not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2 questions about EJB-QL
 
Similar Threads
Why DISTINCT with OBJECT in QL?
regarding EJB QL
Chapter 7 - HF study group
Q. EJB-QL SELECT - when to use Object()
EJB spec conflicts - CMR field return types