[英]How to remove Hibernate deprecation warning message
We have a query: 我们有一个查询:
List<Book> books = session.createQuery(
"from Book b where :x member of b.bookCategories")
.setParameter("x", crimeStory)
.list();
But when executing this query, we got a warning message: 但是在执行此查询时,我们收到一条警告消息:
WARN 10:19:41 deprecation: HHH90000016: Found use of deprecated 'collection property' syntax in HQL/JPQL query [null.elements];
WARN 10:19:41弃用:HHH90000016:在HQL / JPQL查询[null.elements]中发现已弃用的“ collection property”语法 use collection function syntax instead [elements(null)].
使用集合函数语法代替[elements(null)]。
I tried to change the query to: 我试图将查询更改为:
List<Book> books = session.createQuery(
"from Book b where ? in elements(b.bookCategories)")
.setParameter(0, crimeStory).list();
but the warning message was still there. 但是警告消息仍然存在。
Please help me to fix this warning. 请帮助我解决此警告。
P/s: We are currently using Hibernate 5.0.2 P / s:我们目前正在使用Hibernate 5.0.2
It is legal JPA and so should not be deprecated. 它是合法的JPA,因此不应弃用。 See also http://download.oracle.com/otndocs/jcp/persistence-2.0-fr-oth-JSpec/ .
另请参见http://download.oracle.com/otndocs/jcp/persistence-2.0-fr-oth-JSpec/ 。
See https://hibernate.atlassian.net/browse/HHH-10621 for the JIRA about this bug. 有关此错误的JIRA,请参阅https://hibernate.atlassian.net/browse/HHH-10621 。
You could just hide the message by adding log4j.logger.org.hibernate.orm.deprecation=error
to your log4j.properties
. 您可以通过在
log4j.properties
添加log4j.logger.org.hibernate.orm.deprecation=error
来隐藏消息。
(I know this was an old question but it is used in the JIRA call) (我知道这是一个老问题,但是它在JIRA调用中使用了)
Instead of using MEMBER OF
, rather use an INNER JOIN
. 而不是使用
MEMBER OF
,而是使用INNER JOIN
。 The JSQL should then be 然后应该将JSQL
from Book b inner join b.bookCategories bc where bc.id = :categoryId
Reference: https://stackoverflow.com/a/8340001/67796 参考: https : //stackoverflow.com/a/8340001/67796
As a side note, to simply hide (not fix) messages like this, as of 2017 and Log4j2 , use org.hibernate.orm.deprecation
, for example: 附带说明一下,从2017年和Log4j2开始 ,要简单地隐藏(而不是修复)这样的消息,请使用
org.hibernate.orm.deprecation
,例如:
<Logger name="org.hibernate.orm.deprecation" additivity="false" level="WARN">
<RegexFilter regex=".*HHH90000016.*" onMatch="DENY" onMismatch="NEUTRAL"/>
…
</Logger>
Be sure to use the specific code for your particular deprecation message, in this particular case it was HHH90000016
, but for Criteria-API deprecation warnings it would be HHH90000022
, and so on. 请确保对特定的弃用消息使用特定的代码,在这种特殊情况下为
HHH90000016
,但对于Criteria-API弃用警告HHH90000022
,依此类推。
Or to disable all Hibernate deprecation messages (not recommended): 或禁用所有休眠弃用消息(不推荐):
<Logger name="org.hibernate.orm.deprecation" additivity="false" level="ERROR">
…
</Logger>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.