|
Oracle Fusion Middleware Java API Reference for Oracle TopLink 11g Release 1 (11.1.1) B32476-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.toplink.ejb.cmp.SessionAccessor
public class SessionAccessor
This class provides access to TopLink's Session and UnitOfWork and can be used at runtime by a bean to manage aspects of caching, merging, and transactions with regular java objects that are not generally available in an EJB.
If a bean (including an EJB1.1 bean) has references to regular Java objects that are made persistent through TopLink, this class can be used to properly manage various serialized versions of the Java objects.
Constructor Summary | |
---|---|
SessionAccessor() |
Method Summary | |
---|---|
static UnitOfWork |
getCurrentUnitOfWorkFor(javax.ejb.EntityContext context) Returns the active TopLink unit of work for the context. |
static Session |
getSessionFor(javax.ejb.EntityContext context) Returns the active TopLink session for the context. |
static Session |
getSessionFor(java.lang.String name) Returns the active TopLink session for the project. |
static java.lang.Object |
registerOrMergeAttribute(java.lang.Object value, java.lang.String attributeName, javax.ejb.EntityContext ctx) Merge the changes from the remote clone into the server version of the object(s) for a bean's attribute. |
static java.lang.Object |
registerOrMergeObject(java.lang.Object value, javax.ejb.EntityContext ctx) Merge the changes from the remote clone into the server version of the object(s) for a bean's attribute. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SessionAccessor()
Method Detail |
---|
public static UnitOfWork getCurrentUnitOfWorkFor(javax.ejb.EntityContext context)
WARNING - Only in rare instances should this method ever be used, and if so, caution must be taken to ensure that the unit of work is not misused.
context
- the entity context for the beanpublic static Session getSessionFor(javax.ejb.EntityContext context)
context
- the entity context associated with the sessionpublic static Session getSessionFor(java.lang.String name)
name
- the project identifier of the project associated with the sessionpublic static java.lang.Object registerOrMergeObject(java.lang.Object value, javax.ejb.EntityContext ctx)
Here is an example of how this method can be used within an EJB setter method.
public void setAddress(Address addressFromClient) { this.address = (Address)SessionAccessor.registerOrMergeObject( addressFromClient, this.ctx ); }
value
- the attribute object to mergectx
- the entity context of the beanpublic static java.lang.Object registerOrMergeAttribute(java.lang.Object value, java.lang.String attributeName, javax.ejb.EntityContext ctx)
Here is an example of how this method can be used within an EJB setter method.
public void setAddress(Address addressFromClient) { this.address = SessionAccessor.registerOrMergeAttribute( addressFromClient, "address", this.ctx ); }
value
- the attribute object to mergeattributeName
- the name of the field in the beanctx
- the entity context of the bean
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |