Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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]; use collection function syntax instead [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

like image 793
Minh Nguyen Avatar asked Oct 26 '15 03:10

Minh Nguyen


1 Answers

As a side note, to simply hide (not fix) messages like this, as of 2017 and Log4j2, use org.hibernate.orm.deprecation, for example:

<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.

Or to disable all Hibernate deprecation messages (not recommended):

<Logger name="org.hibernate.orm.deprecation" additivity="false" level="ERROR">
    …
</Logger>
like image 58
MarcG Avatar answered Sep 20 '22 07:09

MarcG