Java Reference
In-Depth Information
Listing 11.10. Stored procedure for counting the bids for a particular user ID (pgSQL)
The stored procedure in this listing defines a getQtyOrders method that accepts a user
ID and returns the number of bids created by the particular user. Thus, the procedure has
one parameter and one result. The input parameter is an integer and the result parameter is
also an integer. The code in the next listing invokes this procedure.
Listing 11.11. Invoking a stored procedure using JPA
The code in this listing creates a StoredProcedureQuery and then registers a
parameter that is an integer . This parameter is named param1 , which is then used for
setting the value . Finally, the stored procedure is executed just like any other query and
the results retrieved. Thus, invoking a stored procedure isn't very different from invoking
a regular query.
That concludes our survey of JPQL, the criteria API, and using native queries. Let's revisit
the major topics of this chapter and then dive into CDI.
 
Search WWH ::




Custom Search