The JPA-SQL editor is a powerful tool that facilitates the formulation of your database queries in RapidClipse. JPA-SQL is a domain-specific, database-independent language (DSL). The syntax is deliberately similar to SQL so that JPA-SQL is easy to learn. However, JPA-SQL is not to be confused with native SQL. Queries formulated in JPA-SQL are never sent to a database. Instead, they are converted to Java code based on the JPA Criteria API. Thus, you can access all the benefits of the JPA Criteria API without having to write the JPA Criteria code.

At runtime, Hibernate generates the native SQL statements from the generated JPA Criteria code to match the connected database, and these are sent to the database. Thus JPA-SQL combines the simplicity of SQL with the numerous advantages of JPA Criteria API.


Benefits of JPA-SQL compared to the use of SQL strings:

Benefits of JPA-SQL in comparison to the JPA Criteria API:


  1. Under Project Management > Data Access click the DAO with which you want to perform a database query, e.g. CustomerDAO.java.
  2. Press Strg + Space and select query: create new query in the following autocomplete window.
  3. Enter an appropriate method name for the generated method, e.g. findAllCustomer.

    findAllCustomer()
    {
    	select * from 
    }


  4. After the keyword from, enter C, press Strg + Space and select Customer.
  5. Click Save.


Result:
Examples:
Note:

JPA-SQL Language Specification