Java Reference
In-Depth Information
Strategies with the Spring Framework
Spring JDBC provides the convenient abstract class StoredProcedure to execute stored
procedures. This class, like other support classes in Spring JDBC, implements the GOF
Template Design pattern and provides an OO abstraction of a stored procedure. With this
class, it is possible to perform stored procedure operations such as setting input and out-
put variables, using database-specific datatypes, and returning cursors. This specific
class extends from the SqlCall class, which can be used to model the execution of any
stored procedure and function. The root of the SqlCall class is the RdbmsOperation , which
can be used to model any database-specific operation such as a SQL query to retrieve
results, update or delete records, and invoke stored procedures. Figure 5-2 shows the
class diagram of the stored procedure support classes.
Figure 5-2. Class diagram: Spring stored procedure support classes
To explore Spring JDBC's support for stored procedure, I will show the case when
lead information has to be saved into the database. Listing 5-17 shows the simplified sig-
nature of the stored procedure. This stored procedure is used to create a new lead in the
database. It accepts the lead name and country as input and outputs the lead ID, which is
the primary key in the database and generated by a sequence.
Listing 5-17. Stored Procedure Signature
SaveNewLead (:pLeadId OUT NUMBER,:pName IN VARCHAR2,:pCountryCd VARCHAR2)
 
Search WWH ::




Custom Search