简体   繁体   中英

Which one is faster: session.createCriteria() or session.createQuery() in hibernate?

Is there any difference in performance if we are using hibernate criteria queries instead of create queries? I looked the web but didn't found a satisfactory answer.

session.createQuery() ( HQL/JPQL queries ) and session.createCriteria() ( Criteria queries ) have the same performance and efficiency.

Criteria queries are more flexible and provide better support for writing dynamic queries as compared to HQL and JPQL. But HQL and JPQL provide native query support that isn't possible with the Criteria queries. This is one of the disadvantages of the Criteria query. We can easily write complex joins using JPQL native queries, whereas it gets difficult to manage while applying the same with Criteria API.

more info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM