【问题标题】:unexpected token: :(colon) in Hibernate意外的标记::(冒号) 在 Hibernate
【发布时间】:2019-07-22 03:55:40
【问题描述】:

我正在尝试执行以下代码,但我收到了 unexpected token: : near line 1 错误,它指的是 ord.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】:

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

    CAST(ord.date_out AS date)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-24
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 2020-09-28
      • 2018-08-02
      • 2020-10-03
      • 1970-01-01
      相关资源
      最近更新 更多