Polymorphic queries in Hibernate by R4R Team

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



Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!