Torai Torai - 1 month ago 16
Java Question

Query object on java persistence and hibernate

What's the difference between Query object on:
- javax.management
- javax.persitence
- org.hibernate
Which should I use, and why ?

Answer

First of all, based on the tags of your question, javax.management.Query is not relevant for you, as it deals with MBeans, and not DB queries.

Now regarding javax.persistence.Query vs org.hibernate.Query.

That depends very much of what are your goals.

If you plan to stay with Hibernate in your project, use org.hibernate.Query, as it provides more useful methods that the standard interface. But if you plan to switch to another provider, like EclipseLink, you should use the standard interface for both, which is javax.persistence.Query.

https://docs.jboss.org/hibernate/orm/3.2/api/org/hibernate/Query.html http://docs.oracle.com/javaee/6/api/javax/persistence/Query.html