Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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
Hibernate Jasper报表所需子实体类中选择字段的HQL查询_Hibernate_Jasper Reports_Hql - Fatal编程技术网

Hibernate Jasper报表所需子实体类中选择字段的HQL查询

Hibernate Jasper报表所需子实体类中选择字段的HQL查询,hibernate,jasper-reports,hql,Hibernate,Jasper Reports,Hql,我需要对Jasper报告进行HQL查询,以选择子实体字段 我在reoprt.jrxml中尝试了以下查询: select c.fullname, p.description from Client c inner join c.Product p 但我得到: net.sf.jasperreports.engine.JRException:从bean:description检索字段值时出错 我知道这个查询返回两个对象,但我不知道使用HQL选择子实体字段的正确方法是什么 或者,我尝试将Product

我需要对Jasper报告进行HQL查询,以选择子实体字段

我在reoprt.jrxml中尝试了以下查询:

select c.fullname, p.description from Client c inner join c.Product p
但我得到:

net.sf.jasperreports.engine.JRException:从bean:description检索字段值时出错

我知道这个查询返回两个
对象
,但我不知道使用HQL选择
子实体字段的正确方法是什么

或者,我尝试将
Product
字段放在
Map
中,并在Jasper报告中使用这些参数,但这不是一个好的做法

Map map = new HashMap();
    manager.searchId(74).forEach(client -> {
    map.put("description", client.getProduct().getDescription());
});
我应该使用哪个查询

无法使用请求的结果类型为具有多个返回的查询创建类型化查询

消息已经指出,您有多个查询返回,即选择的项不能使用除
Object[]
Tuple
以外的结果类型

下面的代码有什么不同?您仍然返回一个
列表
。如果需要,可以使用以下HQL功能返回地图列表:

public List<Map<String, Object>> quotation() {
    try (Session session = sessionFactory.openSession()) {
        return session.createQuery("select new map(c.fullname as fullname, p.description as description) from Client as c inner join Product p where c.id=74", Map.class).getResultList();
    }
}
公开列表报价(){
try(Session Session=sessionFactory.openSession()){
从客户端返回session.createQuery(“选择新映射(c.fullname作为fullname,p.description作为description),作为c内部连接产品p,其中c.id=74”,map.class).getResultList();
}
}

那么,只需使用
return session.createQuery(“从客户端选择新映射(c.fullname作为fullname,p.description作为description),作为c内部连接产品p,其中c.id=74”,map.class)。getSingleResult()
Sorry@Christian Beikov我想在Jasper reportrs中获得此查询工作,但它没有。我想查询Jasper报告。嗨,我解决了它,它甚至不需要写我刚刚在Jasper Report product.description中创建的查询字段,它解决了这个问题。我用JPA代替HQl搜索记录。