Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

HHH-1904 Hash the natural id unique key names

  • Loading branch information...
commit 06ab065272d79ca6fe9c90da64b2e35059118a65 1 parent 721016c
@brmeyer brmeyer authored
View
5 hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
@@ -155,6 +155,7 @@
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 @@ else if ( !isId || !entityBinder.isIgnoreIdAnnotations() ) {
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
2  hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
@@ -2247,7 +2247,7 @@ else if ( "filter".equals( name ) ) {
}
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") );
Please sign in to comment.
Something went wrong with that request. Please try again.