mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-18 00:55:16 +00:00
HHH-12454 - Offer flag to consider id generator with local scope (legacy non JPA behavior)
This commit is contained in:
parent
b463c809d6
commit
6cefa865b0
@ -71,6 +71,14 @@ hence we can save a database roundtrip.
|
|||||||
+
|
+
|
||||||
If enabled Hibernate will initialize the entity Proxy even when accessing its identifier.
|
If enabled Hibernate will initialize the entity Proxy even when accessing its identifier.
|
||||||
|
|
||||||
|
`*hibernate.jpa.compliance.global_id_generators*` (e.g. `true` or `false` (default value) )::
|
||||||
|
The JPA spec says that the scope of TableGenerator and SequenceGenerator names is global to the persistence unit (across all generator types).
|
||||||
|
+
|
||||||
|
Traditionally, Hibernate has considered the names locally scoped.
|
||||||
|
+
|
||||||
|
If enabled, the names used by `@TableGenerator` and `@SequenceGenerator` will be considered global so configuring two different generators
|
||||||
|
with the same name will cause a `java.lang.IllegalArgumentException' to be thrown at boot time.
|
||||||
|
|
||||||
[[configurations-database-connection]]
|
[[configurations-database-connection]]
|
||||||
=== Database connection properties
|
=== Database connection properties
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
||||||
import org.hibernate.dialect.function.SQLFunction;
|
import org.hibernate.dialect.function.SQLFunction;
|
||||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.loader.BatchFetchStyle;
|
import org.hibernate.loader.BatchFetchStyle;
|
||||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
import org.hibernate.cfg.annotations.reflection.JPAMetadataProvider;
|
import org.hibernate.cfg.annotations.reflection.JPAMetadataProvider;
|
||||||
import org.hibernate.dialect.function.SQLFunction;
|
import org.hibernate.dialect.function.SQLFunction;
|
||||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||||
|
import org.hibernate.jpa.internal.JpaComplianceImpl;
|
||||||
|
import org.hibernate.jpa.spi.MutableJpaCompliance;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
import org.jboss.jandex.IndexView;
|
import org.jboss.jandex.IndexView;
|
||||||
@ -51,6 +53,8 @@ public class BootstrapContextImpl implements BootstrapContext {
|
|||||||
|
|
||||||
private final StandardServiceRegistry serviceRegistry;
|
private final StandardServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
|
private final MutableJpaCompliance jpaCompliance;
|
||||||
|
|
||||||
private final TypeConfiguration typeConfiguration;
|
private final TypeConfiguration typeConfiguration;
|
||||||
|
|
||||||
private final ClassLoaderAccessImpl classLoaderAccess;
|
private final ClassLoaderAccessImpl classLoaderAccess;
|
||||||
@ -87,6 +91,7 @@ public BootstrapContextImpl(
|
|||||||
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
|
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
|
||||||
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
|
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
|
||||||
|
|
||||||
|
this.jpaCompliance = new JpaComplianceImpl( configService.getSettings(), false );
|
||||||
this.scanOptions = new StandardScanOptions(
|
this.scanOptions = new StandardScanOptions(
|
||||||
(String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ),
|
(String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ),
|
||||||
false
|
false
|
||||||
@ -112,6 +117,11 @@ public StandardServiceRegistry getServiceRegistry() {
|
|||||||
return serviceRegistry;
|
return serviceRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableJpaCompliance getJpaCompliance() {
|
||||||
|
return jpaCompliance;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeConfiguration getTypeConfiguration() {
|
public TypeConfiguration getTypeConfiguration() {
|
||||||
return typeConfiguration;
|
return typeConfiguration;
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
import org.hibernate.boot.model.relational.QualifiedTableName;
|
import org.hibernate.boot.model.relational.QualifiedTableName;
|
||||||
import org.hibernate.boot.model.source.internal.ImplicitColumnNamingSecondPass;
|
import org.hibernate.boot.model.source.internal.ImplicitColumnNamingSecondPass;
|
||||||
import org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext;
|
import org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext;
|
||||||
import org.hibernate.boot.model.convert.spi.ConverterAutoApplyHandler;
|
|
||||||
import org.hibernate.boot.spi.BootstrapContext;
|
import org.hibernate.boot.spi.BootstrapContext;
|
||||||
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
@ -60,6 +59,7 @@
|
|||||||
import org.hibernate.cache.cfg.internal.DomainDataRegionConfigImpl.Builder;
|
import org.hibernate.cache.cfg.internal.DomainDataRegionConfigImpl.Builder;
|
||||||
import org.hibernate.cache.spi.access.AccessType;
|
import org.hibernate.cache.spi.access.AccessType;
|
||||||
import org.hibernate.cfg.AnnotatedClassType;
|
import org.hibernate.cfg.AnnotatedClassType;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.CopyIdentifierComponentSecondPass;
|
import org.hibernate.cfg.CopyIdentifierComponentSecondPass;
|
||||||
import org.hibernate.cfg.CreateKeySecondPass;
|
import org.hibernate.cfg.CreateKeySecondPass;
|
||||||
import org.hibernate.cfg.FkSecondPass;
|
import org.hibernate.cfg.FkSecondPass;
|
||||||
@ -493,11 +493,13 @@ public void addIdentifierGenerator(IdentifierGeneratorDefinition generator) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final IdentifierGeneratorDefinition old = idGeneratorDefinitionMap.put( generator.getName(), generator );
|
final IdentifierGeneratorDefinition old = idGeneratorDefinitionMap.put( generator.getName(), generator );
|
||||||
if ( old != null ) {
|
if ( old != null && !old.equals( generator ) ) {
|
||||||
if ( !old.equals( generator ) ) {
|
if ( bootstrapContext.getJpaCompliance().isGlobalGeneratorScopeEnabled() ) {
|
||||||
throw new IllegalArgumentException( "Duplicate generator name " + old.getName() );
|
throw new IllegalArgumentException( "Duplicate generator name " + old.getName() + " you will likely want to set the property " + AvailableSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE + " to false " );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.duplicateGeneratorName( old.getName() );
|
||||||
}
|
}
|
||||||
// log.duplicateGeneratorName( old.getName() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.hibernate.AssertionFailure;
|
|
||||||
import org.hibernate.ConnectionAcquisitionMode;
|
import org.hibernate.ConnectionAcquisitionMode;
|
||||||
import org.hibernate.ConnectionReleaseMode;
|
import org.hibernate.ConnectionReleaseMode;
|
||||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||||
@ -51,8 +50,8 @@
|
|||||||
import org.hibernate.id.uuid.LocalObjectUuidHelper;
|
import org.hibernate.id.uuid.LocalObjectUuidHelper;
|
||||||
import org.hibernate.internal.log.DeprecationLogger;
|
import org.hibernate.internal.log.DeprecationLogger;
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.jpa.spi.JpaComplianceImpl;
|
import org.hibernate.jpa.spi.MutableJpaCompliance;
|
||||||
import org.hibernate.loader.BatchFetchStyle;
|
import org.hibernate.loader.BatchFetchStyle;
|
||||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||||
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
||||||
@ -235,7 +234,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
|||||||
|
|
||||||
private Map<String, SQLFunction> sqlFunctions;
|
private Map<String, SQLFunction> sqlFunctions;
|
||||||
|
|
||||||
private JpaComplianceImpl jpaCompliance;
|
private MutableJpaCompliance jpaCompliance;
|
||||||
|
|
||||||
private boolean failOnPaginationOverCollectionFetchEnabled;
|
private boolean failOnPaginationOverCollectionFetchEnabled;
|
||||||
|
|
||||||
@ -465,7 +464,7 @@ else if ( jdbcTimeZoneValue != null ) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// added the boolean parameter in case we want to define some form of "all" as discussed
|
// added the boolean parameter in case we want to define some form of "all" as discussed
|
||||||
this.jpaCompliance = new JpaComplianceImpl( configurationSettings, false );
|
this.jpaCompliance = context.getJpaCompliance();
|
||||||
|
|
||||||
this.failOnPaginationOverCollectionFetchEnabled = ConfigurationHelper.getBoolean(
|
this.failOnPaginationOverCollectionFetchEnabled = ConfigurationHelper.getBoolean(
|
||||||
FAIL_ON_PAGINATION_OVER_COLLECTION_FETCH,
|
FAIL_ON_PAGINATION_OVER_COLLECTION_FETCH,
|
||||||
@ -979,8 +978,6 @@ public JpaCompliance getJpaCompliance() {
|
|||||||
return jpaCompliance;
|
return jpaCompliance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// In-flight mutation access
|
// In-flight mutation access
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
||||||
import org.hibernate.dialect.function.SQLFunction;
|
import org.hibernate.dialect.function.SQLFunction;
|
||||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.loader.BatchFetchStyle;
|
import org.hibernate.loader.BatchFetchStyle;
|
||||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||||
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
package org.hibernate.boot.spi;
|
package org.hibernate.boot.spi;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
@ -20,6 +19,7 @@
|
|||||||
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.dialect.function.SQLFunction;
|
import org.hibernate.dialect.function.SQLFunction;
|
||||||
|
import org.hibernate.jpa.spi.MutableJpaCompliance;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
import org.jboss.jandex.IndexView;
|
import org.jboss.jandex.IndexView;
|
||||||
@ -34,6 +34,8 @@
|
|||||||
public interface BootstrapContext {
|
public interface BootstrapContext {
|
||||||
StandardServiceRegistry getServiceRegistry();
|
StandardServiceRegistry getServiceRegistry();
|
||||||
|
|
||||||
|
MutableJpaCompliance getJpaCompliance();
|
||||||
|
|
||||||
TypeConfiguration getTypeConfiguration();
|
TypeConfiguration getTypeConfiguration();
|
||||||
|
|
||||||
MetadataBuildingOptions getMetadataBuildingOptions();
|
MetadataBuildingOptions getMetadataBuildingOptions();
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
import org.hibernate.dialect.function.SQLFunction;
|
import org.hibernate.dialect.function.SQLFunction;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.loader.BatchFetchStyle;
|
import org.hibernate.loader.BatchFetchStyle;
|
||||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||||
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -128,6 +129,7 @@
|
|||||||
import org.hibernate.boot.model.IdGeneratorStrategyInterpreter;
|
import org.hibernate.boot.model.IdGeneratorStrategyInterpreter;
|
||||||
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
|
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
|
||||||
import org.hibernate.boot.model.TypeDefinition;
|
import org.hibernate.boot.model.TypeDefinition;
|
||||||
|
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
||||||
import org.hibernate.boot.spi.InFlightMetadataCollector.EntityTableXref;
|
import org.hibernate.boot.spi.InFlightMetadataCollector.EntityTableXref;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.annotations.CollectionBinder;
|
import org.hibernate.cfg.annotations.CollectionBinder;
|
||||||
@ -2242,20 +2244,33 @@ else if ( !isId || !entityBinder.isIgnoreIdAnnotations() ) {
|
|||||||
foreignGeneratorBuilder.setName( "Hibernate-local--foreign generator" );
|
foreignGeneratorBuilder.setName( "Hibernate-local--foreign generator" );
|
||||||
foreignGeneratorBuilder.setStrategy( "foreign" );
|
foreignGeneratorBuilder.setStrategy( "foreign" );
|
||||||
foreignGeneratorBuilder.addParam( "property", mapsIdProperty.getPropertyName() );
|
foreignGeneratorBuilder.addParam( "property", mapsIdProperty.getPropertyName() );
|
||||||
|
|
||||||
final IdentifierGeneratorDefinition foreignGenerator = foreignGeneratorBuilder.build();
|
final IdentifierGeneratorDefinition foreignGenerator = foreignGeneratorBuilder.build();
|
||||||
// Map<String, IdentifierGeneratorDefinition> localGenerators = ( HashMap<String, IdentifierGeneratorDefinition> ) classGenerators.clone();
|
|
||||||
// localGenerators.put( foreignGenerator.getName(), foreignGenerator );
|
|
||||||
|
|
||||||
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
if ( isGlobalGeneratorNameGlobal( context ) ) {
|
||||||
( SimpleValue ) propertyBinder.getValue(),
|
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
||||||
property,
|
(SimpleValue) propertyBinder.getValue(),
|
||||||
foreignGenerator.getStrategy(),
|
property,
|
||||||
foreignGenerator.getName(),
|
foreignGenerator.getStrategy(),
|
||||||
context,
|
foreignGenerator.getName(),
|
||||||
foreignGenerator
|
context,
|
||||||
);
|
foreignGenerator
|
||||||
context.getMetadataCollector().addSecondPass( secondPass );
|
);
|
||||||
|
context.getMetadataCollector().addSecondPass( secondPass );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Map<String, IdentifierGeneratorDefinition> localGenerators = (HashMap<String, IdentifierGeneratorDefinition>) classGenerators
|
||||||
|
.clone();
|
||||||
|
localGenerators.put( foreignGenerator.getName(), foreignGenerator );
|
||||||
|
|
||||||
|
BinderHelper.makeIdGenerator(
|
||||||
|
(SimpleValue) propertyBinder.getValue(),
|
||||||
|
property,
|
||||||
|
foreignGenerator.getStrategy(),
|
||||||
|
foreignGenerator.getName(),
|
||||||
|
context,
|
||||||
|
localGenerators
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( isId ) {
|
if ( isId ) {
|
||||||
//components and regular basic types create SimpleValue objects
|
//components and regular basic types create SimpleValue objects
|
||||||
@ -2313,6 +2328,10 @@ else if ( !isId || !entityBinder.isIgnoreIdAnnotations() ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isGlobalGeneratorNameGlobal(MetadataBuildingContext context) {
|
||||||
|
return context.getBootstrapContext().getJpaCompliance().isGlobalGeneratorScopeEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isToManyAssociationWithinEmbeddableCollection(PropertyHolder propertyHolder) {
|
private static boolean isToManyAssociationWithinEmbeddableCollection(PropertyHolder propertyHolder) {
|
||||||
if(propertyHolder instanceof ComponentPropertyHolder) {
|
if(propertyHolder instanceof ComponentPropertyHolder) {
|
||||||
ComponentPropertyHolder componentPropertyHolder = (ComponentPropertyHolder) propertyHolder;
|
ComponentPropertyHolder componentPropertyHolder = (ComponentPropertyHolder) propertyHolder;
|
||||||
@ -2344,10 +2363,6 @@ private static void processId(
|
|||||||
}
|
}
|
||||||
XClass entityXClass = inferredData.getClassOrElement();
|
XClass entityXClass = inferredData.getClassOrElement();
|
||||||
XProperty idXProperty = inferredData.getProperty();
|
XProperty idXProperty = inferredData.getProperty();
|
||||||
//clone classGenerator and override with local values
|
|
||||||
// HashMap<String, IdentifierGeneratorDefinition> localGenerators = ( HashMap<String, IdentifierGeneratorDefinition> ) classGenerators.clone();
|
|
||||||
// localGenerators.putAll( buildGenerators( idXProperty, buildingContext ) );
|
|
||||||
buildGenerators( idXProperty, buildingContext );
|
|
||||||
|
|
||||||
//manage composite related metadata
|
//manage composite related metadata
|
||||||
//guess if its a component and find id data access (property, field etc)
|
//guess if its a component and find id data access (property, field etc)
|
||||||
@ -2366,14 +2381,31 @@ private static void processId(
|
|||||||
generatorType = "assigned";
|
generatorType = "assigned";
|
||||||
}
|
}
|
||||||
|
|
||||||
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
if ( isGlobalGeneratorNameGlobal( buildingContext ) ) {
|
||||||
idValue,
|
buildGenerators( idXProperty, buildingContext );
|
||||||
idXProperty,
|
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
||||||
generatorType,
|
idValue,
|
||||||
generatorName,
|
idXProperty,
|
||||||
buildingContext
|
generatorType,
|
||||||
);
|
generatorName,
|
||||||
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
buildingContext
|
||||||
|
);
|
||||||
|
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//clone classGenerator and override with local values
|
||||||
|
HashMap<String, IdentifierGeneratorDefinition> localGenerators = (HashMap<String, IdentifierGeneratorDefinition>) classGenerators
|
||||||
|
.clone();
|
||||||
|
localGenerators.putAll( buildGenerators( idXProperty, buildingContext ) );
|
||||||
|
BinderHelper.makeIdGenerator(
|
||||||
|
idValue,
|
||||||
|
idXProperty,
|
||||||
|
generatorType,
|
||||||
|
generatorName,
|
||||||
|
buildingContext,
|
||||||
|
localGenerators
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ( LOG.isTraceEnabled() ) {
|
if ( LOG.isTraceEnabled() ) {
|
||||||
LOG.tracev( "Bind {0} on {1}", ( isComponent ? "@EmbeddedId" : "@Id" ), inferredData.getPropertyName() );
|
LOG.tracev( "Bind {0} on {1}", ( isComponent ? "@EmbeddedId" : "@Id" ), inferredData.getPropertyName() );
|
||||||
@ -2710,27 +2742,38 @@ public static Component fillComponent(
|
|||||||
XProperty property = propertyAnnotatedElement.getProperty();
|
XProperty property = propertyAnnotatedElement.getProperty();
|
||||||
if ( property.isAnnotationPresent( GeneratedValue.class ) &&
|
if ( property.isAnnotationPresent( GeneratedValue.class ) &&
|
||||||
property.isAnnotationPresent( Id.class ) ) {
|
property.isAnnotationPresent( Id.class ) ) {
|
||||||
//clone classGenerator and override with local values
|
|
||||||
// Map<String, IdentifierGeneratorDefinition> localGenerators = new HashMap<>();
|
|
||||||
// localGenerators.putAll( buildGenerators( property, buildingContext ) );
|
|
||||||
|
|
||||||
buildGenerators( property, buildingContext );
|
|
||||||
GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
|
GeneratedValue generatedValue = property.getAnnotation( GeneratedValue.class );
|
||||||
String generatorType = generatedValue != null
|
String generatorType = generatedValue != null
|
||||||
? generatorType( generatedValue, buildingContext, property.getType() )
|
? generatorType( generatedValue, buildingContext, property.getType() )
|
||||||
: "assigned";
|
: "assigned";
|
||||||
String generator = generatedValue != null ? generatedValue.generator() : BinderHelper.ANNOTATION_STRING_DEFAULT;
|
String generator = generatedValue != null ?
|
||||||
|
generatedValue.generator() :
|
||||||
|
BinderHelper.ANNOTATION_STRING_DEFAULT;
|
||||||
|
|
||||||
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
if ( isGlobalGeneratorNameGlobal( buildingContext ) ) {
|
||||||
( SimpleValue ) comp.getProperty( property.getName() ).getValue(),
|
buildGenerators( property, buildingContext );
|
||||||
property,
|
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
||||||
generatorType,
|
(SimpleValue) comp.getProperty( property.getName() ).getValue(),
|
||||||
generator,
|
property,
|
||||||
buildingContext
|
generatorType,
|
||||||
);
|
generator,
|
||||||
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
buildingContext
|
||||||
|
);
|
||||||
|
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Map<String, IdentifierGeneratorDefinition> localGenerators = new HashMap<>();
|
||||||
|
localGenerators.putAll( buildGenerators( property, buildingContext ) );
|
||||||
|
BinderHelper.makeIdGenerator(
|
||||||
|
(SimpleValue) comp.getProperty( property.getName() ).getValue(),
|
||||||
|
property,
|
||||||
|
generatorType,
|
||||||
|
generator,
|
||||||
|
buildingContext,
|
||||||
|
localGenerators
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
@ -2827,14 +2870,26 @@ private static void bindIdClass(
|
|||||||
id = value.make();
|
id = value.make();
|
||||||
}
|
}
|
||||||
rootClass.setIdentifier( id );
|
rootClass.setIdentifier( id );
|
||||||
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
if ( isGlobalGeneratorNameGlobal( buildingContext ) ) {
|
||||||
id,
|
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
||||||
inferredData.getProperty(),
|
id,
|
||||||
generatorType,
|
inferredData.getProperty(),
|
||||||
generatorName,
|
generatorType,
|
||||||
buildingContext
|
generatorName,
|
||||||
);
|
buildingContext
|
||||||
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
);
|
||||||
|
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BinderHelper.makeIdGenerator(
|
||||||
|
id,
|
||||||
|
inferredData.getProperty(),
|
||||||
|
generatorType,
|
||||||
|
generatorName,
|
||||||
|
buildingContext,
|
||||||
|
Collections.emptyMap()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ( isEmbedded ) {
|
if ( isEmbedded ) {
|
||||||
rootClass.setEmbeddedIdentifier( inferredData.getPropertyClass() == null );
|
rootClass.setEmbeddedIdentifier( inferredData.getPropertyClass() == null );
|
||||||
@ -3331,6 +3386,7 @@ public static FetchMode getFetchMode(FetchType fetch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static HashMap<String, IdentifierGeneratorDefinition> buildGenerators(XAnnotatedElement annElt, MetadataBuildingContext context) {
|
private static HashMap<String, IdentifierGeneratorDefinition> buildGenerators(XAnnotatedElement annElt, MetadataBuildingContext context) {
|
||||||
|
InFlightMetadataCollector metadataCollector = context.getMetadataCollector();
|
||||||
HashMap<String, IdentifierGeneratorDefinition> generators = new HashMap<>();
|
HashMap<String, IdentifierGeneratorDefinition> generators = new HashMap<>();
|
||||||
|
|
||||||
TableGenerators tableGenerators = annElt.getAnnotation( TableGenerators.class );
|
TableGenerators tableGenerators = annElt.getAnnotation( TableGenerators.class );
|
||||||
@ -3344,6 +3400,7 @@ private static HashMap<String, IdentifierGeneratorDefinition> buildGenerators(XA
|
|||||||
idGenerator.getName(),
|
idGenerator.getName(),
|
||||||
idGenerator
|
idGenerator
|
||||||
);
|
);
|
||||||
|
metadataCollector.addIdentifierGenerator( idGenerator );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3358,6 +3415,7 @@ private static HashMap<String, IdentifierGeneratorDefinition> buildGenerators(XA
|
|||||||
idGenerator.getName(),
|
idGenerator.getName(),
|
||||||
idGenerator
|
idGenerator
|
||||||
);
|
);
|
||||||
|
metadataCollector.addIdentifierGenerator( idGenerator );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3367,20 +3425,19 @@ private static HashMap<String, IdentifierGeneratorDefinition> buildGenerators(XA
|
|||||||
if ( tabGen != null ) {
|
if ( tabGen != null ) {
|
||||||
IdentifierGeneratorDefinition idGen = buildIdGenerator( tabGen, context );
|
IdentifierGeneratorDefinition idGen = buildIdGenerator( tabGen, context );
|
||||||
generators.put( idGen.getName(), idGen );
|
generators.put( idGen.getName(), idGen );
|
||||||
|
metadataCollector.addIdentifierGenerator( idGen );
|
||||||
|
|
||||||
}
|
}
|
||||||
if ( seqGen != null ) {
|
if ( seqGen != null ) {
|
||||||
IdentifierGeneratorDefinition idGen = buildIdGenerator( seqGen, context );
|
IdentifierGeneratorDefinition idGen = buildIdGenerator( seqGen, context );
|
||||||
generators.put( idGen.getName(), idGen );
|
generators.put( idGen.getName(), idGen );
|
||||||
|
metadataCollector.addIdentifierGenerator( idGen );
|
||||||
}
|
}
|
||||||
if ( genGen != null ) {
|
if ( genGen != null ) {
|
||||||
IdentifierGeneratorDefinition idGen = buildIdGenerator( genGen, context );
|
IdentifierGeneratorDefinition idGen = buildIdGenerator( genGen, context );
|
||||||
generators.put( idGen.getName(), idGen );
|
generators.put( idGen.getName(), idGen );
|
||||||
|
metadataCollector.addIdentifierGenerator( idGen );
|
||||||
}
|
}
|
||||||
|
|
||||||
generators.forEach( (name, idGenerator) -> {
|
|
||||||
context.getMetadataCollector().addIdentifierGenerator( idGenerator );
|
|
||||||
} );
|
|
||||||
|
|
||||||
return generators;
|
return generators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence;
|
import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence;
|
||||||
import org.hibernate.cache.spi.TimestampsCacheFactory;
|
import org.hibernate.cache.spi.TimestampsCacheFactory;
|
||||||
import org.hibernate.internal.log.DeprecationLogger;
|
import org.hibernate.internal.log.DeprecationLogger;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
||||||
import org.hibernate.query.internal.ParameterMetadataImpl;
|
import org.hibernate.query.internal.ParameterMetadataImpl;
|
||||||
import org.hibernate.resource.beans.container.spi.ExtendedBeanManager;
|
import org.hibernate.resource.beans.container.spi.ExtendedBeanManager;
|
||||||
@ -1846,6 +1846,18 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
|
|||||||
*/
|
*/
|
||||||
String JPA_CACHING_COMPLIANCE = "hibernate.jpa.compliance.caching";
|
String JPA_CACHING_COMPLIANCE = "hibernate.jpa.compliance.caching";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the scope of {@link javax.persistence.TableGenerator#name()} and {@link javax.persistence.SequenceGenerator#name()} should be
|
||||||
|
* considered globally or locally defined.
|
||||||
|
*
|
||||||
|
* If enabled, the names will considered globally scoped so defining two different generators with the same name
|
||||||
|
* will cause a name collision and an exception will be thrown during the bootstrap phase.
|
||||||
|
*
|
||||||
|
* @see JpaCompliance#isGlobalGeneratorScopeEnabled()
|
||||||
|
* @since 5.2.17
|
||||||
|
*/
|
||||||
|
String JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE = "hibernate.jpa.compliance.global_id_generators";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True/False setting indicating if the value stored in the table used by the {@link javax.persistence.TableGenerator}
|
* True/False setting indicating if the value stored in the table used by the {@link javax.persistence.TableGenerator}
|
||||||
* is the last value generated or the next value to be used.
|
* is the last value generated or the next value to be used.
|
||||||
|
@ -107,14 +107,26 @@ property, unique, associationTableBinder, ignoreNotFound, getBuildingContext()
|
|||||||
generatorType = null;
|
generatorType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
if ( buildingContext.getBootstrapContext().getJpaCompliance().isGlobalGeneratorScopeEnabled() ) {
|
||||||
id,
|
SecondPass secondPass = new IdGeneratorResolverSecondPass(
|
||||||
property,
|
id,
|
||||||
generatorType,
|
property,
|
||||||
generator,
|
generatorType,
|
||||||
getBuildingContext()
|
generator,
|
||||||
);
|
getBuildingContext()
|
||||||
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
);
|
||||||
|
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BinderHelper.makeIdGenerator(
|
||||||
|
id,
|
||||||
|
property,
|
||||||
|
generatorType,
|
||||||
|
generator,
|
||||||
|
getBuildingContext(),
|
||||||
|
localGenerators
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import org.hibernate.engine.spi.ExceptionConverter;
|
import org.hibernate.engine.spi.ExceptionConverter;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||||
|
|
||||||
|
@ -4,24 +4,25 @@
|
|||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.spi;
|
package org.hibernate.jpa.internal;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.MutableJpaCompliance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class JpaComplianceImpl implements JpaCompliance {
|
public class JpaComplianceImpl implements MutableJpaCompliance {
|
||||||
private boolean queryCompliance;
|
private boolean queryCompliance;
|
||||||
private boolean transactionCompliance;
|
private boolean transactionCompliance;
|
||||||
private boolean listCompliance;
|
private boolean listCompliance;
|
||||||
private boolean closedCompliance;
|
private boolean closedCompliance;
|
||||||
private boolean proxyCompliance;
|
private boolean proxyCompliance;
|
||||||
private boolean cachingCompliance;
|
private boolean cachingCompliance;
|
||||||
|
private final boolean globalGeneratorNameScopeCompliance;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@ -58,6 +59,11 @@ public JpaComplianceImpl(Map configurationSettings, boolean jpaByDefault) {
|
|||||||
configurationSettings,
|
configurationSettings,
|
||||||
jpaByDefault
|
jpaByDefault
|
||||||
);
|
);
|
||||||
|
globalGeneratorNameScopeCompliance = ConfigurationHelper.getBoolean(
|
||||||
|
AvailableSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE,
|
||||||
|
configurationSettings,
|
||||||
|
jpaByDefault
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,6 +96,11 @@ public boolean isJpaCacheComplianceEnabled() {
|
|||||||
return cachingCompliance;
|
return cachingCompliance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGlobalGeneratorScopeEnabled() {
|
||||||
|
return globalGeneratorNameScopeCompliance;
|
||||||
|
}
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Mutators
|
// Mutators
|
||||||
|
|
@ -4,7 +4,7 @@
|
|||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa;
|
package org.hibernate.jpa.spi;
|
||||||
|
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
|
||||||
@ -89,4 +89,12 @@ public interface JpaCompliance {
|
|||||||
* @return {@code true} says to act the spec-defined way.
|
* @return {@code true} says to act the spec-defined way.
|
||||||
*/
|
*/
|
||||||
boolean isJpaCacheComplianceEnabled();
|
boolean isJpaCacheComplianceEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the the scope of {@link javax.persistence.TableGenerator#name()} and {@link javax.persistence.SequenceGenerator#name()} be
|
||||||
|
* considered globally or locally defined?
|
||||||
|
*
|
||||||
|
* @return {@code true} indicates the generator name scope is considered global.
|
||||||
|
*/
|
||||||
|
boolean isGlobalGeneratorScopeEnabled();
|
||||||
}
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
package org.hibernate.jpa.spi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface MutableJpaCompliance extends JpaCompliance {
|
||||||
|
void setQueryCompliance(boolean queryCompliance);
|
||||||
|
|
||||||
|
void setTransactionCompliance(boolean transactionCompliance);
|
||||||
|
|
||||||
|
void setListCompliance(boolean listCompliance);
|
||||||
|
|
||||||
|
void setClosedCompliance(boolean closedCompliance);
|
||||||
|
|
||||||
|
void setProxyCompliance(boolean proxyCompliance);
|
||||||
|
|
||||||
|
void setCachingCompliance(boolean cachingCompliance);
|
||||||
|
}
|
@ -15,7 +15,7 @@
|
|||||||
import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||||
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransaction;
|
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransaction;
|
||||||
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransactionAccess;
|
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransactionAccess;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||||
import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||||
import org.hibernate.resource.transaction.TransactionRequiredForJoinException;
|
import org.hibernate.resource.transaction.TransactionRequiredForJoinException;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
import org.hibernate.engine.transaction.spi.IsolationDelegate;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
||||||
import org.hibernate.jpa.JpaCompliance;
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models the coordination of all transaction related flows.
|
* Models the coordination of all transaction related flows.
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.jpa;
|
package org.hibernate.jpa;
|
||||||
|
|
||||||
|
import org.hibernate.jpa.spi.JpaCompliance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@ -44,6 +46,7 @@ public static JpaCompliance withClosedCompliance() {
|
|||||||
private boolean closedCompliance;
|
private boolean closedCompliance;
|
||||||
private boolean proxyCompliance;
|
private boolean proxyCompliance;
|
||||||
private boolean cacheCompliance;
|
private boolean cacheCompliance;
|
||||||
|
private boolean idGeneratorNameScopeCompliance;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isJpaQueryComplianceEnabled() {
|
public boolean isJpaQueryComplianceEnabled() {
|
||||||
@ -74,4 +77,9 @@ public boolean isJpaProxyComplianceEnabled() {
|
|||||||
public boolean isJpaCacheComplianceEnabled() {
|
public boolean isJpaCacheComplianceEnabled() {
|
||||||
return cacheCompliance;
|
return cacheCompliance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGlobalGeneratorScopeEnabled() {
|
||||||
|
return idGeneratorNameScopeCompliance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
import org.hibernate.boot.spi.ClassLoaderAccess;
|
import org.hibernate.boot.spi.ClassLoaderAccess;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
||||||
import org.hibernate.dialect.function.SQLFunction;
|
import org.hibernate.dialect.function.SQLFunction;
|
||||||
|
import org.hibernate.jpa.spi.MutableJpaCompliance;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
import org.jboss.jandex.IndexView;
|
import org.jboss.jandex.IndexView;
|
||||||
@ -48,6 +49,11 @@ public StandardServiceRegistry getServiceRegistry() {
|
|||||||
return delegate.getServiceRegistry();
|
return delegate.getServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableJpaCompliance getJpaCompliance() {
|
||||||
|
return delegate.getJpaCompliance();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeConfiguration getTypeConfiguration() {
|
public TypeConfiguration getTypeConfiguration() {
|
||||||
return delegate.getTypeConfiguration();
|
return delegate.getTypeConfiguration();
|
||||||
|
@ -42,48 +42,6 @@ For backward compatibility, a new setting called `hibernate.id.generator.stored_
|
|||||||
Existing applications migrating to 5.3 and using the `@TableGenerator` have to set the `hibernate.id.generator.stored_last_used` configuration property to `false`.
|
Existing applications migrating to 5.3 and using the `@TableGenerator` have to set the `hibernate.id.generator.stored_last_used` configuration property to `false`.
|
||||||
====
|
====
|
||||||
|
|
||||||
=== Change in the `@TableGenerator` and `@SequenceGenerator` name scope
|
|
||||||
|
|
||||||
In order to be compliant with the JPA specification, generators names are now considered global (e.g. https://hibernate.atlassian.net/browse/HHH-12157[HHH-12157]) .
|
|
||||||
Configuring two generators, even if with different types but with the same name will now cause a `java.lang.IllegalArgumentException' to be thrown at boot time.
|
|
||||||
|
|
||||||
For example, the following mappings are no longer valid:
|
|
||||||
|
|
||||||
[source,java]
|
|
||||||
----
|
|
||||||
@Entity
|
|
||||||
@TableGenerator(name = "ID_GENERATOR", ... )
|
|
||||||
public class FirstEntity {
|
|
||||||
....
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@TableGenerator(name = "ID_GENERATOR", ... )
|
|
||||||
public class SecondEntity {
|
|
||||||
....
|
|
||||||
}
|
|
||||||
----
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
[source,java]
|
|
||||||
----
|
|
||||||
@Entity
|
|
||||||
@TableGenerator(name = "ID_GENERATOR", ... )
|
|
||||||
public class FirstEntity {
|
|
||||||
....
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@SequenceGenerator(name="ID_GENERATOR", ... )
|
|
||||||
public class SecondEntity {
|
|
||||||
....
|
|
||||||
}
|
|
||||||
----
|
|
||||||
|
|
||||||
The solution is to make all generators unique so that there are no two generators with the same name.
|
|
||||||
|
|
||||||
|
|
||||||
=== Drop hibernate-infinispan module
|
=== Drop hibernate-infinispan module
|
||||||
|
|
||||||
Support for using Infinispan as a Hibernate 2nd-level cache provider has been moved to the Infinispan project so
|
Support for using Infinispan as a Hibernate 2nd-level cache provider has been moved to the Infinispan project so
|
||||||
|
Loading…
x
Reference in New Issue
Block a user