Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ejb-ql  RSS feed

 
alan kent
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does somebody now how can I find an example of a ejb-ql using 2 or more tables?

If I have a query like this in SQL:
Select
teacher.name,
student.name
from
teacher,
student
where
teacher.id = student.id_teacher
and student.id = 1

How can I do using ejb-ql ??
I have 2 tables
teacher with the fields 'id' and 'name'
student with the fields 'id', 'name' and 'id_teacher'

thanks,
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, EJB-QL is done according to the schema of your DD, not the table(s) that your beans are stored in. You should download the EJB specification. It gives you the entire EJB-QL EBNF so you can see how to put together your queries.

Simply put, it allows you to do selects from multiple beans much like you would given multiple tables in SQL.

SELECT OBJECT(a) FROM Bean1 AS a, Bean2 AS b WHERE a.thing = b.thing AND a.thing = ?1

... or something very similar. I always mess up my commas.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!