Author: mbo Date: Thu Jul 21 07:19:45 2005 New Revision: 220088 URL: http://svn.apache.org/viewcvs?rev=220088&view=rev Log: Added StateManager method isBeforeImageRequired Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java?rev=220088&r1=220087&r2=220088&view=diff ============================================================================== --- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java (original) +++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/impl/state/StateManagerImpl.java Thu Jul 21 07:19:45 2005 @@ -679,6 +679,20 @@ return myLC.isNew(); } + /** + * Returns true, if a before image must be created. The + * decision is based on the current lifecycle state plus other conditions + * e.g. transaction type, restore values flag, etc. + * @see org.apache.jdo.state.StateManagerInternal#isBeforeImageRequired() + * @return true if a before image must be created. + */ + public boolean isBeforeImageRequired() { + boolean isTransientTransactional = + !myLC.isPersistent() && myLC.isTransactional(); + return (tx.getOptimistic() || tx.getRestoreValues() || + isTransientTransactional); + } + // // LifeCycleState transition requests // @@ -936,11 +950,8 @@ debug("createBeforeImage: new " + (beforeImage == null) + // NOI18N " Tx is active: " + tx.isActive()); // NOI18N - boolean isTransientTransactional = - !myLC.isPersistent() && myLC.isTransactional(); - if (beforeImage == null && tx.isActive() && - (tx.getOptimistic() || tx.getRestoreValues() || - isTransientTransactional)) { + if (beforeImage == null && tx.isActive() && + isBeforeImageRequired()) { beforeImage = jdoImplHelper.newInstance (myPCClass, this); int[] fields = getFieldNums(loadedFields); @@ -1349,11 +1360,7 @@ if (debugging()) debug("createBeforeImage"); // NOI18N - boolean isTransientTransactional = - !myLC.isPersistent() && myLC.isTransactional(); - if (tx.getOptimistic() || tx.getRestoreValues() || - isTransientTransactional) { - + if (isBeforeImageRequired()) { beforeImage = jdoImplHelper.newInstance (myPCClass, this); beforeImage.jdoCopyFields(myPC, getFieldNums(loadedFields)); biFields.or(loadedFields); Modified: incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java?rev=220088&r1=220087&r2=220088&view=diff ============================================================================== --- incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java (original) +++ incubator/jdo/trunk/runtime20/src/java/org/apache/jdo/state/StateManagerInternal.java Thu Jul 21 07:19:45 2005 @@ -272,4 +272,12 @@ */ public boolean isNew(); + /** + * Returns true, if a before image must be created. The + * decision is based on the current lifecycle state plus other conditions + * e.g. transaction type, restore values flag, etc. + * @return true if a before image must be created. + */ + public boolean isBeforeImageRequired(); + }