Skip to content

Commit 030f442

Browse files
dreab8sebersole
authored andcommitted
HHH-10372 - Fix Sequence generator for idbag ignores generator parameters
1 parent a9e4eb4 commit 030f442

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/IdentifierGeneratorDefinition.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public IdentifierGeneratorDefinition(
3939
}
4040
}
4141

42+
public IdentifierGeneratorDefinition(
43+
final String name,
44+
final Map<String, String> parameters) {
45+
this( name, name, parameters );
46+
}
47+
4248
public IdentifierGeneratorDefinition(String name) {
4349
this( name, name );
4450
}

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3386,7 +3386,7 @@ public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
33863386

33873387
makeIdentifier(
33883388
mappingDocument,
3389-
new IdentifierGeneratorDefinition( idSource.getGeneratorName() ),
3389+
new IdentifierGeneratorDefinition( idSource.getGeneratorName(), idSource.getParameters() ),
33903390
null,
33913391
idBinding
33923392
);

hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/PluralAttributeSourceIdBagImpl.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
*/
77
package org.hibernate.boot.model.source.internal.hbm;
88

9+
import java.util.Collections;
910
import java.util.List;
1011
import java.util.Locale;
12+
import java.util.Map;
1113

1214
import org.hibernate.boot.MappingException;
1315
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmIdBagCollectionType;
@@ -19,6 +21,7 @@
1921
import org.hibernate.boot.model.source.spi.RelationalValueSource;
2022
import org.hibernate.boot.model.source.spi.SizeSource;
2123
import org.hibernate.internal.util.StringHelper;
24+
import org.hibernate.internal.util.collections.CollectionHelper;
2225

2326
/**
2427
* @author Steve Ebersole
@@ -81,10 +84,12 @@ public List getColumnOrFormulaElements() {
8184
);
8285
}
8386

87+
8488
this.collectionIdSource = new CollectionIdSourceImpl(
8589
(ColumnSource) collectionIdRelationalValueSource,
8690
new HibernateTypeSourceImpl( idBagMapping.getCollectionId().getType() ),
87-
idBagMapping.getCollectionId().getGenerator().getClazz()
91+
idBagMapping.getCollectionId().getGenerator().getClazz(),
92+
Helper.extractParameters( idBagMapping.getCollectionId().getGenerator().getConfigParameters() )
8893
);
8994
}
9095

@@ -122,14 +127,22 @@ private static class CollectionIdSourceImpl implements CollectionIdSource {
122127
private final ColumnSource columnSource;
123128
private final HibernateTypeSourceImpl typeSource;
124129
private final String generator;
130+
private final Map<String, String> parameters;
125131

126132
public CollectionIdSourceImpl(
127133
ColumnSource columnSource,
128134
HibernateTypeSourceImpl typeSource,
129-
String generator) {
135+
String generator,
136+
final Map<String, String> parameters) {
130137
this.columnSource = columnSource;
131138
this.typeSource = typeSource;
132139
this.generator = generator;
140+
if ( CollectionHelper.isEmpty( parameters ) ) {
141+
this.parameters = Collections.emptyMap();
142+
}
143+
else {
144+
this.parameters = Collections.unmodifiableMap( parameters );
145+
}
133146
}
134147

135148
@Override
@@ -146,5 +159,9 @@ public HibernateTypeSourceImpl getTypeInformation() {
146159
public String getGeneratorName() {
147160
return generator;
148161
}
162+
163+
public Map<String, String> getParameters() {
164+
return parameters;
165+
}
149166
}
150167
}

hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/CollectionIdSource.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
package org.hibernate.boot.model.source.spi;
88

9+
import java.util.Map;
10+
911
/**
1012
* @author Steve Ebersole
1113
*/
@@ -30,4 +32,9 @@ public interface CollectionIdSource {
3032
* @return The identifier value generator name
3133
*/
3234
public String getGeneratorName();
35+
36+
/**
37+
* @return The identifier generator configuration parameters
38+
*/
39+
public Map<String, String> getParameters();
3340
}

0 commit comments

Comments
 (0)