Re: [hibernate-dev] [ORM] Query with condition on subclass attribute

2020-07-01 Thread Gail Badner
I don't see it documented in the user guide. Is it safe to assume that this
functionality won't be going away?

On Wed, Jul 1, 2020 at 5:11 PM Steve Ebersole  wrote:

> It is not portable.  Hibernate applies an implicit treat-as operation in
> such cases.  This is actually Hibernate's behavior from the beginning.  JPA
> says this should use an explicit treat-as operation.
>
> On Wed, Jul 1, 2020, 4:58 PM Gail Badner  wrote:
>
>> Hi,
>>
>> Given the following inheritance hierarchy:
>>
>> @Entity
>> public class Person {
>> @Id
>> private int id;
>> ...
>> }
>>
>> @Entity
>> public class Employee extends Person {
>> private String title;
>> }
>>
>> Executing a query like the following succeeds.
>>
>> "from Person where title = 'abc'"
>>
>> I thought that it would fail because Person does not have an attribute
>> named "title". Instead, the query succeeds and returns the Employee with
>> the specified title.
>>
>> I don't see anything in the JPA spec that indicates whether this is
>> portable.
>>
>> Does anyone know if this is portable?
>>
>> Thanks,
>> Gail
>> ___
>> hibernate-dev mailing list
>> hibernate-dev@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>
>>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] [ORM] Query with condition on subclass attribute

2020-07-01 Thread Steve Ebersole
It is not portable.  Hibernate applies an implicit treat-as operation in
such cases.  This is actually Hibernate's behavior from the beginning.  JPA
says this should use an explicit treat-as operation.

On Wed, Jul 1, 2020, 4:58 PM Gail Badner  wrote:

> Hi,
>
> Given the following inheritance hierarchy:
>
> @Entity
> public class Person {
> @Id
> private int id;
> ...
> }
>
> @Entity
> public class Employee extends Person {
> private String title;
> }
>
> Executing a query like the following succeeds.
>
> "from Person where title = 'abc'"
>
> I thought that it would fail because Person does not have an attribute
> named "title". Instead, the query succeeds and returns the Employee with
> the specified title.
>
> I don't see anything in the JPA spec that indicates whether this is
> portable.
>
> Does anyone know if this is portable?
>
> Thanks,
> Gail
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


[hibernate-dev] [ORM] Query with condition on subclass attribute

2020-07-01 Thread Gail Badner
Hi,

Given the following inheritance hierarchy:

@Entity
public class Person {
@Id
private int id;
...
}

@Entity
public class Employee extends Person {
private String title;
}

Executing a query like the following succeeds.

"from Person where title = 'abc'"

I thought that it would fail because Person does not have an attribute
named "title". Instead, the query succeeds and returns the Employee with
the specified title.

I don't see anything in the JPA spec that indicates whether this is
portable.

Does anyone know if this is portable?

Thanks,
Gail
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev