Buggy code:
public class JDBCStoreManager implements JDBCStore , StoreManager { private static final Localizer _loc = Localizer . forPackage ( JDBCStoreManager . class ) ; private StoreContext _ctx = null ; private JDBCConfiguration _conf = null ; private DBDictionary _dict = null ; private SQLFactory _sql = null ; private JDBCLockManager _lm = null ; private DataSource _ds = null ; private JDBCStoreManager . RefCountConnection _conn = null ; private boolean _active = false ; private Set < Statement > _stmnts = Collections . synchronizedSet ( new HashSet < Statement > ( ) ) ; private static final Constructor < JDBCStoreManager . ClientConnection > clientConnectionImpl ; private static final Constructor < JDBCStoreManager . RefCountConnection > refCountConnectionImpl ; private static final Constructor < JDBCStoreManager . CancelStatement > cancelStatementImpl ; private static final Constructor < JDBCStoreManager . CancelPreparedStatement > cancelPreparedStatementImpl ; public StoreContext getContext ( ) { } public void setContext ( StoreContext ctx ) { } public void setContext ( StoreContext ctx , JDBCConfiguration conf ) { } public JDBCConfiguration getConfiguration ( ) { } public DBDictionary getDBDictionary ( ) { } public SQLFactory getSQLFactory ( ) { } public JDBCLockManager getLockManager ( ) { } public JDBCFetchConfiguration getFetchConfiguration ( ) { } public void beginOptimistic ( ) { } public void rollbackOptimistic ( ) { } public void begin ( ) { } public void commit ( ) { } public void rollback ( ) { } public void retainConnection ( ) { } public void releaseConnection ( ) { } public Object getClientConnection ( ) { } public Connection getConnection ( ) { } protected DataSource getDataSource ( ) { } public boolean exists ( OpenJPAStateManager sm , Object context ) { } private boolean exists ( ClassMapping mapping , Object oid , Object context ) { } public boolean syncVersion ( OpenJPAStateManager sm , Object context ) { } public int compareVersion ( OpenJPAStateManager state , Object v1 , Object v2 ) { } public boolean initialize ( OpenJPAStateManager sm , PCState state , FetchConfiguration fetch , Object context ) { } protected boolean initializeState ( OpenJPAStateManager sm , PCState state , JDBCFetchConfiguration fetch , ConnectionInfo info ) throws ClassNotFoundException , SQLException { } private void setInverseRelation ( OpenJPAStateManager owner , ClassMapping mapping , Result res ) { FieldMapping [ ] fms = mapping . getFieldMappings ( ) ; for ( int i = 0 ; i < ( fms . length ) ; i ++ ) { if ( ( res . getEager ( fms [ i ] ) ) != null ) { <START_BUG> if ( ( fms [ i ] . isElementCollection ( ) ) && ( ! ( fms [ i ] . getElement ( ) . isTypePC ( ) ) ) ) <END_BUG> continue ; Object coll = owner . fetchObject ( fms [ i ] . getIndex ( ) ) ; if ( coll instanceof Map ) coll = ( ( Map ) ( coll ) ) . values ( ) ; if ( ( coll instanceof Collection < ? > ) && ( ( ( ( Collection < ? > ) ( coll ) ) . size ( ) ) > 0 ) ) { for ( Iterator < ? > itr = ( ( Collection < ? > ) ( coll ) ) . iterator ( ) ; itr . hasNext ( ) ; ) { PersistenceCapable pc = ( ( PersistenceCapable ) ( itr . next ( ) ) ) ; if ( pc == null ) continue ; OpenJPAStateManager sm = ( ( OpenJPAStateManager ) ( pc . pcGetStateManager ( ) ) ) ; FieldMapping [ ] fmd = ( ( ClassMapping ) ( sm . getMetaData ( ) ) ) . getFieldMappings ( ) ; for ( int j = 0 ; j < ( fmd . length ) ; j ++ ) { Object oid = sm . getIntermediate ( fmd [ j ] . getIndex ( ) ) ; if ( ( oid != null ) && ( oid . equals ( owner . getObjectId ( ) ) ) ) { sm . storeObject ( fmd [ j ] . getIndex ( ) , owner . getPersistenceCapable ( ) ) ; break ; } } } } } } } protected void setMappedBy ( OpenJPAStateManager sm , FieldMapping mappedByFieldMapping , Object mappedByObject ) { } protected void getVersion ( ClassMapping mapping , OpenJPAStateManager sm , Result res ) throws SQLException { } protected boolean isEmptyResult ( Result res ) throws SQLException { } protected Class < ? > getType ( Result res , ClassMapping mapping ) { } private Boolean customLoad ( OpenJPAStateManager sm , ClassMapping mapping , PCState state , JDBCFetchConfiguration fetch ) throws ClassNotFoundException , SQLException { } private Result getInitializeStateResult ( OpenJPAStateManager sm , ClassMapping mapping , JDBCFetchConfiguration fetch , int subs ) throws SQLException { } private Result getInitializeStateUnionResult ( final OpenJPAStateManager sm , ClassMapping mapping , final ClassMapping [ ] mappings , final JDBCFetchConfiguration fetch ) throws SQLException { } private boolean selectPrimaryKey ( OpenJPAStateManager sm , ClassMapping mapping , JDBCFetchConfiguration fetch ) throws SQLException { } public boolean load ( OpenJPAStateManager sm , BitSet fields , FetchConfiguration fetch , int lockLevel , Object context ) { } private void removeLoadedFields ( OpenJPAStateManager sm , BitSet fields ) { } public Collection loadAll ( Collection sms , PCState state , int load , FetchConfiguration fetch , Object context ) { } public void beforeStateChange ( OpenJPAStateManager sm , PCState fromState , PCState toState ) { } public Collection flush ( Collection sms ) { } public boolean cancelAll ( ) { } public boolean assignObjectId ( OpenJPAStateManager sm , boolean preFlush ) { } public boolean assignField ( OpenJPAStateManager sm , int field , boolean preFlush ) { } public Class < ? > getManagedType ( Object oid ) { } public Class < ? > getDataStoreIdType ( ClassMetaData meta ) { }

Fix:
if ( ! ( fms [ i ] . getElement ( ) . isTypePC ( ) ) )