Java Reference
In-Depth Information
The following code demonstrates how to execute the stored procedure getStu-
dentsName we just created:
EntityManagerFactory emf =
EntityManager em = emf.createEntityManager();
//create entity manager
StoredProcedureQuery spQuery =
List<Student> results = spQuery.getResultList();
for(Student std : results)
New reserved identifiers
The JQPL has introduced the following new keywords:
ON : This keyword allows us to make explicit joins as in SQL with the ON con-
tities, whichrequiredminimalconfiguration. Thefollowingcodedemonstrates
the use of ON :
String queryString = "SELECT a FROM
Student a "+" JOIN Department b ON
a.departId =";
Query query = em.createQuery(queryString);
System.out.println("result :
FUNCTION : This keyword allows you to invoke functions in your queries other
than those originally intended by JPQL (such SUBSTRING , LENGTH , ABS ,
TRIM , and so on). With this keyword, you can use a database function or
functions that you have defined yourself. The following query gives us the list
of students born in July by using the month() method of derby database in
order to extract the month from a birth date:
Search WWH ::

Custom Search