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

Gail Badner <[email protected]>
Newsgroups gmane.comp.java.hibernate.devel
Message-ID <CAFDzhiS8t9YXqBb_6Zp14Nx4mg+qeQJ5+g-_ebf+SnZouOaPEQ@mail.gmail.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.