Polymorphic queries in Hibernate those returns instances not only of Student , but also of subclasses like DomesticStudent . Hibernate queries can name any Java class or interface in the from clause. The query will return instances of all persistent classes that extend that class or implement the interface.
These last two queries will require more than one SQL SELECT. This means that the order by clause does not correctly order the whole result set. It also means you cannot call these queries using Query.scroll().
It can like this:
from Student as student
The following query would return all persistent objects:
from java.lang.Object o
The interface Named might be implemented by various persistent classes:
from Named n, Named m where n.name = m.name