Buggy code:
public abstract class AttributeValue extends BaseAttributeValue implements Persistent { private Transaction transaction ; private NumberKey oldOptionId ; private NumberKey oldUserId ; private String oldValue ; private int oldNumericValue ; private boolean oldOptionIdIsSet ; private boolean oldUserIdIsSet ; private boolean oldValueIsSet ; private boolean oldNumericValueIsSet ; private AttributeValue chainedValue ; private static String className = "AttributeValue" ; protected AttributeValue ( ) { } public AttributeValue getChainedValue ( ) { } public void setChainedValue ( AttributeValue v ) throws Exception { } public List getValueList ( ) { } public void setAttributeId ( NumberKey nk ) throws TorqueException { } public void setIssueId ( NumberKey nk ) throws TorqueException { } public void startTransaction ( Transaction transaction ) throws ScarabException { } private void endTransaction ( ) { } private void checkTransaction ( String errorMessage ) throws ScarabException { } public String getQueryKey ( ) { } public String toString ( ) { } public String getOptionIdAsString ( ) { } public void setOptionId ( NumberKey optionId ) throws TorqueException { } public void setNumericValue ( int v ) { } protected void setOptionIdOnly ( NumberKey optionId ) throws TorqueException { if ( ! ( Objects . equals ( optionId , getOptionId ( ) ) ) ) { <START_BUG> if ( ( ! ( isNew ( ) ) ) && ( ! ( oldOptionIdIsSet ) ) ) { <END_BUG> oldOptionId = new NumberKey ( getOptionId ( ) ) ; oldOptionIdIsSet = true ; } super . setOptionId ( optionId ) ; } } public void setUserId ( NumberKey userId ) throws TorqueException { } protected void setUserIdOnly ( NumberKey value ) throws TorqueException { } public NumberKey [ ] getOptionIds ( ) throws Exception { } public void setOptionIds ( NumberKey [ ] ids ) throws Exception { } public NumberKey [ ] getUserIds ( ) throws Exception { } public void setUserIds ( NumberKey [ ] ids ) throws Exception { } public void setValue ( String value ) { } protected void setValueOnly ( String value ) { } public boolean isRequired ( ) throws Exception { } public boolean isSet ( ) { } public RModuleAttribute getRModuleAttribute ( ) throws Exception { } public AttributeOption getAttributeOption ( ) throws TorqueException { } public boolean isQuickSearchAttribute ( ) throws Exception { } static String getCacheKey ( ObjectKey key ) { } public static AttributeValue getNewInstance ( RModuleAttribute rma , Issue issue ) throws TorqueException { } public static AttributeValue getNewInstance ( ObjectKey attId , Issue issue ) throws TorqueException { } public static synchronized AttributeValue getNewInstance ( Attribute attribute , Issue issue ) throws TorqueException { } protected abstract Object loadResources ( ) throws Exception { } protected abstract void setResources ( Object resources ) { } public abstract void init ( ) throws Exception { } public boolean supportsVoting ( ) { } public AttributeValue copy ( ) throws TorqueException { } public void save ( DBConnection dbcon ) throws TorqueException { } private String getActivityDescription ( ) throws TorqueException { } }

Fix:
if ( ( ( ! ( isNew ( ) ) ) && ( ! ( oldOptionIdIsSet ) ) ) && ( ( getOptionId ( ) ) != null ) ) {