Spring hibernate.createSQLQuery作为自定义实体返回

我在做 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));

就像参考手册所建议的那样。

以上是 Spring hibernate.createSQLQuery作为自定义实体返回 的全部内容, 来源链接: utcz.com/qa/413738.html

回到顶部