How to return a list of specific type instead of List<Object[]> in Hibernate?

前端 未结 5 663
太阳男子
太阳男子 2020-12-06 02:27

I have tree of classes:

classA {  
      classB b;  
      classC c;
      .....
} 

I have HQL query like this:



        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-06 02:51

    If you are really sure you can do type casts.

     List newlist = ...;
     for(Object o : list){
          newlist.add((classD) o);
     }
    

    Be careful with this though

    So yes. Manual casting. (note: with arrays (you can directly cast) )

提交回复
热议问题