This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB query language  RSS feed

 
Gerald Holl
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I read some examples concerning EJB QL but they didn't satisfy me.

Consider the following example:
two tables:
DVD and Users
DVD PK is an id, Users PK is the username.

The mapping table between DVD and Users had been created by using the @ManyToMany annotation.

Now I want to search all the DVDs of user "jimbo".

Ok, let's try it:


It doesn't work, I get an exception that the SQL grammar isn't correct.
I also tried some other queries but they result in the same error.

I have no idea what's wrong. Help appreciated.
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gerald,

You are trying to use non-standard syntax.

Change it to:

SELECT DISTINCT d
FROM DVD AS d JOIN d.users AS u
WHERE u.userName = :uname

-Mike
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!