Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Get specific entries from a Table using the "InheritanceType.SINGLE_TABLE-strategy" by using the DiscriminatorValue

JPQL provides a TYPE operator.

Here is an example from the spec:

SELECT e
FROM Employee e
WHERE TYPE(e) IN (Exempt, Contractor)


On 11/01/2012 8:56 AM, Rick van Son wrote:
Hello everyone,

I've a class Person and a class Employee.
Employee is extended from the class Person.
Person has its own Table, using "InheritanceType.SINGLE_TABLE" as Inheritance
strategy.
Employee entries are thus also stored in the table of Person.

However, I couldn't find the magic SELECT query for EclipseLink to get only the
Employee-entries from the table Person.

PostgreSQL finds "SELECT person.* FROM Person person WHERE person.dtype =
'Employee';" very delicious and gives me the right results. But EclipseLink is
less nice and doesn't want to see the DiscriminatorColumn "dtype" when I do
"List<Employee> employees = (List<Employee>) em.createQuery("SELECT
OBJECT(Employee) FROM Person person WHERE person.dtype =
'Employee';").getResultList();".

Trying to cast 'Employee' to CHARACTER VARYING(31) in various ways didn't also work.

Does anyone have a suggestion to solve this?

Thanks in advance,

Rick


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top