How to create View of Objects with EJB QL ?
One nice feature of EJB QL is the ability to create new Type safe instances of an Object simply using the new construct. Here is an example:
select new Family(mother, mate, offspr)
from DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr
Here we are returning an Object type of Family provided that we have a Constructor Family(mother, mate, offspr) in the class.
This option is useful to create View of Object structures, similarly like RDBMS create view of tables