Different query generated by JPA Criteria API as compared to hibernate Criteria API

17 Views Asked by At

I am using hibernate ORM. Current version in use is 5.6.3. I am planning to re-write all my queries to JPA criteria API from Hibernate Criteria API.

In order to ensure there is no inadvertent regression during this re-write, I have captured all generated queries by enabling debug logging for org.hibernate.SQL logger. Similar activity was done after changing to JPA criteria API.

However after the change, I am observing a slight change in the queries which are being generated.

Before

SELECT table0_.account_id AS account_9_0_1_
WHERE  table0_.account_id IN (SELECT this_.id
                              FROM   accounts this_
                              WHERE  this_.user_id = ?
                                     AND this_.account_ext_id IN ( ?, ? )) 

After

SELECT table0_.account_id AS account_9_0_1_
WHERE  table0_.account_id IN (SELECT storedacco0_.id
                              FROM   accounts storedacco0_
                              WHERE  storedacco0_.user_id = ?
                                     AND ( storedacco0_.account_ext_id IN ( ?, ?
                                           ) )) 

Upon close inspection, it was observed that this_ is replaced by the table alias for the inner query. Is this change expected ?

0

There are 0 best solutions below