1 21 package oracle.toplink.essentials.internal.sessions; 23 24 import oracle.toplink.essentials.exceptions.*; 25 import oracle.toplink.essentials.threetier.*; 26 import oracle.toplink.essentials.internal.identitymaps.IdentityMapManager; 27 import oracle.toplink.essentials.queryframework.*; 28 import oracle.toplink.essentials.internal.sessions.AbstractSession; 29 import oracle.toplink.essentials.internal.sessions.AbstractRecord; 30 31 37 public class IsolatedClientSession extends oracle.toplink.essentials.threetier.ClientSession { 38 public IsolatedClientSession(ServerSession parent, ConnectionPolicy connectionPolicy) { 39 super(parent, connectionPolicy); 40 } 41 42 47 public void initializeIdentityMapAccessor() { 48 this.identityMapAccessor = new IsolatedClientSessionIdentityMapAccessor(this, new IdentityMapManager(this)); 49 } 50 51 56 protected boolean shouldExecuteLocally(DatabaseQuery query) { 57 if (isIsolatedQuery(query)) { 58 return true; 59 } 60 return isInTransaction(); 61 } 62 63 67 protected boolean isIsolatedQuery(DatabaseQuery query) { 68 query.checkDescriptor(this); 69 if (query.isDataModifyQuery() || ((query.getDescriptor() != null) && query.getDescriptor().isIsolated())) { 70 return true; 76 } 77 return false; 78 79 } 80 81 97 public AbstractSession getParentIdentityMapSession(DatabaseQuery query, boolean canReturnSelf, boolean terminalOnly) { 98 if ((query != null) && isIsolatedQuery(query)) { 99 return this; 100 } else { 101 return getParent().getParentIdentityMapSession(query, canReturnSelf, terminalOnly); 102 } 103 } 104 105 120 public AbstractSession getExecutionSession(DatabaseQuery query) { 121 if (shouldExecuteLocally(query)) { 122 return this; 123 } else { 124 return getParent().getExecutionSession(query); 125 } 126 } 127 128 133 public Object executeCall(Call call, AbstractRecord translationRow, DatabaseQuery query) throws DatabaseException { 134 if (isInTransaction()) { 135 return super.executeCall(call, translationRow, query); 136 } 137 return getParent().executeCall(call, translationRow, query); 138 } 139 } 140 | Popular Tags |