Java spring hibernate.createSQLQuery作为自定义实体返回
我正在执行Java spring hibernate.createSQLQuery作为自定义实体返回,java,sql,hibernate,spring,Java,Sql,Hibernate,Spring,我正在执行queryquery=hibernate.createSQLQuery(“从表中选择abc、def”) 是否可以将结果自动“解析”到“POJO”列表 这样我就可以做到: List<CustomPOJO> abc = query.list(); //CustomPOJO is pojo not entity , no @Entity tag List abc=query.List()//CustomPOJO不是实体,没有@entity标记 试试看 就像我建议的那样
queryquery=hibernate.createSQLQuery(“从表中选择abc、def”)代码>
是否可以将结果自动“解析”到“POJO”列表
这样我就可以做到:
List<CustomPOJO> abc = query.list(); //CustomPOJO is pojo not entity , no @Entity tag
List abc=query.List()//CustomPOJO不是实体,没有@entity标记
试试看
就像我建议的那样
hibernate.createSQLQuery("select abc,def from table").setResultTransformer(Transformers.aliasToBean(CustomPOJO.class));