Is there any sort of tool available which allows one to execute JPQL queries against a database "directly"? I would like to type JPQL queries directly into a window and execute them.
Of course it would probably require me to do quite a bit of configuration so that it would be aware of my JPA entities, etc., but I guess it could be done... Anyone know of such a tool?
Thanks.
Until Eclipse Dali gets a generic JPQL editor you can use Hibernate Tools. Hibernate Tools works with Dali and provides a HQL/JPQL query editor which uses Hibernate to execute the queries. An alternative would be to use the JPA Query Tool [JQT], an Interactive JPA query editor and runner.
Execute the query using an appropriate Query's method: getSingleResult or getResultList. In the case of an update or delete operation, though, you must use the executeUpdate method, which returns the number of entity instances updated or deleted.
JPQL syntax is very similar to the syntax of SQL. Having SQL like syntax is an advantage because SQL is a simple structured query language and many developers are using it in applications. SQL works directly against relational database tables, records and fields, whereas JPQL works with Java classes and instances.
Until Eclipse Dali gets a generic JPQL editor you can use Hibernate Tools. Hibernate Tools works with Dali and provides a HQL/JPQL query editor which uses Hibernate to execute the queries.
An alternative would be to use the JPA Query Tool [JQT], an Interactive JPA query editor and runner. It might be closer to what you're looking for (runs as a standalone application).
Update: I removed the tool suggested for NetBeans, the project is inactive and doesn't provide anything.
News from 2013: NetBeans 7.3 will have a built-in JPQL query tool:
https://blogs.oracle.com/geertjan/entry/test_jpql_with_netbeans_ide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With