【发布时间】:2018-10-23 12:47:37
【问题描述】:
我正在使用休眠。我有一个清单。我在 dao 层上使用了 hql。但我的名单不存在。但我打开了 show_sql=true。然后本机sql正在工作。为什么我的原生 sql 能用,hql 不能用。
休眠查询
customers = entityManager.createQuery(
"SELECT c FROM LoungeCustomerCash c where c.operationDate between :beginDate and :endDate and c.boardingPass.operatingCarrierDesignator= :iataCode ORDER BY c.operationDate DESC")
.setParameter("iataCode", iataCode).setParameter("beginDate", beginDate)
.setParameter("endDate", endDate).getResultList();
原生 Sql 查询:
select loungecust0_.id as id2_59_, loungecust0_.CREATEDATE as CREATEDATE3_59_, loungecust0_.CREATEUSER as CREATEUSER4_59_, loungecust0_.UPDATEDATE as UPDATEDATE5_59_, loungecust0_.UPDATEUSER as UPDATEUSER6_59_, loungecust0_.VERSION as VERSION7_59_, loungecust0_.BOARDINGPASSID as BOARDINGPASSID14_59_, loungecust0_.customerType as customerType8_59_, loungecust0_.fullName as fullName9_59_, loungecust0_.LOUNGESERVICEID as LOUNGESERVICEID15_59_, loungecust0_.operationDate as operationDate10_59_, loungecust0_.price as price11_59_, loungecust0_.bankName as bankName12_59_ from LNCUSTOMER loungecust0_ cross join LNBOARDINGPASS boardingpa1_ where loungecust0_.service_type='CASH' and loungecust0_.BOARDINGPASSID=boardingpa1_.id and (loungecust0_.operationDate between to_timestamp('23/09/2018 11:09:02,660000000','DD/MM/RRRR HH24:MI:SSXFF') and to_timestamp('23/12/2018 11:09:02,660000000','DD/MM/RRRR HH24:MI:SSXFF') ) and boardingpa1_.operatingCarrierDesignator='LH' order by loungecust0_.operationDate DESC
【问题讨论】:
-
嗨,问题与休眠和 jsf 相关的问题非常非常少。在这种情况下,它似乎是一个纯休眠的东西,与 JSF 无关。
-
使用
createSQLQuery而不是createQuery。 -
究竟是什么错误? “不工作”非常含糊。
-
@SumeshTG 好的。我正在尝试 createSQLQuery。
-
@coladict 没有错误信息。我的清单也是空的。
标签: hibernate