Java Reference
In-Depth Information
JPQL
JPQL ( Java Persistence Query Language ) is an object-oriented SQL-like query
language. It is platform independent and allows you to access your data through en-
tities instead of manipulating the physical structure of your database. The following
code demonstrates how to query for all registered students whose ID is greater than
123.
The following code is an example of a JPQL query:
String queryString = "SELECT a FROM Student a
WHERE a.id > 123";
Query query = em.createQuery(queryString);
System.out.println("result :
"+query.getResultList());
Despite its power and its vastness, the JPQL continues to receive significant im-
provements. In JPA 2.1, it has among other enhancements integrated support for
stored procedures, added new reserved identifiers, and the support for creation of
named queries at runtime.
Support for stored procedures
JPA 2.1 now allows you to execute stored procedures. Through the various API that
it offers, you can define and execute named stored procedures or dynamically stored
procedures.
The following script is an example of a script to create a stored procedure in MySQL:
DELIMITER $$
CREATE
PROCEDURE
`ONLINEREGISTRATION`.`getStudentsName`()
BEGIN
SELECT ID,LASTNAME FROM STUDENT ORDER BY
LASTNAME ASC;
Search WWH ::




Custom Search