Buggy code:
public class StateManagerImpl implements Serializable , OpenJPAStateManager { public static final int LOAD_FGS = 0 ; public static final int LOAD_ALL = 1 ; public static final int LOAD_SERIALIZE = 2 ; private static final int FLAG_SAVE = 2 << 0 ; private static final int FLAG_DEREF = 2 << 1 ; private static final int FLAG_LOADED = 2 << 2 ; private static final int FLAG_READ_LOCKED = 2 << 3 ; private static final int FLAG_WRITE_LOCKED = 2 << 4 ; private static final int FLAG_OID_ASSIGNED = 2 << 5 ; private static final int FLAG_LOADING = 2 << 6 ; private static final int FLAG_PRE_DELETING = 2 << 7 ; private static final int FLAG_FLUSHED = 2 << 8 ; private static final int FLAG_PRE_FLUSHED = 2 << 9 ; private static final int FLAG_FLUSHED_DIRTY = 2 << 10 ; private static final int FLAG_IMPL_CACHE = 2 << 11 ; private static final int FLAG_INVERSES = 2 << 12 ; private static final int FLAG_NO_UNPROXY = 2 << 13 ; private static final int FLAG_VERSION_CHECK = 2 << 14 ; private static final int FLAG_VERSION_UPDATE = 2 << 15 ; private static final int FLAG_DETACHING = 2 << 16 ; private static final Localizer _loc = Localizer . forPackage ( StateManagerImpl . class ) ; private transient PersistenceCapable _pc = null ; private transient ClassMetaData _meta = null ; private BitSet _loaded = null ; private BitSet _dirty = null ; private BitSet _flush = null ; private int _flags = 0 ; private Object _id = null ; private Object _oid = null ; private transient BrokerImpl _broker ; private PCState _state = PCState . TRANSIENT ; private Object _version = null ; private Object _loadVersion = null ; private Object _lock = null ; private int _readLockLevel = - 1 ; private int _writeLockLevel = - 1 ; private SingleFieldManager _single = null ; private SaveFieldManager _saved = null ; private FieldManager _fm = null ; private Object _impl = null ; private Object [ ] _fieldImpl = null ; private StateManagerImpl _owner = null ; private int _ownerIndex = - 1 ; protected StateManagerImpl ( Object id , ClassMetaData meta , BrokerImpl broker ) { } void setOwner ( StateManagerImpl owner , ValueMetaData ownerMeta ) { } boolean isLoading ( ) { } void setLoading ( boolean loading ) { } private void setPCState ( PCState state ) { } public void initialize ( Class cls , PCState state ) { } protected void initialize ( PersistenceCapable pc , PCState state ) { } public boolean isIntercepting ( ) { } private boolean fireLifecycleEvent ( int type ) { } public void load ( FetchConfiguration fetch ) { } protected boolean load ( FetchConfiguration fetch , int loadMode , BitSet exclude , Object sdata , boolean forWrite ) { <START_BUG> if ( ( ! forWrite ) && ( ( ( ! ( isPersistent ( ) ) ) || ( isNew ( ) ) ) || ( isDeleted ( ) ) ) ) <END_BUG> return false ; BitSet fields = getUnloadedInternal ( fetch , loadMode , exclude ) ; boolean active = _broker . isActive ( ) ; if ( ( ! forWrite ) && ( fields != null ) ) beforeRead ( ( - 1 ) ) ; int lockLevel = calculateLockLevel ( active , forWrite , fetch ) ; boolean ret = loadFields ( fields , fetch , lockLevel , sdata ) ; obtainLocks ( active , forWrite , lockLevel , fetch , sdata ) ; return ret ; } public Object getManagedInstance ( ) { } public PersistenceCapable getPersistenceCapable ( ) { } public ClassMetaData getMetaData ( ) { } public OpenJPAStateManager getOwner ( ) { } public int getOwnerIndex ( ) { } public boolean isEmbedded ( ) { } public boolean isFlushed ( ) { } public boolean isFlushedDirty ( ) { } public BitSet getLoaded ( ) { } public BitSet getFlushed ( ) { } public BitSet getDirty ( ) { } public BitSet getUnloaded ( FetchConfiguration fetch ) { } private BitSet getUnloadedInternal ( FetchConfiguration fetch , int mode , BitSet exclude ) { } public StoreContext getContext ( ) { } BrokerImpl getBroker ( ) { } public Object getId ( ) { } public Object getObjectId ( ) { } public void setObjectId ( Object oid ) { } public boolean assignObjectId ( boolean flush ) { } private boolean assignObjectId ( boolean flush , boolean preFlushing ) { } private void assertObjectIdAssigned ( boolean recache ) { } private boolean assignField ( int field , boolean preFlushing ) { } public Object getLock ( ) { } public void setLock ( Object lock ) { } public Object getVersion ( ) { } public void setVersion ( Object version ) { } Object getLoadVersion ( ) { } public void setNextVersion ( Object version ) { } private void assignVersionField ( Object version ) { } public PCState getPCState ( ) { } public synchronized Object getImplData ( ) { } public synchronized Object setImplData ( Object data , boolean cacheable ) { } public boolean isImplDataCacheable ( ) { } public Object getImplData ( int field ) { } public Object setImplData ( int field , Object data ) { } public synchronized boolean isImplDataCacheable ( int field ) { } public Object getIntermediate ( int field ) { } public void setIntermediate ( int field , Object data ) { } private synchronized Object getExtraFieldData ( int field , boolean isLoaded ) { } private synchronized Object setExtraFieldData ( int field , Object data , boolean loaded ) { } public Object fetch ( int field ) { } public Object fetchField ( int field , boolean transitions ) { } public void store ( int field , Object val ) { } public void storeField ( int field , Object val ) { } public void dirtyCheck ( ) { }

Fix:
if ( ( ! forWrite ) && ( ( ( ! ( isPersistent ( ) ) ) || ( ( isNew ( ) ) && ( ! ( isFlushed ( ) ) ) ) ) || ( isDeleted ( ) ) ) )