views:

160

answers:

1

Hibernate JPA Template fetches list of objects from database. Can this be type casted to another class object list??

List<Class1> list1 = (List<Class1>) getJpaTemplate().findByNamedQuery("..someQuery..");

This is the code which i use now. Class1 relates to a table1 in database. Will I be able to fetch the records in table1 into another list<Class2> list2; which has all parameters as table1 and some extra parameters. If I will be able to fetch then will I be able to assign values to those extra parameters through namedQuery ??

Any help appreciated!!

A: 

Yes, you can. But before you have some more concrete questions, go read the following: Hibernate inheritance and JPA-QL reference, point 7.7, where they explain cat.class

Bozho