[
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
|
There is more going wrong here than just a problem with the query. The
exception states it is coming from an preUpdate event, probably because
you have validation configured somehow, and are making updates that are
not conforming. Your query mode might be causing a flush to occur
before the query can execute, so you might want to call em.clear before
the query to clear out any corrupted entities that could be causing this
exception.
If this isn't the case, please give the exception stack trace.
Best Regards,
Chris
On 13/01/2012 11:23 AM, Rick van Son wrote:
Thanks for your reply.
I've tried those solutions, however every time I get a this useless
exception which even ignores try-catch( Exception ex ):
"javax.validation.ConstraintViolationException: Bean Validation
constraint(s) violated while executing Automatic Bean Validation on
callback event:'preUpdate'. Please refer to embedded
ConstraintViolations for details."
After debugging, It seems that I'm supposed to get a Employee object,
however, the variable properties which the Employee class inherits from
Person are kept null and don't get filled.
Why does this happen?
Best Regards,
Rick
---------
2012/1/11 Christopher Delahunt <christopher.delahunt@xxxxxxxxxx
<mailto:christopher.delahunt@xxxxxxxxxx>>
Tom is correct, but in your example you would want either:
"Select p from Person p where TYPE(p) = Employee"
Or you can just select the Employee subclass:
"Select e from Employee e"
Both queries will return Employees, but the second will also return
Employee subclasses if there are any.
JPQL is object based and dtype is not an attribute in the java
object, which is why it cannot be used within the query.
Best Regards,
Chris
On 11/01/2012 9:03 AM, Tom Ware wrote:
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
<mailto:eclipselink-users@xxxxxxxxxxx>
https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users
<https://dev.eclipse.org/mailman/listinfo/eclipselink-users>
_________________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>
https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users
<https://dev.eclipse.org/mailman/listinfo/eclipselink-users>
_________________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>
https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users
<https://dev.eclipse.org/mailman/listinfo/eclipselink-users>
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users