HHH-1904 Hash the natural id unique key names

This commit is contained in:
Brett Meyer 2013-03-21 15:57:43 -04:00
parent 721016cccb
commit 06ab065272
2 changed files with 4 additions and 3 deletions

View File

@ -155,6 +155,7 @@ import org.hibernate.id.SequenceHiLoGenerator;
import org.hibernate.id.TableHiLoGenerator;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
@ -2097,12 +2098,12 @@ public final class AnnotationBinder {
if ( naturalIdAnn != null ) {
if ( joinColumns != null ) {
for ( Ejb3Column column : joinColumns ) {
column.addUniqueKey( "_UniqueKey", inSecondPass );
column.addUniqueKey( StringHelper.randomFixedLengthHex("UK_"), inSecondPass );
}
}
else {
for ( Ejb3Column column : columns ) {
column.addUniqueKey( "_UniqueKey", inSecondPass );
column.addUniqueKey( StringHelper.randomFixedLengthHex("UK_"), inSecondPass );
}
}
}

View File

@ -2247,7 +2247,7 @@ public final class HbmBinder {
}
else if ( "natural-id".equals( name ) ) {
UniqueKey uk = new UniqueKey();
uk.setName("_UniqueKey");
uk.setName(StringHelper.randomFixedLengthHex("UK_"));
uk.setTable(table);
//by default, natural-ids are "immutable" (constant)
boolean mutableId = "true".equals( subnode.attributeValue("mutable") );