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

**URL:** <https://discourse.hibernate.org/t/sqlquery-and-org-hibernate-query-are-deprecated-what-to-use-instead/1179>\
**Category:** Hibernate ORM\
**Created:** [August 6, 2018, 9:14am UTC](https://discourse.hibernate.org/t/sqlquery-and-org-hibernate-query-are-deprecated-what-to-use-instead/1179 "2018-08-06T09:14:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Amo](https://discourse.hibernate.org/u/Amo)\
**Post date:** [August 6, 2018, 9:14am UTC](https://discourse.hibernate.org/t/sqlquery-and-org-hibernate-query-are-deprecated-what-to-use-instead/1179/1 "2018-08-06T09:14:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [August 7, 2018, 12:15pm UTC](https://discourse.hibernate.org/t/sqlquery-and-org-hibernate-query-are-deprecated-what-to-use-instead/1179/2 "2018-08-07T12:15:17Z")

</div>

Since you are asking this question, I suppose you did not read the [Migration Guide](https://github.com/hibernate/hibernate-orm/wiki/Migration-Guides) 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](https://docs.jboss.org/hibernate/orm/5.2/javadocs/deprecated-list.html#class).

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

---

<div class="post-metadata">

**Author:** ![Amo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Amo](https://discourse.hibernate.org/u/Amo)\
**Post date:** [November 14, 2018, 1:29pm UTC](https://discourse.hibernate.org/t/sqlquery-and-org-hibernate-query-are-deprecated-what-to-use-instead/1179/3 "2018-11-14T13:29:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Raghavendra\_J](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/raghavendra_j/32/2544_2.png) [@Raghavendra\_J](https://discourse.hibernate.org/u/Raghavendra_J)\
**Post date:** [July 3, 2023, 11:41am UTC](https://discourse.hibernate.org/t/sqlquery-and-org-hibernate-query-are-deprecated-what-to-use-instead/1179/4 "2023-07-03T11:41:37Z")

</div>

Are there any reasons for deprecation ? does it impact performance ? We have used SQLQuery in lot of places in our project, looking if it is worth to make such huge changes.
