Buggy code:
class VersionAttachStrategy extends AttachStrategy implements DetachState { private static final Localizer _loc = Localizer . forPackage ( VersionAttachStrategy . class ) ; protected Object getDetachedObjectId ( AttachManager manager , Object toAttach ) { } protected void provideField ( Object toAttach , StateManagerImpl sm , int field ) { } public Object attach ( AttachManager manager , Object toAttach , ClassMetaData meta , PersistenceCapable into , OpenJPAStateManager owner , ValueMetaData ownerMeta , boolean explicit ) { BrokerImpl broker = manager . getBroker ( ) ; PersistenceCapable pc = ( ( PersistenceCapable ) ( toAttach ) ) ; boolean embedded = ( ownerMeta != null ) && ( ownerMeta . isEmbeddedPC ( ) ) ; boolean isNew = ! ( broker . isDetached ( pc ) ) ; Object version = null ; StateManagerImpl sm = null ; if ( embedded && ( ( isNew || ( into == null ) ) || ( ( broker . getStateManager ( into ) ) == null ) ) ) { if ( into == null ) into = pc . pcNewInstance ( null , false ) ; sm = ( ( StateManagerImpl ) ( broker . embed ( into , null , owner , ownerMeta ) ) ) ; into = sm . getPersistenceCapable ( ) ; } else if ( isNew ) { sm = persist ( manager , pc , meta , ApplicationIds . create ( pc , meta ) , explicit ) ; into = sm . getPersistenceCapable ( ) ; } else if ( ( ! embedded ) && ( into == null ) ) { Object id = getDetachedObjectId ( manager , toAttach ) ; if ( id != null ) into = ( ( PersistenceCapable ) ( broker . find ( id , true , null ) ) ) ; if ( into == null ) throw new org . apache . openjpa . util . OptimisticException ( VersionAttachStrategy . _loc . get ( "attach-version-del" , pc . getClass ( ) , id , version ) ) . setFailedObject ( toAttach ) ; sm = manager . assertManaged ( into ) ; if ( ( meta . getDescribedType ( ) ) != ( sm . getMetaData ( ) . getDescribedType ( ) ) ) { throw new org . apache . openjpa . util . ObjectNotFoundException ( VersionAttachStrategy . _loc . get ( "attach-wrongclass" , id , toAttach . getClass ( ) , sm . getMetaData ( ) . getDescribedType ( ) ) ) . setFailedObject ( toAttach ) ; } } else sm = manager . assertManaged ( into ) ; manager . setAttachedCopy ( toAttach , into ) ; if ( pc == into ) { attachFieldsInPlace ( manager , sm ) ; return into ; } manager . fireBeforeAttach ( toAttach , meta ) ; StateManager smBefore = pc . pcGetStateManager ( ) ; pc . pcReplaceStateManager ( sm ) ; int detach = ( isNew ) ? DETACH_ALL : broker . getDetachState ( ) ; FetchConfiguration fetch = broker . getFetchConfiguration ( ) ; try { FieldMetaData [ ] fmds = meta . getFields ( ) ; for ( int i = 0 ; i < ( fmds . length ) ; i ++ ) { switch ( detach ) { case DETACH_ALL : attachField ( manager , toAttach , sm , fmds [ i ] , true ) ; break ; <START_BUG> case DETACH_FGS : <END_BUG> if ( ( fetch . requiresFetch ( fmds [ i ] ) ) != ( FetchConfiguration . FETCH_NONE ) ) attachField ( manager , toAttach , sm , fmds [ i ] , true ) ; break ; case DETACH_LOADED : attachField ( manager , toAttach , sm , fmds [ i ] , false ) ; break ; } } } finally { pc . pcReplaceStateManager ( smBefore ) ; } if ( ( ! embedded ) && ( ! isNew ) ) compareVersion ( sm , pc ) ; return into ; } private void compareVersion ( StateManagerImpl sm , PersistenceCapable pc ) { } private void attachFieldsInPlace ( AttachManager manager , StateManagerImpl sm ) { } private Object attachInPlace ( AttachManager manager , StateManagerImpl sm , ValueMetaData vmd , Object pc ) { } private Object [ ] attachInPlace ( AttachManager manager , StateManagerImpl sm , FieldMetaData fmd , Object [ ] arr ) { } private Collection attachInPlace ( AttachManager manager , StateManagerImpl sm , FieldMetaData fmd , Collection coll ) { } private Map attachInPlace ( AttachManager manager , StateManagerImpl sm , FieldMetaData fmd , Map map ) { } }

Fix:
case DETACH_FETCH_GROUPS :