HHH-10372 - Fix Sequence generator for idbag ignores generator parameters

This commit is contained in:
Andrea Boriero 2016-04-19 13:40:00 +01:00 committed by Steve Ebersole
parent a9e4eb4895
commit 030f442f3c
4 changed files with 33 additions and 3 deletions

View File

@ -39,6 +39,12 @@ public class IdentifierGeneratorDefinition implements Serializable {
}
}
public IdentifierGeneratorDefinition(
final String name,
final Map<String, String> parameters) {
this( name, name, parameters );
}
public IdentifierGeneratorDefinition(String name) {
this( name, name );
}

View File

@ -3386,7 +3386,7 @@ public class ModelBinder {
makeIdentifier(
mappingDocument,
new IdentifierGeneratorDefinition( idSource.getGeneratorName() ),
new IdentifierGeneratorDefinition( idSource.getGeneratorName(), idSource.getParameters() ),
null,
idBinding
);

View File

@ -6,8 +6,10 @@
*/
package org.hibernate.boot.model.source.internal.hbm;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.hibernate.boot.MappingException;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmIdBagCollectionType;
@ -19,6 +21,7 @@ import org.hibernate.boot.model.source.spi.PluralAttributeNature;
import org.hibernate.boot.model.source.spi.RelationalValueSource;
import org.hibernate.boot.model.source.spi.SizeSource;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
/**
* @author Steve Ebersole
@ -81,10 +84,12 @@ public class PluralAttributeSourceIdBagImpl extends AbstractPluralAttributeSourc
);
}
this.collectionIdSource = new CollectionIdSourceImpl(
(ColumnSource) collectionIdRelationalValueSource,
new HibernateTypeSourceImpl( idBagMapping.getCollectionId().getType() ),
idBagMapping.getCollectionId().getGenerator().getClazz()
idBagMapping.getCollectionId().getGenerator().getClazz(),
Helper.extractParameters( idBagMapping.getCollectionId().getGenerator().getConfigParameters() )
);
}
@ -122,14 +127,22 @@ public class PluralAttributeSourceIdBagImpl extends AbstractPluralAttributeSourc
private final ColumnSource columnSource;
private final HibernateTypeSourceImpl typeSource;
private final String generator;
private final Map<String, String> parameters;
public CollectionIdSourceImpl(
ColumnSource columnSource,
HibernateTypeSourceImpl typeSource,
String generator) {
String generator,
final Map<String, String> parameters) {
this.columnSource = columnSource;
this.typeSource = typeSource;
this.generator = generator;
if ( CollectionHelper.isEmpty( parameters ) ) {
this.parameters = Collections.emptyMap();
}
else {
this.parameters = Collections.unmodifiableMap( parameters );
}
}
@Override
@ -146,5 +159,9 @@ public class PluralAttributeSourceIdBagImpl extends AbstractPluralAttributeSourc
public String getGeneratorName() {
return generator;
}
public Map<String, String> getParameters() {
return parameters;
}
}
}

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.boot.model.source.spi;
import java.util.Map;
/**
* @author Steve Ebersole
*/
@ -30,4 +32,9 @@ public interface CollectionIdSource {
* @return The identifier value generator name
*/
public String getGeneratorName();
/**
* @return The identifier generator configuration parameters
*/
public Map<String, String> getParameters();
}