• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

2 questions about EJB-QL

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Evil is afoot. But this tiny ad is just an ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic