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 boolean isTypeUnjoinedSubclass ( ValueMapping mapped ) { } public void initialize ( ) { } public void insert ( OpenJPAStateManager sm , JDBCStore store , RowManager rm ) throws SQLException { } 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 { if ( Boolean . TRUE . equals ( _fkOid ) ) { Object oid = sm . getIntermediate ( field . getIndex ( ) ) ; if ( oid != null ) { Object val = store . find ( oid , field , fetch ) ; sm . storeObject ( field . getIndex ( ) , val ) ; return ; } } final ClassMapping [ ] rels = field . getIndependentTypeMappings ( ) ; final int subs = field . getSelectSubclasses ( ) ; final Joins [ ] resJoins = new Joins [ rels . length ] ; Union union = store . getSQLFactory ( ) . newUnion ( rels . length ) ; <START_BUG> union . setSingleResult ( true ) ; <END_BUG> if ( ( fetch . getSubclassFetchMode ( field . getTypeMapping ( ) ) ) != ( JDBCFetchConfiguration . EAGER_JOIN ) ) union . abortUnion ( ) ; union . select ( new Union . Selector ( ) { public void select ( Select sel , int idx ) { if ( ( field . getJoinDirection ( ) ) == ( field . JOIN_INVERSE ) ) sel . whereForeignKey ( field . getForeignKey ( rels [ idx ] ) , sm . getObjectId ( ) , field . getDefiningMapping ( ) , store ) ; else { resJoins [ idx ] = sel . newJoins ( ) . joinRelation ( field . getName ( ) , field . getForeignKey ( rels [ idx ] ) , rels [ idx ] , field . getSelectSubclasses ( ) , false , false ) ; field . wherePrimaryKey ( sel , sm , store ) ; } sel . select ( rels [ idx ] , subs , store , fetch , fetch . EAGER_JOIN , resJoins [ idx ] ) ; } } ) ; Result res = union . execute ( store , fetch ) ; try { Object val = null ; if ( res . next ( ) ) val = res . load ( rels [ res . indexOf ( ) ] , store , fetch , resJoins [ res . indexOf ( ) ] ) ; sm . storeObject ( field . getIndex ( ) , val ) ; } finally { res . close ( ) ; } } 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 ) { } 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 ) { }

Fix:
union . setExpectedResultCount ( 1 , true ) ;