1 56 package org.objectstyle.cayenne.service; 57 58 import org.objectstyle.cayenne.CayenneRuntimeException; 59 import org.objectstyle.cayenne.graph.CompoundDiff; 60 import org.objectstyle.cayenne.graph.GraphDiff; 61 import org.objectstyle.cayenne.graph.OperationRecorder; 62 63 69 class ObjectDataContextCommitAction { 70 71 GraphDiff commit(ObjectDataContext context) throws CayenneRuntimeException { 72 73 if (context.getParentContext() == null) { 74 throw new CayenneRuntimeException( 75 "ObjectContext has no parent PersistenceContext."); 76 } 77 78 synchronized (context.getObjectStore()) { 79 80 if (!context.hasChanges()) { 81 return new CompoundDiff(); 82 } 83 84 if (context.isValidatingObjectsOnCommit()) { 85 context.getObjectStore().validateUncommittedObjects(); 86 } 87 88 OperationRecorder recorder = new OperationRecorder(); 90 context.getParentContext().commitChangesInContext(context, recorder); 91 92 context.getObjectStore().objectsCommitted(); 95 96 return recorder.getDiffs(); 97 } 98 } 99 } 100 | Popular Tags |