1 16 17 package org.springframework.orm.toplink; 18 19 import oracle.toplink.exceptions.TopLinkException; 20 import oracle.toplink.sessions.Session; 21 import oracle.toplink.sessions.UnitOfWork; 22 23 42 public abstract class SessionReadCallback implements TopLinkCallback { 43 44 private final boolean enforceReadOnly; 45 46 49 public SessionReadCallback() { 50 this.enforceReadOnly = false; 51 } 52 53 58 public SessionReadCallback(boolean enforceReadOnly) { 59 this.enforceReadOnly = enforceReadOnly; 60 } 61 62 67 public final Object doInTopLink(Session session) throws TopLinkException { 68 Session sessionToUse = session; 69 if (!this.enforceReadOnly) { 70 UnitOfWork unitOfWork = session.getActiveUnitOfWork(); 71 if (unitOfWork != null) { 72 sessionToUse = unitOfWork; 73 } 74 } 75 return readFromSession(sessionToUse); 76 } 77 78 85 protected abstract Object readFromSession(Session session) throws TopLinkException; 86 87 } 88 | Popular Tags |