|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object PersistenceContext
PersistenceContext provides the interface between a client thread and the persistence framework. A persistence context encapsulates an object directory and object cache which are isolated from the object directory and object cache of other persistence contexts. Persistent objects are created in the persistence context bound to the current thread. Methods are provided to find and delete persistent objects.
Transactions are supported by a persistence context and are isolated from the transactions of other contexts. A transaction begins when a persistence context is created or immediately after the more recent call to the commit or rollback method. The commit method traverses the object directory and persists all changes to the database within a single database transaction. The rollback method traverses the object directory casting out any modified or deleted objects and any objects that have not been persisted.
A persistence context can be bound to multiple threads while a thread can only be bound to one persistence context. The client determines whether threads share a persistence context by explicitly binding each thread to a new context or an existing context.
Method Summary | |
void |
bind(Thread t)
Bind this context to the specified thread. |
void |
close()
Close this persistence context and return it to the context pool. |
void |
commit()
Commit all changes to the database. |
Criteria |
createCriteria(String className)
Create a search criteria object bound to the specified persistent class. |
void |
delete(AbstractProxy proxy)
Delete the persistent object associated with a proxy. |
void |
delete(Collection c)
Delete a collection of persistent objects. |
void |
delete(LOID loid)
Delete the persistent object with the specified logical object ID. |
Collection |
find(Criteria sc)
Find all objects that satisfy the search criteria. |
Object |
find(LOID loid)
Find an object by LOID. |
int |
id()
Returns the identifier for this context. |
PersistenceManager |
manager()
Returns the persistence manager. |
void |
rollback()
Rollback all changes to persistent objects. |
void |
setDefaultDatabase(String name)
Set the default database. |
void |
showObjects()
Display all objects in the object directory in a user-friendly format. |
String |
toString()
Returns a string representation of this persistence context. |
Methods inherited from class Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public void bind(Thread t)
public void close()
public void commit() throws PersistenceException
PersistenceException
public Criteria createCriteria(String className) throws ClassNotSupportedException, PersistenceException
className
- the name of the class of objects to be found
using the search criteria.
ClassNotSupportedException
PersistenceException
public void delete(LOID loid) throws ClassNotSupportedException, InvalidReferenceException, PersistenceException
loid
- the logical object ID of the object to be deleted.
InvalidReferenceException
- if the class ID or database ID
is not valid.
ClassNotSupportedException
- if the class specified in the
LOID is not supported by the database specified in the LOID.
PersistenceException
- if unable to create a proxy or instantiate
an implementation object.public void delete(AbstractProxy proxy)
proxy
- a proxy for the object to be deleted.public void delete(Collection c)
c
- a collection of proxies for persistent objects.public Object find(LOID loid) throws PersistenceException
loid
- the logical object identifier.
PersistenceException
- if the object is not found.public Collection find(Criteria sc) throws PersistenceException
sc
- the search criteria.
Collection
of the objects found.
PersistenceException
- if an SQL error occurred.public int id()
public PersistenceManager manager()
public void rollback()
public void setDefaultDatabase(String name) throws DatabaseNotRegisteredException
name
- the name of the new default database.
DatabaseNotRegisteredException
- if the specified database is
not configured in the metadata.public void showObjects()
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |