Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java spring hibernate.createSQLQuery作为自定义实体返回_Java_Sql_Hibernate_Spring - Fatal编程技术网

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));