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 ) { if ( ( ( field . getTypeCode ( ) ) != ( JavaTypes . PC ) ) || ( field . isEmbeddedPC ( ) ) ) throw new org . apache . openjpa . util . MetaDataException ( RelationFieldStrategy . _loc . get ( "not-relation" , field ) ) ; field . getKeyMapping ( ) . getValueInfo ( ) . assertNoSchemaComponents ( field . getKey ( ) , ( ! adapt ) ) ; field . getElementMapping ( ) . getValueInfo ( ) . assertNoSchemaComponents ( field . getElement ( ) , ( ! adapt ) ) ; boolean criteria = field . getValueInfo ( ) . getUseClassCriteria ( ) ; FieldMapping mapped = field . getMappedByMapping ( ) ; if ( mapped != null ) { field . getMappingInfo ( ) . assertNoSchemaComponents ( field , ( ! adapt ) ) ; field . getValueInfo ( ) . assertNoSchemaComponents ( field , ( ! adapt ) ) ; mapped . resolve ( ( ( mapped . MODE_META ) | ( mapped . MODE_MAPPING ) ) ) ; <START_BUG> if ( ! ( mapped . getDefiningMapping ( ) . isMapped ( ) ) ) <END_BUG> throw new org . apache . openjpa . util . MetaDataException ( RelationFieldStrategy . _loc . get ( "mapped-by-unmapped" , field , mapped ) ) ; if ( ( mapped . getTypeCode ( ) ) == ( JavaTypes . PC ) ) { if ( ( mapped . getJoinDirection ( ) ) == ( mapped . JOIN_FORWARD ) ) { field . setJoinDirection ( JOIN_INVERSE ) ; field . setColumns ( mapped . getDefiningMapping ( ) . getPrimaryKeyColumns ( ) ) ; } else if ( isTypeUnjoinedSubclass ( mapped ) ) throw new org . apache . openjpa . util . MetaDataException ( RelationFieldStrategy . _loc . get ( "mapped-inverse-unjoined" , field . getName ( ) , field . getDefiningMapping ( ) , mapped ) ) ; field . setForeignKey ( mapped . getForeignKey ( field . getDefiningMapping ( ) ) ) ; } else if ( ( mapped . getElement ( ) . getTypeCode ( ) ) == ( JavaTypes . PC ) ) { if ( isTypeUnjoinedSubclass ( mapped . getElementMapping ( ) ) ) throw new org . apache . openjpa . util . MetaDataException ( RelationFieldStrategy . _loc . get ( "mapped-inverse-unjoined" , field . getName ( ) , field . getDefiningMapping ( ) , mapped ) ) ; Log log = field . getRepository ( ) . getLog ( ) ; if ( log . isInfoEnabled ( ) ) log . info ( RelationFieldStrategy . _loc . get ( "coll-owner" , field , mapped ) ) ; field . setForeignKey ( mapped . getElementMapping ( ) . getForeignKey ( ) ) ; } else throw new org . apache . openjpa . util . MetaDataException ( RelationFieldStrategy . _loc . get ( "not-inv-relation" , field , mapped ) ) ; field . setUseClassCriteria ( criteria ) ; return ; } String tableName = field . getMappingInfo ( ) . getTableName ( ) ; Table table = field . getTypeMapping ( ) . getTable ( ) ; ValueMappingInfo vinfo = field . getValueInfo ( ) ; if ( ( ( tableName != null ) && ( table != null ) ) && ( ( tableName . equalsIgnoreCase ( table . getName ( ) ) ) || ( tableName . equalsIgnoreCase ( table . getFullName ( ) ) ) ) ) { vinfo . setJoinDirection ( MappingInfo . JOIN_INVERSE ) ; vinfo . setColumns ( field . getMappingInfo ( ) . getColumns ( ) ) ; field . getMappingInfo ( ) . setTableName ( null ) ; field . getMappingInfo ( ) . setColumns ( null ) ; } field . mapJoin ( adapt , false ) ; if ( field . getTypeMapping ( ) . isMapped ( ) ) { ForeignKey fk = vinfo . getTypeJoin ( field , field . getName ( ) , true , adapt ) ; field . setForeignKey ( fk ) ; field . setColumnIO ( vinfo . getColumnIO ( ) ) ; if ( ( vinfo . getJoinDirection ( ) ) == ( vinfo . JOIN_INVERSE ) ) field . setJoinDirection ( JOIN_INVERSE ) ; } else RelationStrategies . mapRelationToUnmappedPC ( field , field . getName ( ) , adapt ) ; field . setUseClassCriteria ( criteria ) ; field . mapPrimaryKey ( adapt ) ; PrimaryKey pk = field . getTable ( ) . getPrimaryKey ( ) ; if ( field . isPrimaryKey ( ) ) { Column [ ] cols = field . getColumns ( ) ; if ( ( pk != null ) && ( adapt || ( pk . isLogical ( ) ) ) ) for ( int i = 0 ; i < ( cols . length ) ; i ++ ) pk . addColumn ( cols [ i ] ) ; for ( int i = 0 ; i < ( cols . length ) ; i ++ ) field . getDefiningMapping ( ) . setJoinable ( cols [ i ] , this ) ; } field . mapConstraints ( field . getName ( ) , 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 { }

Fix:
if ( ( ! ( mapped . isMapped ( ) ) ) || ( mapped . isSerialized ( ) ) )