JPA Native Query
JPA is said to make things easier for programmers, but as a programmer, why do I feel the opposite? JDBC is a little tedious, but it's very handy, and can be very efficient with the right SQL queries. JPA/Hibernate seem to make things easier by taking away the tasks of mapping result set to object and doing joinings, but I often feel that I don't know how to do this and that, and I'd rather just use JDBC if I have the choice (but usually not if you are in a big JEE project)... Native query can help a little on performance by executing your own query.
A typical way of using native queries with JPA & Spring is to implement a customize repository.
>
>> insert an example here, with inheritance relationships between entities... <<< </cite>
Notes
ID member(s) in entity class should be unique
In an entity class, a member annotated as @Id is needed. This is usually fine, but if this member can be duplicated in the result set, the mapped objects can be wrong. For example, I found that when a query returns 10 records with the same ID member, you will get 10 objects, but all of them have the value of the first record. So we need to make the ID member unique, if it's not possible, we can mark more than one member as ID fields. But in this case, the entity class needs to implement 'Serializable' interface.