Buggy code:
public abstract class RelationToManyTableFieldStrategy extends StoreCollectionFieldStrategy { private static final Localizer _loc = Localizer . forPackage ( RelationToManyTableFieldStrategy . class ) ; protected ClassMapping [ ] getIndependentElementMappings ( boolean traverse ) { } protected ForeignKey getJoinForeignKey ( ClassMapping elem ) { } protected void selectElement ( Select sel , ClassMapping elem , JDBCStore store , JDBCFetchConfiguration fetch , int eagerMode , Joins joins ) { } protected Object loadElement ( OpenJPAStateManager sm , JDBCStore store , JDBCFetchConfiguration fetch , Result res , Joins joins ) throws SQLException { } protected Joins join ( Joins joins , ClassMapping elem ) { } protected Joins joinElementRelation ( Joins joins , ClassMapping elem ) { } public void map ( boolean adapt ) { field . getValueInfo ( ) . assertNoSchemaComponents ( field , ( ! adapt ) ) ; field . getKeyMapping ( ) . getValueInfo ( ) . assertNoSchemaComponents ( field . getKey ( ) , ( ! adapt ) ) ; ValueMapping elem = field . getElementMapping ( ) ; if ( ( ( elem . getTypeCode ( ) ) != ( JavaTypes . PC ) ) || ( elem . isEmbeddedPC ( ) ) ) throw new org . apache . openjpa . util . MetaDataException ( RelationToManyTableFieldStrategy . _loc . get ( "not-elem-relation" , field ) ) ; FieldMapping mapped = field . getMappedByMapping ( ) ; ValueMappingInfo vinfo = elem . getValueInfo ( ) ; boolean criteria = vinfo . getUseClassCriteria ( ) ; if ( mapped != null ) { if ( ( mapped . getElement ( ) . getTypeCode ( ) ) != ( JavaTypes . PC ) ) throw new org . apache . openjpa . util . MetaDataException ( RelationToManyTableFieldStrategy . _loc . get ( "not-inv-relation-coll" , field , mapped ) ) ; field . getMappingInfo ( ) . assertNoSchemaComponents ( field , ( ! adapt ) ) ; vinfo . assertNoSchemaComponents ( elem , ( ! adapt ) ) ; mapped . resolve ( ( ( mapped . MODE_META ) | ( mapped . MODE_MAPPING ) ) ) ; <START_BUG> if ( ! ( mapped . getDefiningMapping ( ) . isMapped ( ) ) ) <END_BUG> throw new org . apache . openjpa . util . MetaDataException ( RelationToManyTableFieldStrategy . _loc . get ( "mapped-by-unmapped" , field , mapped ) ) ; field . setJoinForeignKey ( mapped . getElementMapping ( ) . getForeignKey ( field . getDefiningMapping ( ) ) ) ; elem . setForeignKey ( mapped . getJoinForeignKey ( ) ) ; elem . setUseClassCriteria ( criteria ) ; field . setOrderColumn ( mapped . getOrderColumn ( ) ) ; return ; } field . mapJoin ( adapt , true ) ; if ( elem . getTypeMapping ( ) . isMapped ( ) ) { ForeignKey fk = vinfo . getTypeJoin ( elem , "element" , false , adapt ) ; elem . setForeignKey ( fk ) ; elem . setColumnIO ( vinfo . getColumnIO ( ) ) ; } else RelationStrategies . mapRelationToUnmappedPC ( elem , "element" , adapt ) ; elem . setUseClassCriteria ( criteria ) ; elem . mapConstraints ( "element" , adapt ) ; FieldMappingInfo finfo = field . getMappingInfo ( ) ; Column orderCol = finfo . getOrderColumn ( field , field . getTable ( ) , adapt ) ; field . setOrderColumn ( orderCol ) ; field . setOrderColumnIO ( finfo . getColumnIO ( ) ) ; field . mapPrimaryKey ( adapt ) ; } public void insert ( OpenJPAStateManager sm , JDBCStore store , RowManager rm ) throws SQLException { } private void insert ( OpenJPAStateManager sm , RowManager rm , Object vals ) throws SQLException { } public void update ( OpenJPAStateManager sm , JDBCStore store , RowManager rm ) throws SQLException { } public void delete ( OpenJPAStateManager sm , JDBCStore store , RowManager rm ) throws SQLException { } public Object toDataStoreValue ( Object val , JDBCStore store ) { } public Joins join ( Joins joins , boolean forceOuter ) { } public Joins joinRelation ( Joins joins , boolean forceOuter , boolean traverse ) { } }

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