我正在做 Query query = hibernate.createSQLQuery("select abc,def from table");
是否可以将结果自动“解析”到“POJO”列表?
这样我就可以做到:
List<CustomPOJO> abc = query.list(); //CustomPOJO is pojo not entity , no @Entity tag
最佳答案
尝试
hibernate.createSQLQuery("select abc,def from table").setResultTransformer(Transformers.aliasToBean(CustomPOJO.class));
喜欢reference manual建议。
关于java - spring hibernate.createSQLQuery 作为自定义实体返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2183393/