Skip Headers

# Using SQL Finders

Previous

Next

You can use custom SQL code to specify finder logic. SQL lets you implement logic that might not be possible to express with TopLink expressions or EJB QL.

To create a SQL finder, use this procedure:

1. Declare the finder in the `ejb-jar.xml` file, and leave the `ejb-ql` tag empty.

2. Start TopLink Workbench.

3. Specify the `ejb-jar.xml` file location and choose File > Updated Project from the `ejb-jar.xml` file to read in the finders.

4. Go the Queries > Named Queries tab for the bean.

5. Select the finder, select the SQL radio button, and enter the SQL string.

6. Configure the finder.

The following is an example of a simple SQL finder that requires one parameter. In this example, the number sign character ( # ) is used to bind the argument `projectName` within the SQL string:

    SELECT * FROM EJB_PROJECT WHERE (PROJ_NAME = #projectName)