HHH-11107 - Avoid creating a foreign key when a composite-id contains a many-to-one association for the envers schema.

This commit is contained in:
Chris Cranford 2016-10-11 11:52:48 -04:00
parent 501a1f4f9b
commit 68eb34960b
1 changed files with 8 additions and 0 deletions

View File

@ -126,6 +126,14 @@ public final class BasicMetadataGenerator {
final Element manyToOneElement = parent.addElement( mapper != null ? "many-to-one" : "key-many-to-one" );
manyToOneElement.addAttribute( "name", propertyAuditingData.getName() );
manyToOneElement.addAttribute( "class", type.getName() );
// HHH-11107
// Use FK hbm magic value 'none' to skip making foreign key constraints between the Envers
// schema and the base table schema when a @ManyToOne is present in an identifier.
if ( mapper == null ) {
manyToOneElement.addAttribute( "foreign-key", "none" );
}
MetadataTools.addColumns( manyToOneElement, value.getColumnIterator() );
// A null mapper means that we only want to add xml mappings