Skip Headers

Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Using a Unit of Work With Custom SQL

You can execute native SQL or invoke a stored procedure within a unit of work by using unit of work method `executeNonSelectingCall` or by executing a `DataModifyQuery`. This makes the unit of work begin its database transaction early and execute the call to the data immediately.

If you release the unit of work, it will roll back the database changes. If you commit the unit of work and the commit succeeds, the unit of work will commit the changes to the database.

You can execute a `DataModifyQuery` only in a unit of work or a database session. You cannot execute a `DataModifyQuery` in a client or server session directly.

You can execute a `DataReadQuery` or use session method `executeSelectingCall` in any session type because these do not modify data.

Example 102-11 illustrates using `SQLCall` with the unit of work method `executeNonSelectingCall`.

Example 102-11 Using the executeNonSelectingCall Method

    uow.executeNonSelectingCall(new SQLCall(mySqlString));

WARNING: Allowing an unverified SQL string to be passed into methods makes your application vulnerable to SQL injection attacks.