Skip to main content

Inheritance EQL

2 replies [Last post]
fafi
Offline
Joined: 2005-08-25

Hello!

I have basic inheritance:
Employee extends Person

How can I write EQL to obtain list of persons?

When I write:

SELECT res FROM Person res

the result is list of persons AND employees.
It is right in object design becouse Employee IS Person.

---
I tried:

1. to use AbstractPerson instead of Person
Person extends AbstractPerson
Employee extends AbstractPerson

It works but it is not nice ;-).

2. EQL like:
SELECT res FROM Person res LEFT JOIN Employee e ON res.id=e.id WHERE e IS NULL

It does not work - see spec. page 79

3. There exists discriminator column in DB (@DiscriminatorColumn).
Is there a way to obtain value of this column in EQL?

Something like this
"WHERE res.class = Person"
is missing in specification.

See:
http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html#que...

Thank you
Fafi

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mb124283
Offline
Joined: 2005-06-17

Hi,

as far as I know there is no way to restrict query polymorphism, unless there is a user defined field or property that allows checking the type.

Michael

fafi
Offline
Joined: 2005-08-25

Hi Michael,

thank you for your reply.

The field (that allows checking the type) has already exist in database.
I mean @DiscriminatorColumn.

But there is no way to otain the value of this column in EQL :-(.

Fafi