Buggy code:
public class RelationFieldStrategy extends AbstractFieldStrategy implements Embeddable , Joinable { private static final Localizer _loc = Localizer . forPackage ( RelationFieldStrategy . class ) ; private Boolean _fkOid = null ; public void map ( boolean adapt ) { } private void setMappedByIdColumns ( ) { } private List getMappedByIdColumns ( FieldMapping pk ) { } private boolean isTypeUnjoinedSubclass ( ValueMapping mapped ) { } public void initialize ( ) { } public void insert ( OpenJPAStateManager sm , JDBCStore store , RowManager rm ) throws SQLException { } private void setMapKey ( OpenJPAStateManager sm , OpenJPAStateManager rel , JDBCStore store , Row row ) throws SQLException { } private FieldMapping getMapField ( ClassMetaData meta ) { } private Object getMapKeyObj ( Map mapObj , Object value ) { } public void update ( OpenJPAStateManager sm , JDBCStore store , RowManager rm ) throws SQLException { } public void delete ( OpenJPAStateManager sm , JDBCStore store , RowManager rm ) throws SQLException { } private void nullInverse ( OpenJPAStateManager sm , RowManager rm ) throws SQLException { } private void updateInverse ( OpenJPAStateManager sm , OpenJPAStateManager rel , JDBCStore store , RowManager rm ) throws SQLException { } public int supportsSelect ( Select sel , int type , OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch ) { } public void selectEagerParallel ( SelectExecutor sel , final OpenJPAStateManager sm , final JDBCStore store , final JDBCFetchConfiguration fetch , final int eagerMode ) { } private void selectEagerParallel ( Select sel , ClassMapping cls , JDBCStore store , JDBCFetchConfiguration fetch , int eagerMode ) { } public void selectEagerJoin ( Select sel , OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch , int eagerMode ) { } private Joins eagerJoin ( Joins joins , ClassMapping cls , boolean forceInner ) { } private Joins setEmbeddedVariable ( Joins joins ) { } public int select ( Select sel , OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch , int eagerMode ) { } public Object loadEagerParallel ( OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch , Object res ) throws SQLException { } private Map processEagerParallelResult ( OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch , Result res ) throws SQLException { } public void loadEagerJoin ( OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch , Result res ) throws SQLException { } public void load ( OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch , Result res ) throws SQLException { } public void load ( final OpenJPAStateManager sm , final JDBCStore store , final JDBCFetchConfiguration fetch ) throws SQLException { } public Object toDataStoreValue ( Object val , JDBCStore store ) { } public void appendIsNull ( SQLBuffer sql , Select sel , Joins joins ) { } public void appendIsNotNull ( SQLBuffer sql , Select sel , Joins joins ) { } private void testInverseNull ( SQLBuffer sql , Select sel , Joins joins , boolean empty ) { } public Joins join ( Joins joins , boolean forceOuter ) { } public Joins joinRelation ( Joins joins , boolean forceOuter , boolean traverse ) { } public int getFieldIndex ( ) { } public Object getPrimaryKeyValue ( Result res , Column [ ] cols , ForeignKey fk , JDBCStore store , Joins joins ) throws SQLException { } private ForeignKey createTranslatingForeignKey ( ClassMapping relmapping , Column [ ] gcols , ForeignKey gfk ) { } public Object getJoinValue ( Object fieldVal , Column col , JDBCStore store ) { Object o = field . getForeignKey ( ) . getConstant ( col ) ; if ( o != null ) return o ; col = field . getForeignKey ( ) . getPrimaryKeyColumn ( col ) ; if ( col == null ) throw new InternalException ( ) ; ClassMapping relmapping = field . getTypeMapping ( ) ; Joinable j = field . getTypeMapping ( ) . assertJoinable ( col ) ; <START_BUG> if ( ImplHelper . isManageable ( fieldVal ) ) <END_BUG> fieldVal = store . getContext ( ) . getObjectId ( fieldVal ) ; if ( fieldVal instanceof OpenJPAId ) fieldVal = ( ( OpenJPAId ) ( fieldVal ) ) . getIdObject ( ) ; if ( ( ( relmapping . getObjectIdType ( ) ) != null ) && ( relmapping . getObjectIdType ( ) . isInstance ( fieldVal ) ) ) { Object [ ] pks = ApplicationIds . toPKValues ( fieldVal , relmapping ) ; fieldVal = pks [ relmapping . getField ( j . getFieldIndex ( ) ) . getPrimaryKeyIndex ( ) ] ; } return j . getJoinValue ( fieldVal , col , store ) ; } public Object getJoinValue ( OpenJPAStateManager sm , Column col , JDBCStore store ) { } public void setAutoAssignedValue ( OpenJPAStateManager sm , JDBCStore store , Column col , Object autoInc ) { } public Column [ ] getColumns ( ) { } public ColumnIO getColumnIO ( ) { } public Object [ ] getResultArguments ( ) { } public Object toEmbeddedDataStoreValue ( Object val , JDBCStore store ) { } public Object toEmbeddedObjectValue ( Object val ) { } public void loadEmbedded ( OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch , Object val ) throws SQLException { } }

Fix:
if ( ( ImplHelper . isManageable ( fieldVal ) ) && ( ! ( field . getDefiningMetaData ( ) . useIdClassFromParent ( ) ) ) )