• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
Their achilles heel is the noogie! Give them noogies tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic