简体   繁体   English

JPQL没有给出结果

[英]JPQL not giving results

In my application I am hitting DB using JPA (With Hibernate as JPA Provider). 在我的应用程序中,我使用JPA(使用Hibernate作为JPA Provider)访问数据库。 When I try to run a query, system provides me empty result list. 当我尝试运行查询时,系统会为我提供空的结果列表。 But when I run SQL representation of same query (taken from logs), it runs fine and provides me correct results. 但是,当我运行相同查询的SQL表示形式(取自日志)时,它运行良好,并为我提供了正确的结果。

Can someone please help me in understanding what can be the possible issue here? 有人可以帮我理解这里可能出现的问题吗?

The issue is probably with the parameter values. 问题可能出在参数值上。 Do you use any parameter of a type that requires some inference from the provider (like an enum)? 您是否使用任何需要提供程序进行某种推断的类型的参数(例如枚举)? I've seen a complex JPQL query for which Hibernate 3.3 wasn't able to infer the type of an enum (Number or String) for an entity attribute because the entity attribute wasn't qualified with the entity alias in the query (entityAttribute instead of alias.entityAttribute). 我看到了一个复杂的JPQL查询,Hibernate 3.3无法为其查询实体属性的枚举类型(数字或字符串),因为该实体属性未使用查询中的实体别名进行限定(改为entityAttribute (alias.entityAttribute)。 The enum was set as a parameter in its serialized form. 枚举被设置为其序列化形式的参数。 Like @Gimby said, you can check the full Hibernate logs to see what are the real values set as parameters. 就像@Gimby所说的那样,您可以检查完整的Hibernate日志以查看设置为参数的实际值是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM