Buggy code:
protected ClassMetaData newEmbeddedClassMetaData ( ValueMetaData owner ) { } protected ValueMetaData newValueMetaData ( FieldMetaData owner ) { } protected SequenceMetaData newSequenceMetaData ( String name ) { } protected Order newValueOrder ( FieldMetaData owner , boolean asc ) { } protected Order newRelatedFieldOrder ( FieldMetaData owner , FieldMetaData rel , boolean asc ) { } protected Order [ ] newOrderArray ( int size ) { } protected Version newVersion ( ClassMapping cls ) { } protected Discriminator newDiscriminator ( ClassMapping cls ) { } protected ClassMappingInfo newMappingInfo ( ClassMapping cls ) { } protected FieldMappingInfo newMappingInfo ( FieldMapping fm ) { } protected ValueMappingInfo newMappingInfo ( ValueMapping vm ) { } protected VersionMappingInfo newMappingInfo ( Version version ) { } protected DiscriminatorMappingInfo newMappingInfo ( Discriminator disc ) { } protected ClassStrategy namedStrategy ( ClassMapping cls ) { } protected ClassStrategy instantiateClassStrategy ( String name , ClassMapping cls ) { } protected FieldStrategy namedStrategy ( FieldMapping field , boolean installHandlers ) { } protected DiscriminatorStrategy namedStrategy ( Discriminator discrim ) { } protected DiscriminatorStrategy instantiateDiscriminatorStrategy ( String name , Discriminator discrim ) { } protected VersionStrategy namedStrategy ( Version version ) { } protected VersionStrategy instantiateVersionStrategy ( String name , Version version ) { } protected VersionStrategy instantiateVersionStrategy ( Class strat , Version version , String props ) { } protected ClassStrategy defaultStrategy ( ClassMapping cls ) { } protected ClassStrategy defaultStrategy ( ClassMapping cls , boolean adapting ) { } protected FieldStrategy defaultStrategy ( FieldMapping field , boolean installHandlers ) { } protected FieldStrategy defaultStrategy ( FieldMapping field , boolean installHandlers , boolean adapting ) { } protected FieldStrategy defaultTypeStrategy ( FieldMapping field , boolean installHandlers , boolean adapting ) { switch ( field . getTypeCode ( ) ) { case JavaTypes . BOOLEAN : case JavaTypes . BYTE : case JavaTypes . CHAR : case JavaTypes . DOUBLE : case JavaTypes . FLOAT : case JavaTypes . INT : case JavaTypes . LONG : case JavaTypes . SHORT : return new PrimitiveFieldStrategy ( ) ; case JavaTypes . STRING : if ( ! ( isClob ( field , false ) ) ) return new StringFieldStrategy ( ) ; if ( ( _dict . maxEmbeddedClobSize ) != ( - 1 ) ) return new MaxEmbeddedClobFieldStrategy ( ) ; break ; case JavaTypes . PC : if ( field . isEmbeddedPC ( ) ) return new EmbedFieldStrategy ( ) ; if ( ( field . getTypeMapping ( ) . isMapped ( ) ) || ( ! ( useUntypedPCHandler ( field ) ) ) ) return new RelationFieldStrategy ( ) ; break ; case JavaTypes . ARRAY : case JavaTypes . COLLECTION : ValueMapping elem = field . getElementMapping ( ) ; ValueHandler ehandler = namedHandler ( elem ) ; if ( ehandler == null ) ehandler = defaultHandler ( elem ) ; if ( ehandler != null ) return handlerCollectionStrategy ( field , ehandler , installHandlers ) ; if ( ( ( ( elem . getTypeCode ( ) ) == ( JavaTypes . PC ) ) && ( ! ( elem . isSerialized ( ) ) ) ) && ( ! ( elem . isEmbeddedPC ( ) ) ) ) { if ( useInverseKeyMapping ( field ) ) return new RelationCollectionInverseKeyFieldStrategy ( ) ; return new RelationCollectionTableFieldStrategy ( ) ; } break ; case JavaTypes . MAP : ValueMapping key = field . getKeyMapping ( ) ; ValueHandler khandler = namedHandler ( key ) ; if ( khandler == null ) khandler = defaultHandler ( key ) ; ValueMapping val = field . getElementMapping ( ) ; ValueHandler vhandler = namedHandler ( val ) ; if ( vhandler == null ) vhandler = defaultHandler ( val ) ; boolean krel = ( ( ( khandler == null ) && ( ( key . getTypeCode ( ) ) == ( JavaTypes . PC ) ) ) && ( ! ( key . isSerialized ( ) ) ) ) && ( ! ( key . isEmbeddedPC ( ) ) ) ; boolean vrel = ( ( ( vhandler == null ) && ( ( val . getTypeCode ( ) ) == ( JavaTypes . PC ) ) ) && ( ! ( val . isSerialized ( ) ) ) ) && ( ! ( val . isEmbeddedPC ( ) ) ) ; <START_BUG> if ( ( ( ! krel ) && vrel ) && ( ( key . getValueMappedBy ( ) ) != null ) ) { <END_BUG> if ( useInverseKeyMapping ( field ) ) return new RelationMapInverseKeyFieldStrategy ( ) ; return new RelationMapTableFieldStrategy ( ) ; } if ( ( ! krel ) && ( khandler == null ) ) break ; if ( ( ! vrel ) && ( vhandler == null ) ) break ; return handlerMapStrategy ( field , khandler , vhandler , krel , vrel , installHandlers ) ; case JavaTypes . INPUT_STREAM : case JavaTypes . INPUT_READER : return new LobFieldStrategy ( ) ; } return null ; } protected FieldStrategy handlerCollectionStrategy ( FieldMapping field , ValueHandler ehandler , boolean installHandlers ) { } protected FieldStrategy handlerMapStrategy ( FieldMapping field , ValueHandler khandler , ValueHandler vhandler , boolean krel , boolean vrel , boolean installHandlers ) { } private boolean useInverseKeyMapping ( FieldMapping field ) { } private Object mappedStrategy ( ValueMapping val , Class type , boolean adapting ) { } protected ValueHandler namedHandler ( ValueMapping val ) { } protected ValueHandler defaultHandler ( ValueMapping val ) { } protected ValueHandler defaultHandler ( ValueMapping val , boolean adapting ) { } private boolean useUntypedPCHandler ( ValueMapping val ) { } private boolean isClob ( ValueMapping val , boolean warn ) { } private void warnMaxEmbedded ( ValueMapping val , int size ) { } protected DiscriminatorStrategy defaultStrategy ( Discriminator discrim ) { } protected DiscriminatorStrategy defaultStrategy ( Discriminator discrim , boolean adapting ) { } protected VersionStrategy defaultStrategy ( Version version ) { } protected VersionStrategy defaultStrategy ( Version version , boolean adapting ) { }

Fix:
if ( vrel && ( ( key . getValueMappedBy ( ) ) != null ) ) {