• 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

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

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic