意外的令牌:: Hibernate中的(冒号)

问题描述 投票:0回答:1

我正在尝试执行以下代码,但是我得到了引用unexpected token: : near line 1ord.date_out::date错误。这是我的代码

@Query(value="select new com.ameerarestapi.wrapper.report.SummaryPeriodicSales(sto.name, sum(odi.subtotal_price), sum(odi.qty), ((sum(odi.subtotal_price))/(sum(odi.qty))), ord.date_out::date) "
                 + "from OrderDetailItem odi "
                 + "left join odi.order as ord "
                 + "left join ord.store as sto "
                 + "where ord.store.principle = :principle and ord.orderStatus IN :orderstatus and ord.dateOut between :date1 and :date2 and ord.voidStatus = :voidStatus "
                 + "group by sto.name, ord.date_out::date ")
List<SummaryPeriodicSales> getReportDaily(@Param("principle") Principle principle,@Param("orderstatus") List<OrderStatus> orderstatus,@Param("date1") Date date1,@Param("date2") Date date2,@Param("voidStatus") byte voidStatus);

我正在使用postgre数据库

postgresql hibernate spring-data-jpa hql
1个回答
0
投票

使用标准的CAST()运算符:

CAST(ord.date_out AS date)
© www.soinside.com 2019 - 2024. All rights reserved.