spring hibernate.createSQLQuery return as custom e

2020-07-09 02:26发布

I am doing Query query = hibernate.createSQLQuery("select abc,def from table");

Is it possible to auto "parse" the result to "POJO" list?

So that I can do this:

List<CustomPOJO> abc = query.list();    //CustomPOJO is pojo not entity , no @Entity tag 

1条回答
狗以群分
2楼-- · 2020-07-09 02:58

Try

hibernate.createSQLQuery("select abc,def from table").setResultTransformer(Transformers.aliasToBean(CustomPOJO.class));

like the reference manual suggests.

查看更多
登录 后发表回答