• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XDoclet, JBossQL and EJB QL: Joining multiple tables (2+) possible?

 
Karl Beowulph
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy.

I'm trying to figure out how I can join multiple tables together in EJB QL using XDoclet.

Suppose for the moment I have three tables. School, Car and Person.

In my PersonEntityBean I've got the following method:



But that simply gets me all the schools that that any particular person belongs to.

What I want is a way to retrieve all the people who are in a certain school and drive a particular car.

The SQL would be (approximately)



Note that School and Car have no relation to each other at all, asides from simply sharing the non-key personID field.

Is what I'm trying to do possible with CMP EJB QL or JBossQL?
 
Karthik Guru
Ranch Hand
Posts: 1209
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have the following relationships defined

schools.persons //school 1 -> (many) person
person.cars // person 1 -> (many) car

then you should be able to define this method in the SchoolBean




Please check
@ejb-finder tag to embed this query.
 
Arlet Contreras
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, The answer is very good from my point of view, it helped me a lot, thank you.
And what do you put inside the tag * @jboss:table-name table-name="table" ?
And which are the methods that the CMP includes (get and set)? which table they belong?

cheers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic