Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to Execute JPQL Queries?

Tags:

java

jpa

jpql

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.

like image 762
Rintoul Avatar asked Oct 23 '09 19:10

Rintoul


People also ask

How do I run a JPQL query?

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.

Which method is used to execute a select JPQL query?

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.

Is JPQL simpler than SQL?

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.


2 Answers

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).

alt text

Update: I removed the tool suggested for NetBeans, the project is inactive and doesn't provide anything.

like image 171
Pascal Thivent Avatar answered Sep 21 '22 11:09

Pascal Thivent


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

https://blogs.oracle.com/geertjan/resource/run-jpql-query-4.png

like image 24
Ondra Žižka Avatar answered Sep 22 '22 11:09

Ondra Žižka