Skip Headers

# SQL Finders

Previous

Next

Using SQL to define a finder offers the following advantages:

- You can implement logic that cannot be expressed when you use EJB QL or a TopLink `Expression`.

- It allows for the use of a stored procedure instead of TopLink generated SQL.

- There may be cases in which custom SQL will improve performance.

SQL finders also have the following disadvantages:

- Writing complex custom SQL statements requires a significant maintenance effort if the database tables change.

- Hard-coded SQL limits portability to other databases.

- No validation is performed on the SQL string. Errors in SQL statements will not be detected until run time.

- The use of SQL for a function other than `SELECT` may result in unpredictable errors.

For more information on TopLink predefined finders that take SQL, see "Predefined Finders".