Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Understanding the Unit of Work API

You do not instantiate an instance of oracle.toplink.sessions.UnitOfWork. Rather, you acquire a unit of work from an instance of oracle.toplink.sessions.Session or from another unit of work.

For more information on creating sessions, see "Creating Sessions".

For more information on acquiring a unit of work, see "Acquiring a Unit of Work".

For more information on using the basic API of the unit of work, see "Using Basic Unit of Work API".

For more information on using the advanced API of the unit of work, see "Using Advanced Unit of Work API".

Unit of Work as Session

The unit of work extends the interface oracle.toplink.sessions.Session, and implements all the usual session API. When using session API from a unit of work, you should consider the following:

Reading and Querying Objects with the Unit of Work

A unit of work offers the same set of database access methods as a regular session.

When called from a unit of work, these methods access the objects in the unit of work, register the selected objects automatically, and return clones.

Although this makes it unnecessary for you to call the registerObject and registerAllObjects methods, be aware of the restrictions on registering objects described in "Creating an Object" and "Associating a New Source to an Existing Target Object".

Reading Objects with the Unit of Work

As with regular sessions, you use the readObject and readAllObjects methods to read objects from the database.

Querying Objects with the Unit of Work

You can execute queries in a unit of work with the executeQuery method.


Note:

Because a unit of work manages changes to existing objects and the creation of new objects, modifying queries such as InsertObjectQuery or UpdateObjectQuery are not necessary and therefore are not supported by the unit of work.

Locking and the Unit of Work

For information on locking API generic to all sessions, see:

For information on locking API specific to a unit of work, see "Using Optimistic Read Locking with forceUpdateToVersionField".