# ADF BC StoredProcedures Sample

The goal of this sample application is to demonstrate how to a ADF Business Components application can use database stored procedures to select, update, insert, and delete data.

## Requirements

You must have JDeveloper 10 g and access to the Oracle common schema. To install the Oracle9i common schema on a earlier version of the database following these instructions.

You must also run the included SQL script (`stproc.sql`) using the `hr_conn` connection. To do this in JDeveloper, you must have SQL*Plus installed.

1. Open the `Model` project in the Application Navigator.
2. Right click on `stproc.sql`.
3. Select Run in SQL*Plus|hr_conn
   If you haven't used SQL*Plus with JDeveloper, you may be prompted for the location to SQL*Plus. Enter it and click OK.

If you don't have SQL*Plus installed, you could also use the SQL Worksheet available in JDeveloper.

1. From the Tools menu, select SQL Worksheet.
2. Copy all contents of the script into the SQL Worksheet.
3. Click the Execute Statement button.

This script is designed for the Oracle database. It may not work on other databases.

## Running the sample

To run the sample right-click on the Model project and select Run from the context menu.

## How was this sample created?

The Model project was created using the simple ADF Business Components wizards available in the new gallery. The `doDML()` and `doSelect()` methods were written using the code editor.

## Key points in this sample

The key point in this sample application is to understand how to override `doDML()` and `doSelect()` in the entity object to use stored procedures. You may want to do this if you have existing stored procedures that you want to use, rather than using the default ADF BC methods for working with your data.

To see how this is done, open `DepartmentsImpl.java` in the code editor. You can do this by selecting the Departments entity object in the Model project, Then, in the structure pane, double-clicking on `DepartmentsImpl.java`. Look closely at `doSelect()` at line 127 and `doDML()` at line 135. Notice they use helper functions defined further down in the file. That's a good practice to keep the logic of`doSelect()` and `doDML()` clear, while still allowing you to write complex functions to work with your data.

## Next Steps

Here are a few things you could do now that you understand this sample.

- Try it using your own stored procedures
- Create a client that uses the ADF BC from this sample