|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.orm.toplink.SessionReadCallback
public abstract class SessionReadCallback
Convenient abstract implementation of the TopLinkCallback interface, exposing either the plain TopLink Session or the TopLink UnitOfWork (which extends the Session interface) to code that reads persistent objects.
Exposes the UnitOfWork if there is an active one (that is, if we're running within a non-read-only transaction); else exposes the Session itself. This allows to modify returned objects within a transaction, which is often desired, while the same code will return shared cache objects if running outside a transaction.
If "enforceReadOnly" is demanded, the callback will always expose the Session itself, avoiding the UnitOfWork overhead in any case.
Session.getActiveUnitOfWork()
,
readFromSession(oracle.toplink.sessions.Session)
Constructor Summary | |
---|---|
SessionReadCallback()
Create a new SessionReadCallback, not enforcing read-only objects. |
|
SessionReadCallback(boolean enforceReadOnly)
Create a new SessionReadCallback, enforcing read-only objects if demanded. |
Method Summary | |
---|---|
Object |
doInTopLink(oracle.toplink.sessions.Session session)
Determines the Session to work on (either the active UnitOfWork or the plain Session) and delegates to readFromSession . |
protected abstract Object |
readFromSession(oracle.toplink.sessions.Session session)
Called with a Session to work on, either the active UnitOfWork or the plain Session (as determined by the transaction status). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SessionReadCallback()
public SessionReadCallback(boolean enforceReadOnly)
enforceReadOnly
- whether to enforce returning read-only objects,
even if running within a non-read-only transactionMethod Detail |
---|
public final Object doInTopLink(oracle.toplink.sessions.Session session) throws oracle.toplink.exceptions.TopLinkException
readFromSession
.
doInTopLink
in interface TopLinkCallback
session
- active TopLink Session
null
if none
oracle.toplink.exceptions.TopLinkException
- if thrown by the TopLink APIreadFromSession(oracle.toplink.sessions.Session)
protected abstract Object readFromSession(oracle.toplink.sessions.Session session) throws oracle.toplink.exceptions.TopLinkException
session
- the TopLink Session to perform read operations on
null
if none
oracle.toplink.exceptions.TopLinkException
- in case of TopLink errors
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |