SQLQuery and org.hibernate.Query are deprecated. What to use instead?

Trying to upgrade hibernate 3 to hibernate 5 these (SQLQuery and Query) interfaces are deprecated. please let me know alternative for this.as we have used Sql Query in our appications.

Since you are asking this question, I suppose you did not read the Migration Guide entirely.

Doing such a migration without following the Migration Guide is not recommended.

If you go to the `SQLQuery class, you will see this:

 * @deprecated (since 5.2) use {@link NativeQuery} instead.

And, for the org.hibernate.Query, you will see this:

 * @deprecated (since 5.2) use {@link org.hibernate.query.Query} instead

This is also documented in the JavaDoc.

So, use the org.hibernate.query.NativeQuery and org.hibernate.query.Query instead.

Thank you very much it helped me to solve the problem.

1 Like