mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-06 19:36:03 +00:00
HHH-14857 Deprecations in preparation for 6
This commit is contained in:
parent
34a9fa2e55
commit
48068e0311
@ -69,7 +69,7 @@ public void testLifecycle() {
|
||||
try {
|
||||
Map settings = buildSettings();
|
||||
settings.put(
|
||||
org.hibernate.jpa.AvailableSettings.LOADED_CLASSES,
|
||||
org.hibernate.cfg.AvailableSettings.LOADED_CLASSES,
|
||||
Collections.singletonList(
|
||||
Person.class
|
||||
)
|
||||
|
@ -59,7 +59,7 @@ public void testLifecycle() {
|
||||
try {
|
||||
Map settings = buildSettings();
|
||||
settings.put(
|
||||
org.hibernate.jpa.AvailableSettings.LOADED_CLASSES,
|
||||
AvailableSettings.LOADED_CLASSES,
|
||||
Arrays.asList(
|
||||
ApplicationCustomer.class,
|
||||
CustomTrackingRevisionEntity.class
|
||||
|
@ -83,7 +83,7 @@ public void test() {
|
||||
try {
|
||||
Map settings = buildSettings();
|
||||
settings.put(
|
||||
org.hibernate.jpa.AvailableSettings.LOADED_CLASSES,
|
||||
AvailableSettings.LOADED_CLASSES,
|
||||
Arrays.asList(
|
||||
ApplicationCustomer.class,
|
||||
CustomTrackingRevisionEntity.class
|
||||
|
@ -75,7 +75,7 @@ public void testLifecycle() {
|
||||
try {
|
||||
Map settings = buildSettings();
|
||||
settings.put(
|
||||
org.hibernate.jpa.AvailableSettings.LOADED_CLASSES,
|
||||
AvailableSettings.LOADED_CLASSES,
|
||||
Arrays.asList(
|
||||
ApplicationCustomer.class,
|
||||
CustomTrackingRevisionEntity.class,
|
||||
|
@ -21,7 +21,6 @@
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.envers.configuration.EnversSettings;
|
||||
import org.hibernate.envers.strategy.ValidityAuditStrategy;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -22,7 +22,10 @@
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated To be removed in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
@java.lang.annotation.Target( { PACKAGE, TYPE, METHOD, FIELD } )
|
||||
@Retention( RUNTIME )
|
||||
@Repeatable(AnyMetaDefs.class)
|
||||
|
@ -17,9 +17,12 @@
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated To be removed in 6.0
|
||||
*/
|
||||
@java.lang.annotation.Target( { PACKAGE, TYPE } )
|
||||
@Retention( RUNTIME )
|
||||
@Deprecated
|
||||
public @interface AnyMetaDefs {
|
||||
/**
|
||||
* The collective set of any meta-defs.
|
||||
|
@ -26,8 +26,14 @@
|
||||
public @interface CollectionId {
|
||||
/**
|
||||
* Collection id column(s).
|
||||
*
|
||||
* @deprecated Only basic (single column) collection-ids are supported.
|
||||
* Use {@link #column} instead
|
||||
*/
|
||||
Column[] columns();
|
||||
@Deprecated
|
||||
Column[] columns() default {};
|
||||
|
||||
Column column() default @Column;
|
||||
|
||||
/**
|
||||
* id type, type.type() must be set.
|
||||
|
@ -20,9 +20,12 @@
|
||||
* @see org.hibernate.usertype.UserCollectionType
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated Custom handling for "collection types" will be handled differently in 6.0
|
||||
*/
|
||||
@java.lang.annotation.Target({FIELD, METHOD})
|
||||
@Retention(RUNTIME)
|
||||
@Deprecated
|
||||
public @interface CollectionType {
|
||||
/**
|
||||
* Names the type.
|
||||
|
@ -16,9 +16,12 @@
|
||||
* Allows defining the type of the key of a persistent map.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated 6.0 will introduce a new type-safe {@code CustomType} annotation
|
||||
*/
|
||||
@java.lang.annotation.Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
@Deprecated
|
||||
public @interface MapKeyType {
|
||||
/**
|
||||
* The map key type definition.
|
||||
|
@ -24,9 +24,12 @@
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated 6.0 will introduce a new type-safe {@code CustomType} annotation
|
||||
*/
|
||||
@Target({FIELD, METHOD})
|
||||
@Retention(RUNTIME)
|
||||
@Deprecated
|
||||
public @interface Type {
|
||||
/**
|
||||
* The Hibernate type name. Usually the fully qualified name of an implementation class for
|
||||
|
@ -28,10 +28,13 @@
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated 6.0 will introduce a new series of type-safe annotations to serve the same purpose
|
||||
*/
|
||||
@Target({TYPE, PACKAGE})
|
||||
@Retention(RUNTIME)
|
||||
@Repeatable(TypeDefs.class)
|
||||
@Deprecated
|
||||
public @interface TypeDef {
|
||||
/**
|
||||
* The type name. This is the name that would be used in other locations.
|
||||
|
@ -18,9 +18,12 @@
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated 6.0 will introduce a new series of type-safe annotations to serve the same purpose
|
||||
*/
|
||||
@Target({TYPE, PACKAGE})
|
||||
@Retention(RUNTIME)
|
||||
@Deprecated
|
||||
public @interface TypeDefs {
|
||||
/**
|
||||
* The grouping of type definitions.
|
||||
|
@ -46,6 +46,9 @@
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
|
||||
import org.hibernate.internal.SessionFactoryImpl;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.FetchProfile;
|
||||
import org.hibernate.mapping.MappedSuperclass;
|
||||
@ -59,6 +62,8 @@
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
import static org.hibernate.cfg.AvailableSettings.EVENT_LISTENER_PREFIX;
|
||||
|
||||
/**
|
||||
* Container for configuration data collected during binding the metamodel.
|
||||
*
|
||||
@ -376,21 +381,32 @@ public void initSessionFactory(SessionFactoryImplementor sessionFactory) {
|
||||
final ConfigurationService cfgService = sessionFactoryServiceRegistry.getService( ConfigurationService.class );
|
||||
final ClassLoaderService classLoaderService = sessionFactoryServiceRegistry.getService( ClassLoaderService.class );
|
||||
|
||||
for ( Map.Entry entry : ( (Map<?, ?>) cfgService.getSettings() ).entrySet() ) {
|
||||
for ( Map.Entry<?,?> entry : ( (Map<?, ?>) cfgService.getSettings() ).entrySet() ) {
|
||||
if ( !String.class.isInstance( entry.getKey() ) ) {
|
||||
continue;
|
||||
}
|
||||
final String propertyName = (String) entry.getKey();
|
||||
if ( !propertyName.startsWith( org.hibernate.jpa.AvailableSettings.EVENT_LISTENER_PREFIX ) ) {
|
||||
continue;
|
||||
}
|
||||
final String eventTypeName = propertyName.substring(
|
||||
org.hibernate.jpa.AvailableSettings.EVENT_LISTENER_PREFIX.length() + 1
|
||||
final String listenerPrefix = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> propertyName.startsWith( EVENT_LISTENER_PREFIX ) ? EVENT_LISTENER_PREFIX : null,
|
||||
() -> {
|
||||
if ( propertyName.startsWith( AvailableSettings.EVENT_LISTENER_PREFIX ) ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
AvailableSettings.EVENT_LISTENER_PREFIX,
|
||||
EVENT_LISTENER_PREFIX
|
||||
);
|
||||
return AvailableSettings.EVENT_LISTENER_PREFIX;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
() -> null
|
||||
);
|
||||
final EventType eventType = EventType.resolveEventTypeByName( eventTypeName );
|
||||
final EventListenerGroup eventListenerGroup = eventListenerRegistry.getEventListenerGroup( eventType );
|
||||
for ( String listenerImpl : LISTENER_SEPARATION_PATTERN.split( ( (String) entry.getValue() ) ) ) {
|
||||
eventListenerGroup.appendListener( instantiate( listenerImpl, classLoaderService ) );
|
||||
if ( listenerPrefix != null ) {
|
||||
final String eventTypeName = propertyName.substring( listenerPrefix.length() + 1 );
|
||||
final EventType eventType = EventType.resolveEventTypeByName( eventTypeName );
|
||||
final EventListenerGroup eventListenerGroup = eventListenerRegistry.getEventListenerGroup( eventType );
|
||||
for ( String listenerImpl : LISTENER_SEPARATION_PATTERN.split( ( (String) entry.getValue() ) ) ) {
|
||||
eventListenerGroup.appendListener( instantiate( listenerImpl, classLoaderService ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,7 @@
|
||||
import org.hibernate.id.uuid.LocalObjectUuidHelper;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.jpa.spi.JpaCompliance;
|
||||
import org.hibernate.jpa.spi.MutableJpaCompliance;
|
||||
@ -93,6 +94,7 @@
|
||||
import static org.hibernate.cfg.AvailableSettings.IN_CLAUSE_PARAMETER_PADDING;
|
||||
import static org.hibernate.cfg.AvailableSettings.JDBC_TIME_ZONE;
|
||||
import static org.hibernate.cfg.AvailableSettings.JDBC_TYLE_PARAMS_ZERO_BASE;
|
||||
import static org.hibernate.cfg.AvailableSettings.JPA_CALLBACKS_ENABLED;
|
||||
import static org.hibernate.cfg.AvailableSettings.JTA_TRACK_BY_THREAD;
|
||||
import static org.hibernate.cfg.AvailableSettings.LOG_SESSION_METRICS;
|
||||
import static org.hibernate.cfg.AvailableSettings.MAX_FETCH_DEPTH;
|
||||
@ -100,12 +102,12 @@
|
||||
import static org.hibernate.cfg.AvailableSettings.NATIVE_EXCEPTION_HANDLING_51_COMPLIANCE;
|
||||
import static org.hibernate.cfg.AvailableSettings.OMIT_JOIN_OF_SUPERCLASS_TABLES;
|
||||
import static org.hibernate.cfg.AvailableSettings.ORDER_INSERTS;
|
||||
import static org.hibernate.cfg.AvailableSettings.JPA_CALLBACKS_ENABLED;
|
||||
import static org.hibernate.cfg.AvailableSettings.ORDER_UPDATES;
|
||||
import static org.hibernate.cfg.AvailableSettings.PREFER_USER_TRANSACTION;
|
||||
import static org.hibernate.cfg.AvailableSettings.PROCEDURE_NULL_PARAM_PASSING;
|
||||
import static org.hibernate.cfg.AvailableSettings.QUERY_CACHE_FACTORY;
|
||||
import static org.hibernate.cfg.AvailableSettings.QUERY_STARTUP_CHECKING;
|
||||
import static org.hibernate.cfg.AvailableSettings.QUERY_STATISTICS_MAX_SIZE;
|
||||
import static org.hibernate.cfg.AvailableSettings.QUERY_SUBSTITUTIONS;
|
||||
import static org.hibernate.cfg.AvailableSettings.RELEASE_CONNECTIONS;
|
||||
import static org.hibernate.cfg.AvailableSettings.SESSION_FACTORY_NAME;
|
||||
@ -114,7 +116,6 @@
|
||||
import static org.hibernate.cfg.AvailableSettings.STATEMENT_BATCH_SIZE;
|
||||
import static org.hibernate.cfg.AvailableSettings.STATEMENT_FETCH_SIZE;
|
||||
import static org.hibernate.cfg.AvailableSettings.STATEMENT_INSPECTOR;
|
||||
import static org.hibernate.cfg.AvailableSettings.QUERY_STATISTICS_MAX_SIZE;
|
||||
import static org.hibernate.cfg.AvailableSettings.USE_DIRECT_REFERENCE_CACHE_ENTRIES;
|
||||
import static org.hibernate.cfg.AvailableSettings.USE_GET_GENERATED_KEYS;
|
||||
import static org.hibernate.cfg.AvailableSettings.USE_IDENTIFIER_ROLLBACK;
|
||||
@ -126,9 +127,9 @@
|
||||
import static org.hibernate.cfg.AvailableSettings.USE_STRUCTURED_CACHE;
|
||||
import static org.hibernate.cfg.AvailableSettings.VALIDATE_QUERY_PARAMETERS;
|
||||
import static org.hibernate.cfg.AvailableSettings.WRAP_RESULT_SETS;
|
||||
import static org.hibernate.cfg.AvailableSettings.DISCARD_PC_ON_CLOSE;
|
||||
import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN;
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
import static org.hibernate.jpa.AvailableSettings.DISCARD_PC_ON_CLOSE;
|
||||
|
||||
/**
|
||||
* In-flight state of {@link org.hibernate.boot.spi.SessionFactoryOptions}
|
||||
@ -465,11 +466,25 @@ public SessionFactoryOptionsBuilder(StandardServiceRegistry serviceRegistry, Boo
|
||||
false
|
||||
);
|
||||
|
||||
this.releaseResourcesOnCloseEnabled = ConfigurationHelper.getBoolean(
|
||||
DISCARD_PC_ON_CLOSE,
|
||||
configurationSettings,
|
||||
false
|
||||
this.releaseResourcesOnCloseEnabled = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> ConfigurationHelper.getBooleanWrapper( DISCARD_PC_ON_CLOSE, configurationSettings, null ),
|
||||
() -> {
|
||||
final Boolean oldSetting = ConfigurationHelper.getBooleanWrapper(
|
||||
org.hibernate.jpa.AvailableSettings.DISCARD_PC_ON_CLOSE,
|
||||
configurationSettings,
|
||||
null
|
||||
);
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.DISCARD_PC_ON_CLOSE,
|
||||
DISCARD_PC_ON_CLOSE
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
},
|
||||
() -> false
|
||||
);
|
||||
|
||||
Object jdbcTimeZoneValue = configurationSettings.get(
|
||||
JDBC_TIME_ZONE
|
||||
);
|
||||
@ -542,39 +557,40 @@ else if ( jdbcTimeZoneValue != null ) {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Interceptor determineInterceptor(Map configurationSettings, StrategySelector strategySelector) {
|
||||
Object setting = configurationSettings.get( INTERCEPTOR );
|
||||
if ( setting == null ) {
|
||||
// try the legacy (deprecated) JPA name
|
||||
setting = configurationSettings.get( org.hibernate.jpa.AvailableSettings.INTERCEPTOR );
|
||||
if ( setting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.INTERCEPTOR,
|
||||
INTERCEPTOR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return strategySelector.resolveStrategy(
|
||||
Interceptor.class,
|
||||
setting
|
||||
final Object setting = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> configurationSettings.get( INTERCEPTOR ),
|
||||
() -> {
|
||||
final Object oldSetting = configurationSettings.get( org.hibernate.jpa.AvailableSettings.INTERCEPTOR );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.INTERCEPTOR,
|
||||
INTERCEPTOR
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
}
|
||||
);
|
||||
|
||||
return strategySelector.resolveStrategy( Interceptor.class, setting );
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "deprecation"})
|
||||
private static Supplier<? extends Interceptor> determineStatelessInterceptor(
|
||||
Map configurationSettings,
|
||||
StrategySelector strategySelector) {
|
||||
Object setting = configurationSettings.get( SESSION_SCOPED_INTERCEPTOR );
|
||||
if ( setting == null ) {
|
||||
// try the legacy (deprecated) JPA name
|
||||
setting = configurationSettings.get( org.hibernate.jpa.AvailableSettings.SESSION_INTERCEPTOR );
|
||||
if ( setting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.SESSION_INTERCEPTOR,
|
||||
SESSION_SCOPED_INTERCEPTOR
|
||||
);
|
||||
}
|
||||
}
|
||||
Object setting = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> configurationSettings.get( SESSION_SCOPED_INTERCEPTOR ),
|
||||
() -> {
|
||||
final Object oldSetting = configurationSettings.get( org.hibernate.jpa.AvailableSettings.SESSION_INTERCEPTOR );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.SESSION_INTERCEPTOR,
|
||||
SESSION_SCOPED_INTERCEPTOR
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
}
|
||||
);
|
||||
|
||||
if ( setting == null ) {
|
||||
return null;
|
||||
|
@ -260,6 +260,11 @@ default boolean doesConnectionProviderDisableAutoCommit() {
|
||||
|
||||
boolean isPreferUserTransaction();
|
||||
|
||||
/**
|
||||
* @deprecated with no replacement. See {@link org.hibernate.cfg.AvailableSettings#PROCEDURE_NULL_PARAM_PASSING}
|
||||
* for details
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isProcedureParameterNullPassingEnabled();
|
||||
|
||||
boolean isCollectionJoinSubqueryRewriteEnabled();
|
||||
|
@ -881,6 +881,31 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
|
||||
// SessionFactoryBuilder level settings
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
/**
|
||||
* Event configuration should follow the following pattern
|
||||
* hibernate.event.listener.[eventType] f.q.c.n.EventListener1, f.q.c.n.EventListener12 ...
|
||||
*/
|
||||
String EVENT_LISTENER_PREFIX = "hibernate.event.listener";
|
||||
|
||||
/**
|
||||
* Used to pass along the name of the persistence unit.
|
||||
*/
|
||||
String PERSISTENCE_UNIT_NAME = "hibernate.persistenceUnitName";
|
||||
|
||||
/**
|
||||
* SessionFactoryObserver class name, the class must have a no-arg constructor
|
||||
*/
|
||||
String SESSION_FACTORY_OBSERVER = "hibernate.session_factory_observer";
|
||||
|
||||
/**
|
||||
* IdentifierGeneratorStrategyProvider class name, the class must have a no-arg constructor
|
||||
*
|
||||
* @deprecated with no replacement. Hooking in to Hibernate's id-generator determination
|
||||
* will be done very differently in Hibernate 6
|
||||
*/
|
||||
@Deprecated
|
||||
String IDENTIFIER_GENERATOR_STRATEGY_PROVIDER = "hibernate.identifier_generator_strategy_provider";
|
||||
|
||||
/**
|
||||
* Setting used to name the Hibernate {@link org.hibernate.SessionFactory}.
|
||||
*
|
||||
@ -896,6 +921,13 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
|
||||
*/
|
||||
String SESSION_FACTORY_NAME = "hibernate.session_factory_name";
|
||||
|
||||
/**
|
||||
* EntityManagerFactory name. Same purpose as {@value #SESSION_FACTORY_NAME}
|
||||
*
|
||||
* @see #SESSION_FACTORY_NAME
|
||||
*/
|
||||
String EMF_NAME = "hibernate.entitymanager_factory_name";
|
||||
|
||||
/**
|
||||
* Does the value defined by {@link #SESSION_FACTORY_NAME} represent a JNDI namespace into which
|
||||
* the {@link org.hibernate.SessionFactory} should be bound and made accessible?
|
||||
@ -910,6 +942,36 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
|
||||
*/
|
||||
String SESSION_FACTORY_NAME_IS_JNDI = "hibernate.session_factory_name_is_jndi";
|
||||
|
||||
/**
|
||||
* Whether to discard persistent context on {@link org.hibernate.Session#close} /
|
||||
* {@link javax.persistence.EntityManager#close}.
|
||||
*
|
||||
* The default (and spec compliant behavior) is false
|
||||
*/
|
||||
String DISCARD_PC_ON_CLOSE = "hibernate.discard_pc_on_close";
|
||||
|
||||
/**
|
||||
* Used to specify a Hibernate {@code cfg.xml} config file
|
||||
*/
|
||||
String CFG_XML_FILE = "hibernate.cfg_xml_file";
|
||||
String HBM_XML_FILES = "hibernate.hbm_xml_files";
|
||||
String ORM_XML_FILES = "hibernate.orm_xml_files";
|
||||
String LOADED_CLASSES = "hibernate.loaded_classes";
|
||||
|
||||
/**
|
||||
* Caching configuration should follow the following pattern
|
||||
* {@code hibernate.ejb.classcache.<fully.qualified.Classname> usage[, region]}
|
||||
* where usage is the cache strategy used and region the cache region name
|
||||
*/
|
||||
String CLASS_CACHE_PREFIX = "hibernate.classcache";
|
||||
|
||||
/**
|
||||
* Caching configuration should follow the following pattern
|
||||
* {@code hibernate.ejb.collectioncache.<fully.qualified.Classname>.<role> usage[, region]}
|
||||
* where usage is the cache strategy used and region the cache region name
|
||||
*/
|
||||
String COLLECTION_CACHE_PREFIX = "hibernate.collectioncache";
|
||||
|
||||
/**
|
||||
* Enable logging of generated SQL to the console
|
||||
*/
|
||||
|
@ -9,6 +9,8 @@
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.annotations.CollectionId;
|
||||
import org.hibernate.annotations.Type;
|
||||
@ -70,7 +72,7 @@ property, unique, associationTableBinder, ignoreNotFound, getBuildingContext()
|
||||
"id"
|
||||
);
|
||||
Ejb3Column[] idColumns = Ejb3Column.buildColumnFromAnnotation(
|
||||
collectionIdAnn.columns(),
|
||||
determineColumns( collectionIdAnn ),
|
||||
null,
|
||||
null,
|
||||
Nullability.FORCED_NOT_NULL,
|
||||
@ -131,4 +133,16 @@ property, unique, associationTableBinder, ignoreNotFound, getBuildingContext()
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Column[] determineColumns(CollectionId collectionIdAnn) {
|
||||
if ( collectionIdAnn.columns().length > 0 ) {
|
||||
return collectionIdAnn.columns();
|
||||
}
|
||||
final Column column = collectionIdAnn.column();
|
||||
if ( StringHelper.isNotEmpty( column.name() ) ) {
|
||||
return new Column[] { column };
|
||||
}
|
||||
// this should mimic the old behavior when `#columns` was not specified
|
||||
return new Column[0];
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,25 @@
|
||||
*/
|
||||
package org.hibernate.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.persistence.CacheRetrieveMode;
|
||||
import javax.persistence.CacheStoreMode;
|
||||
import javax.persistence.PessimisticLockScope;
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.BaselineSessionEventsListenerBuilder;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
|
||||
import org.hibernate.engine.jdbc.spi.ConnectionObserver;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
@ -52,7 +60,8 @@
|
||||
import org.hibernate.event.spi.ReplicateEventListener;
|
||||
import org.hibernate.event.spi.ResolveNaturalIdEventListener;
|
||||
import org.hibernate.event.spi.SaveOrUpdateEventListener;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
import org.hibernate.jpa.QueryHints;
|
||||
import org.hibernate.jpa.internal.util.CacheModeHelper;
|
||||
import org.hibernate.jpa.internal.util.ConfigurationHelper;
|
||||
@ -61,16 +70,6 @@
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.CacheRetrieveMode;
|
||||
import javax.persistence.CacheStoreMode;
|
||||
import javax.persistence.PessimisticLockScope;
|
||||
|
||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_JPA_LOCK_SCOPE;
|
||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_JPA_LOCK_TIMEOUT;
|
||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_JPA_SHARED_CACHE_RETRIEVE_MODE;
|
||||
@ -241,8 +240,20 @@ public final class FastSessionServices {
|
||||
}
|
||||
|
||||
private static FlushMode initializeDefaultFlushMode(Map<String, Object> defaultSessionProperties) {
|
||||
Object setMode = defaultSessionProperties.get( AvailableSettings.FLUSH_MODE );
|
||||
return ConfigurationHelper.getFlushMode( setMode, FlushMode.AUTO );
|
||||
final Object setting = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> defaultSessionProperties.get( AvailableSettings.FLUSH_MODE ),
|
||||
() -> {
|
||||
final Object oldSetting = defaultSessionProperties.get( org.hibernate.jpa.AvailableSettings.FLUSH_MODE );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.FLUSH_MODE,
|
||||
AvailableSettings.FLUSH_MODE
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
}
|
||||
);
|
||||
return ConfigurationHelper.getFlushMode( setting, FlushMode.AUTO );
|
||||
}
|
||||
|
||||
private static LockOptions initializeDefaultLockOptions(final Map<String, Object> defaultSessionProperties) {
|
||||
|
@ -71,8 +71,8 @@
|
||||
import org.hibernate.UnresolvableObjectException;
|
||||
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
|
||||
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
|
||||
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
|
||||
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.criterion.NaturalIdentifier;
|
||||
import org.hibernate.engine.internal.StatefulPersistenceContext;
|
||||
@ -91,8 +91,6 @@
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.engine.spi.NamedQueryDefinition;
|
||||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||
import org.hibernate.engine.spi.QueryParameters;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
@ -140,7 +138,7 @@
|
||||
import org.hibernate.hql.spi.QueryTranslator;
|
||||
import org.hibernate.internal.CriteriaImpl.CriterionEntry;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
import org.hibernate.jpa.QueryHints;
|
||||
import org.hibernate.jpa.internal.util.CacheModeHelper;
|
||||
import org.hibernate.jpa.internal.util.ConfigurationHelper;
|
||||
@ -271,6 +269,19 @@ public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
|
||||
initialMode = fastSessionServices.initialSessionFlushMode;
|
||||
}
|
||||
else {
|
||||
final Object setting = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> getSessionProperty( AvailableSettings.FLUSH_MODE ),
|
||||
() -> {
|
||||
final Object oldSetting = getSessionProperty( org.hibernate.jpa.AvailableSettings.FLUSH_MODE );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.FLUSH_MODE,
|
||||
AvailableSettings.FLUSH_MODE
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
}
|
||||
);
|
||||
initialMode = ConfigurationHelper.getFlushMode( getSessionProperty( AvailableSettings.FLUSH_MODE ), FlushMode.AUTO );
|
||||
}
|
||||
getSession().setHibernateFlushMode( initialMode );
|
||||
@ -3603,7 +3614,8 @@ public void setProperty(String propertyName, Object value) {
|
||||
|
||||
//now actually update settings, if it's any of these which have a direct impact on this Session state:
|
||||
|
||||
if ( AvailableSettings.FLUSH_MODE.equals( propertyName ) ) {
|
||||
if ( AvailableSettings.FLUSH_MODE.equals( propertyName )
|
||||
|| org.hibernate.jpa.AvailableSettings.FLUSH_MODE.equals( propertyName ) ) {
|
||||
setHibernateFlushMode( ConfigurationHelper.getFlushMode( value, FlushMode.AUTO ) );
|
||||
}
|
||||
else if ( JPA_LOCK_SCOPE.equals( propertyName ) || JPA_LOCK_TIMEOUT.equals( propertyName )
|
||||
|
@ -12,7 +12,10 @@
|
||||
* NOTE : Does *not* include {@link org.hibernate.cfg.Environment} values.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings} instead. Will be removed in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AvailableSettings {
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -278,37 +281,48 @@ public interface AvailableSettings {
|
||||
|
||||
/**
|
||||
* cfg.xml configuration file used
|
||||
*
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#CFG_XML_FILE}
|
||||
*/
|
||||
@Deprecated
|
||||
String CFG_FILE = "hibernate.ejb.cfgfile";
|
||||
|
||||
/**
|
||||
* Caching configuration should follow the following pattern
|
||||
* {@code hibernate.ejb.classcache.<fully.qualified.Classname> usage[, region]}
|
||||
* where usage is the cache strategy used and region the cache region name
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#CLASS_CACHE_PREFIX}
|
||||
*/
|
||||
@Deprecated
|
||||
String CLASS_CACHE_PREFIX = "hibernate.ejb.classcache";
|
||||
|
||||
/**
|
||||
* Caching configuration should follow the following pattern
|
||||
* {@code hibernate.ejb.collectioncache.<fully.qualified.Classname>.<role> usage[, region]}
|
||||
* where usage is the cache strategy used and region the cache region name
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#COLLECTION_CACHE_PREFIX}
|
||||
*/
|
||||
@Deprecated
|
||||
String COLLECTION_CACHE_PREFIX = "hibernate.ejb.collectioncache";
|
||||
|
||||
/**
|
||||
* SessionFactoryObserver class name, the class must have a no-arg constructor
|
||||
*
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#SESSION_FACTORY_OBSERVER} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String SESSION_FACTORY_OBSERVER = "hibernate.ejb.session_factory_observer";
|
||||
|
||||
/**
|
||||
* IdentifierGeneratorStrategyProvider class name, the class must have a no-arg constructor
|
||||
*
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#IDENTIFIER_GENERATOR_STRATEGY_PROVIDER}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
String IDENTIFIER_GENERATOR_STRATEGY_PROVIDER = "hibernate.ejb.identifier_generator_strategy_provider";
|
||||
|
||||
/**
|
||||
* Event configuration should follow the following pattern
|
||||
* hibernate.ejb.event.[eventType] f.q.c.n.EventListener1, f.q.c.n.EventListener12 ...
|
||||
*
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#EVENT_LISTENER_PREFIX} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String EVENT_LISTENER_PREFIX = "hibernate.ejb.event";
|
||||
|
||||
/**
|
||||
@ -327,9 +341,9 @@ public interface AvailableSettings {
|
||||
String ENHANCER_ENABLE_ASSOCIATION_MANAGEMENT = "hibernate.enhancer.enableAssociationManagement";
|
||||
|
||||
/**
|
||||
* Whether or not discard persistent context on entityManager.close()
|
||||
* The EJB3 compliant and default choice is false
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#DISCARD_PC_ON_CLOSE} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String DISCARD_PC_ON_CLOSE = "hibernate.ejb.discard_pc_on_close";
|
||||
|
||||
|
||||
@ -342,22 +356,36 @@ public interface AvailableSettings {
|
||||
|
||||
/**
|
||||
* EntityManagerFactory name
|
||||
*
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#EMF_NAME} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String ENTITY_MANAGER_FACTORY_NAME = "hibernate.ejb.entitymanager_factory_name";
|
||||
|
||||
|
||||
/**
|
||||
* List of classes names
|
||||
* Internal use only
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#ORM_XML_FILES}
|
||||
*/
|
||||
@Deprecated
|
||||
String XML_FILE_NAMES = "hibernate.ejb.xml_files";
|
||||
/**
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#HBM_XML_FILES}
|
||||
*/
|
||||
@Deprecated
|
||||
String HBXML_FILES = "hibernate.hbmxml.files";
|
||||
/**
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#LOADED_CLASSES}
|
||||
*/
|
||||
@Deprecated
|
||||
String LOADED_CLASSES = "hibernate.ejb.loaded.classes";
|
||||
|
||||
|
||||
/**
|
||||
* Used to pass along the name of the persistence unit.
|
||||
*
|
||||
* @deprecated Use {@link org.hibernate.cfg.AvailableSettings#PERSISTENCE_UNIT_NAME} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String PERSISTENCE_UNIT_NAME = "hibernate.ejb.persistenceUnitName";
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,10 @@
|
||||
|
||||
import org.hibernate.Metamodel;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
|
||||
/**
|
||||
* Contract giving access to the underlying {@link org.hibernate.SessionFactory} from an {@link javax.persistence.EntityManagerFactory}
|
||||
@ -64,7 +67,19 @@ default SessionFactoryImplementor getSessionFactory() {
|
||||
*/
|
||||
@Deprecated
|
||||
default String getEntityManagerFactoryName() {
|
||||
return (String) getProperties().get( AvailableSettings.ENTITY_MANAGER_FACTORY_NAME );
|
||||
return NullnessHelper.coalesceSuppliedValues(
|
||||
() -> (String) getProperties().get( AvailableSettings.EMF_NAME ),
|
||||
() -> {
|
||||
final String oldSetting = (String) getProperties().get( AvailableSettings.ENTITY_MANAGER_FACTORY_NAME );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
AvailableSettings.ENTITY_MANAGER_FACTORY_NAME,
|
||||
AvailableSettings.EMF_NAME
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,6 @@
|
||||
import org.hibernate.boot.cfgxml.spi.CfgXmlAccessService;
|
||||
import org.hibernate.boot.cfgxml.spi.LoadedConfig;
|
||||
import org.hibernate.boot.cfgxml.spi.MappingReference;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.model.process.spi.MetadataBuildingProcess;
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
||||
@ -53,6 +52,7 @@
|
||||
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
|
||||
import org.hibernate.bytecode.enhance.spi.UnloadedField;
|
||||
import org.hibernate.cfg.AttributeConverterDefinition;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
@ -60,10 +60,10 @@
|
||||
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
|
||||
import org.hibernate.integrator.spi.Integrator;
|
||||
import org.hibernate.internal.EntityManagerMessageLogger;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
||||
import org.hibernate.jpa.boot.spi.IntegratorProvider;
|
||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||
@ -87,6 +87,7 @@
|
||||
|
||||
import org.jboss.jandex.Index;
|
||||
|
||||
import static org.hibernate.cfg.AvailableSettings.CFG_XML_FILE;
|
||||
import static org.hibernate.cfg.AvailableSettings.DATASOURCE;
|
||||
import static org.hibernate.cfg.AvailableSettings.DRIVER;
|
||||
import static org.hibernate.cfg.AvailableSettings.JACC_CONTEXT_ID;
|
||||
@ -111,6 +112,7 @@
|
||||
import static org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_TYPE;
|
||||
import static org.hibernate.cfg.AvailableSettings.JPA_VALIDATION_MODE;
|
||||
import static org.hibernate.cfg.AvailableSettings.PASS;
|
||||
import static org.hibernate.cfg.AvailableSettings.PERSISTENCE_UNIT_NAME;
|
||||
import static org.hibernate.cfg.AvailableSettings.SESSION_FACTORY_NAME;
|
||||
import static org.hibernate.cfg.AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY;
|
||||
import static org.hibernate.cfg.AvailableSettings.URL;
|
||||
@ -119,7 +121,6 @@
|
||||
import static org.hibernate.jpa.AvailableSettings.CFG_FILE;
|
||||
import static org.hibernate.jpa.AvailableSettings.CLASS_CACHE_PREFIX;
|
||||
import static org.hibernate.jpa.AvailableSettings.COLLECTION_CACHE_PREFIX;
|
||||
import static org.hibernate.jpa.AvailableSettings.PERSISTENCE_UNIT_NAME;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
@ -505,11 +506,25 @@ private MergedSettings mergeSettings(
|
||||
mergedSettings.processPersistenceUnitDescriptorProperties( persistenceUnit );
|
||||
|
||||
// see if the persistence.xml settings named a Hibernate config file....
|
||||
String cfgXmlResourceName = (String) mergedSettings.configurationValues.remove( CFG_FILE );
|
||||
if ( StringHelper.isEmpty( cfgXmlResourceName ) ) {
|
||||
// see if integration settings named a Hibernate config file....
|
||||
cfgXmlResourceName = (String) integrationSettings.get( CFG_FILE );
|
||||
}
|
||||
final String cfgXmlResourceName = NullnessHelper.coalesceSuppliedValues(
|
||||
// first see if we can find it in the configurationValues
|
||||
() -> (String) mergedSettings.configurationValues.remove( CFG_XML_FILE ),
|
||||
() -> {
|
||||
final String oldSetting = (String) mergedSettings.configurationValues.remove( CFG_FILE );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting( CFG_FILE, CFG_XML_FILE);
|
||||
}
|
||||
return oldSetting;
|
||||
},
|
||||
() -> (String) integrationSettings.get( CFG_XML_FILE ),
|
||||
() -> {
|
||||
final String oldSetting = (String) integrationSettings.get( CFG_FILE );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting( CFG_FILE, CFG_XML_FILE);
|
||||
}
|
||||
return oldSetting;
|
||||
}
|
||||
);
|
||||
|
||||
if ( StringHelper.isNotEmpty( cfgXmlResourceName ) ) {
|
||||
processHibernateConfigXmlResources( ssrBuilder, mergedSettings, cfgXmlResourceName );
|
||||
@ -524,16 +539,16 @@ private MergedSettings mergeSettings(
|
||||
// 2) additional cache region declarations
|
||||
//
|
||||
// we will also clean up any references with null entries
|
||||
Iterator itr = mergedSettings.configurationValues.entrySet().iterator();
|
||||
Iterator<Map.Entry> itr = mergedSettings.configurationValues.entrySet().iterator();
|
||||
while ( itr.hasNext() ) {
|
||||
final Map.Entry entry = (Map.Entry) itr.next();
|
||||
final Map.Entry entry = itr.next();
|
||||
if ( entry.getValue() == null ) {
|
||||
// remove entries with null values
|
||||
itr.remove();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( String.class.isInstance( entry.getKey() ) && String.class.isInstance( entry.getValue() ) ) {
|
||||
if ( entry.getKey() instanceof String && entry.getValue() instanceof String ) {
|
||||
final String keyString = (String) entry.getKey();
|
||||
final String valueString = (String) entry.getValue();
|
||||
|
||||
@ -552,7 +567,20 @@ private MergedSettings mergeSettings(
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( keyString.startsWith( AvailableSettings.CLASS_CACHE_PREFIX ) ) {
|
||||
mergedSettings.addCacheRegionDefinition(
|
||||
parseCacheRegionDefinitionEntry(
|
||||
keyString.substring( AvailableSettings.CLASS_CACHE_PREFIX.length() + 1 ),
|
||||
valueString,
|
||||
CacheRegionDefinition.CacheRegionType.ENTITY
|
||||
)
|
||||
);
|
||||
}
|
||||
else if ( keyString.startsWith( CLASS_CACHE_PREFIX ) ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
CLASS_CACHE_PREFIX,
|
||||
AvailableSettings.CLASS_CACHE_PREFIX
|
||||
);
|
||||
mergedSettings.addCacheRegionDefinition(
|
||||
parseCacheRegionDefinitionEntry(
|
||||
keyString.substring( CLASS_CACHE_PREFIX.length() + 1 ),
|
||||
@ -561,7 +589,20 @@ else if ( keyString.startsWith( CLASS_CACHE_PREFIX ) ) {
|
||||
)
|
||||
);
|
||||
}
|
||||
else if ( keyString.startsWith( AvailableSettings.COLLECTION_CACHE_PREFIX ) ) {
|
||||
mergedSettings.addCacheRegionDefinition(
|
||||
parseCacheRegionDefinitionEntry(
|
||||
keyString.substring( AvailableSettings.COLLECTION_CACHE_PREFIX.length() + 1 ),
|
||||
(String) entry.getValue(),
|
||||
CacheRegionDefinition.CacheRegionType.COLLECTION
|
||||
)
|
||||
);
|
||||
}
|
||||
else if ( keyString.startsWith( COLLECTION_CACHE_PREFIX ) ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
COLLECTION_CACHE_PREFIX,
|
||||
AvailableSettings.COLLECTION_CACHE_PREFIX
|
||||
);
|
||||
mergedSettings.addCacheRegionDefinition(
|
||||
parseCacheRegionDefinitionEntry(
|
||||
keyString.substring( COLLECTION_CACHE_PREFIX.length() + 1 ),
|
||||
@ -1152,14 +1193,14 @@ private CacheRegionDefinition parseCacheRegionDefinitionEntry(String role, Strin
|
||||
if ( !params.hasMoreTokens() ) {
|
||||
StringBuilder error = new StringBuilder( "Illegal usage of " );
|
||||
if ( cacheType == CacheRegionDefinition.CacheRegionType.ENTITY ) {
|
||||
error.append( CLASS_CACHE_PREFIX )
|
||||
error.append( AvailableSettings.CLASS_CACHE_PREFIX )
|
||||
.append( ": " )
|
||||
.append( CLASS_CACHE_PREFIX );
|
||||
.append( AvailableSettings.CLASS_CACHE_PREFIX );
|
||||
}
|
||||
else {
|
||||
error.append( COLLECTION_CACHE_PREFIX )
|
||||
error.append( AvailableSettings.COLLECTION_CACHE_PREFIX )
|
||||
.append( ": " )
|
||||
.append( COLLECTION_CACHE_PREFIX );
|
||||
.append( AvailableSettings.COLLECTION_CACHE_PREFIX );
|
||||
}
|
||||
error.append( '.' )
|
||||
.append( role )
|
||||
@ -1191,10 +1232,24 @@ private void configureIdentifierGenerators(StandardServiceRegistry ssr) {
|
||||
final StrategySelector strategySelector = ssr.getService( StrategySelector.class );
|
||||
|
||||
// apply id generators
|
||||
final Object idGeneratorStrategyProviderSetting = configurationValues.remove( AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER );
|
||||
final Object idGeneratorStrategyProviderSetting = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> configurationValues.remove( AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER ),
|
||||
() -> {
|
||||
final Object oldSetting = configurationValues.remove( org.hibernate.jpa.AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER,
|
||||
AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
}
|
||||
);
|
||||
if ( idGeneratorStrategyProviderSetting != null ) {
|
||||
final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider =
|
||||
strategySelector.resolveStrategy( IdentifierGeneratorStrategyProvider.class, idGeneratorStrategyProviderSetting );
|
||||
final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = strategySelector.resolveStrategy(
|
||||
IdentifierGeneratorStrategyProvider.class,
|
||||
idGeneratorStrategyProviderSetting
|
||||
);
|
||||
final MutableIdentifierGeneratorFactory identifierGeneratorFactory = ssr.getService( MutableIdentifierGeneratorFactory.class );
|
||||
if ( identifierGeneratorFactory == null ) {
|
||||
throw persistenceException(
|
||||
@ -1256,9 +1311,17 @@ private List<AttributeConverterDefinition> applyMappingResources(MetadataSources
|
||||
List<AttributeConverterDefinition> attributeConverterDefinitions = null;
|
||||
|
||||
// add any explicit Class references passed in
|
||||
final List<Class> loadedAnnotatedClasses = (List<Class>) configurationValues.remove( AvailableSettings.LOADED_CLASSES );
|
||||
if ( loadedAnnotatedClasses != null ) {
|
||||
for ( Class cls : loadedAnnotatedClasses ) {
|
||||
final List<Class> annotatedClasses = (List<Class>) configurationValues.remove( AvailableSettings.LOADED_CLASSES );
|
||||
final List<Class> oldAnnotatedClasses = (List<Class>) configurationValues.remove( org.hibernate.jpa.AvailableSettings.LOADED_CLASSES );
|
||||
if ( oldAnnotatedClasses != null && ! oldAnnotatedClasses.isEmpty() ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.LOADED_CLASSES,
|
||||
AvailableSettings.LOADED_CLASSES
|
||||
);
|
||||
}
|
||||
final List<Class> explicitAnnotatedClasses = NullnessHelper.coalesce( annotatedClasses, oldAnnotatedClasses );
|
||||
if ( explicitAnnotatedClasses != null ) {
|
||||
for ( Class cls : explicitAnnotatedClasses ) {
|
||||
if ( AttributeConverter.class.isAssignableFrom( cls ) ) {
|
||||
if ( attributeConverterDefinitions == null ) {
|
||||
attributeConverterDefinitions = new ArrayList<>();
|
||||
@ -1272,15 +1335,31 @@ private List<AttributeConverterDefinition> applyMappingResources(MetadataSources
|
||||
}
|
||||
|
||||
// add any explicit hbm.xml references passed in
|
||||
final String explicitHbmXmls = (String) configurationValues.remove( AvailableSettings.HBXML_FILES );
|
||||
if ( explicitHbmXmls != null ) {
|
||||
for ( String hbmXml : StringHelper.split( ", ", explicitHbmXmls ) ) {
|
||||
final String hbmXmlFiles = (String) configurationValues.remove( AvailableSettings.HBM_XML_FILES );
|
||||
final String oldHbmXmlFiles = (String) configurationValues.remove( AvailableSettings.HBXML_FILES );
|
||||
if ( oldHbmXmlFiles != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
AvailableSettings.HBXML_FILES,
|
||||
AvailableSettings.HBM_XML_FILES
|
||||
);
|
||||
}
|
||||
final String explicitHbmXmlFiles = NullnessHelper.coalesce( hbmXmlFiles, oldHbmXmlFiles );
|
||||
if ( explicitHbmXmlFiles != null ) {
|
||||
for ( String hbmXml : StringHelper.split( ", ", explicitHbmXmlFiles ) ) {
|
||||
metadataSources.addResource( hbmXml );
|
||||
}
|
||||
}
|
||||
|
||||
// add any explicit orm.xml references passed in
|
||||
final List<String> explicitOrmXmlList = (List<String>) configurationValues.remove( AvailableSettings.XML_FILE_NAMES );
|
||||
final List<String> ormXmlFiles = (List<String>) configurationValues.remove( AvailableSettings.ORM_XML_FILES );
|
||||
final List<String> oldOrmXmlFiles = (List<String>) configurationValues.remove( AvailableSettings.XML_FILE_NAMES );
|
||||
if ( oldOrmXmlFiles != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
AvailableSettings.XML_FILE_NAMES,
|
||||
AvailableSettings.ORM_XML_FILES
|
||||
);
|
||||
}
|
||||
final List<String> explicitOrmXmlList = NullnessHelper.coalesce( ormXmlFiles, oldOrmXmlFiles );
|
||||
if ( explicitOrmXmlList != null ) {
|
||||
explicitOrmXmlList.forEach( metadataSources::addResource );
|
||||
}
|
||||
@ -1455,10 +1534,24 @@ protected void populateSfBuilder(SessionFactoryBuilder sfBuilder, StandardServic
|
||||
}
|
||||
|
||||
// Locate and apply any requested SessionFactoryObserver
|
||||
final Object sessionFactoryObserverSetting = configurationValues.remove( AvailableSettings.SESSION_FACTORY_OBSERVER );
|
||||
final Object sessionFactoryObserverSetting = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> configurationValues.remove( AvailableSettings.SESSION_FACTORY_OBSERVER ),
|
||||
() -> {
|
||||
final Object oldSetting = configurationValues.remove( org.hibernate.jpa.AvailableSettings.SESSION_FACTORY_OBSERVER );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.SESSION_FACTORY_OBSERVER,
|
||||
AvailableSettings.SESSION_FACTORY_OBSERVER
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
}
|
||||
);
|
||||
if ( sessionFactoryObserverSetting != null ) {
|
||||
final SessionFactoryObserver suppliedSessionFactoryObserver =
|
||||
strategySelector.resolveStrategy( SessionFactoryObserver.class, sessionFactoryObserverSetting );
|
||||
final SessionFactoryObserver suppliedSessionFactoryObserver = strategySelector.resolveStrategy(
|
||||
SessionFactoryObserver.class,
|
||||
sessionFactoryObserverSetting
|
||||
);
|
||||
sfBuilder.addSessionFactoryObservers( suppliedSessionFactoryObserver );
|
||||
}
|
||||
|
||||
@ -1529,6 +1622,7 @@ public void processPersistenceUnitDescriptorProperties(PersistenceUnitDescriptor
|
||||
}
|
||||
|
||||
configurationValues.put( PERSISTENCE_UNIT_NAME, persistenceUnit.getName() );
|
||||
configurationValues.put( org.hibernate.jpa.AvailableSettings.PERSISTENCE_UNIT_NAME, persistenceUnit.getName() );
|
||||
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,10 @@ public interface ProcedureParameter<T> extends QueryParameter<T> {
|
||||
* @param enabled {@code true} indicates that the NULL should be passed; {@code false} indicates it should not.
|
||||
*
|
||||
* @see org.hibernate.procedure.ParameterRegistration#enablePassingNulls
|
||||
*
|
||||
* @deprecated with no replacement. See {@link org.hibernate.cfg.AvailableSettings#PROCEDURE_NULL_PARAM_PASSING}
|
||||
* for details
|
||||
*/
|
||||
@Deprecated
|
||||
void enablePassingNulls(boolean enabled);
|
||||
}
|
||||
|
@ -12,10 +12,12 @@
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.engine.config.spi.StandardConverters;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.internal.util.NullnessHelper;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.resource.beans.container.spi.BeanContainer;
|
||||
import org.hibernate.resource.beans.spi.ManagedBeanRegistryInitiator;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
@ -56,7 +58,20 @@ public static BeanContainer fromBeanManagerReference(
|
||||
ctorArgType = beanManagerClass;
|
||||
|
||||
final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final boolean delayAccessToCdi = cfgService.getSetting( AvailableSettings.DELAY_CDI_ACCESS, StandardConverters.BOOLEAN, false );
|
||||
final boolean delayAccessToCdi = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> cfgService.getSetting( AvailableSettings.DELAY_CDI_ACCESS, StandardConverters.BOOLEAN ),
|
||||
() -> {
|
||||
final Boolean oldSetting = cfgService.getSetting( org.hibernate.jpa.AvailableSettings.DELAY_CDI_ACCESS, StandardConverters.BOOLEAN );
|
||||
if ( oldSetting != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
org.hibernate.jpa.AvailableSettings.DELAY_CDI_ACCESS,
|
||||
AvailableSettings.DELAY_CDI_ACCESS
|
||||
);
|
||||
}
|
||||
return oldSetting;
|
||||
},
|
||||
() -> false
|
||||
);
|
||||
if ( delayAccessToCdi ) {
|
||||
containerClass = getHibernateClass( CONTAINER_FQN_DELAYED );
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public void test() throws InterruptedException {
|
||||
Thread thread = new Thread( () -> {
|
||||
try {
|
||||
final Properties props = new Properties();
|
||||
props.setProperty( AvailableSettings.CFG_FILE, "/org/hibernate/test/boot/cfgXml/hibernate.cfg.xml" );
|
||||
props.setProperty( AvailableSettings.CFG_XML_FILE, "/org/hibernate/test/boot/cfgXml/hibernate.cfg.xml" );
|
||||
|
||||
Persistence.createEntityManagerFactory( "ExcludeUnlistedClassesTest1", props );
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ protected Map buildSettings() {
|
||||
protected void addMappings(Map settings) {
|
||||
String[] mappings = getMappings();
|
||||
if ( mappings != null ) {
|
||||
settings.put( AvailableSettings.HBXML_FILES, String.join( ",", mappings ) );
|
||||
settings.put( AvailableSettings.HBM_XML_FILES, String.join( ",", mappings ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,9 +223,9 @@ protected Map getConfig() {
|
||||
config.put( AvailableSettings.COLLECTION_CACHE_PREFIX + "." + entry.getKey(), entry.getValue() );
|
||||
}
|
||||
if ( getEjb3DD().length > 0 ) {
|
||||
ArrayList<String> dds = new ArrayList<String>();
|
||||
ArrayList<String> dds = new ArrayList<>();
|
||||
dds.addAll( Arrays.asList( getEjb3DD() ) );
|
||||
config.put( AvailableSettings.XML_FILE_NAMES, dds );
|
||||
config.put( AvailableSettings.ORM_XML_FILES, dds );
|
||||
}
|
||||
|
||||
config.put( GlobalTemporaryTableBulkIdStrategy.DROP_ID_TABLES, "true" );
|
||||
|
@ -12,8 +12,8 @@
|
||||
import java.util.Map;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||
|
@ -27,8 +27,8 @@
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.QueryHints;
|
||||
import org.hibernate.stat.Statistics;
|
||||
|
@ -13,7 +13,7 @@
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.ValidatorFactory;
|
||||
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
||||
|
@ -14,8 +14,7 @@
|
||||
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.test.PersistenceUnitInfoAdapter;
|
||||
@ -114,11 +113,11 @@ public void testSharedCacheModeDisable() {
|
||||
assertTrue( pc.isCached() );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private MetadataImplementor buildMetadata(SharedCacheMode mode) {
|
||||
Map settings = new HashMap();
|
||||
settings.put( AvailableSettings.SHARED_CACHE_MODE, mode );
|
||||
settings.put( Environment.CACHE_REGION_FACTORY, CustomRegionFactory.class.getName() );
|
||||
final Map settings = new HashMap<>();
|
||||
settings.put( AvailableSettings.JPA_SHARED_CACHE_MODE, mode );
|
||||
settings.put( AvailableSettings.CACHE_REGION_FACTORY, CustomRegionFactory.class.getName() );
|
||||
settings.put(
|
||||
AvailableSettings.LOADED_CLASSES,
|
||||
Arrays.asList(
|
||||
|
@ -6,17 +6,15 @@
|
||||
*/
|
||||
package org.hibernate.jpa.test.cacheable.api;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.cache.CachingRegionFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -33,10 +31,8 @@ protected Class<?>[] getAnnotatedClasses() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addConfigOptions(Map options) {
|
||||
// options.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" );
|
||||
options.put( AvailableSettings.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() );
|
||||
// options.put( AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, "read-write" );
|
||||
options.put( org.hibernate.jpa.AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.ALL );
|
||||
options.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ALL );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManager;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
@ -39,62 +39,62 @@ public void testEntityManagerCacheModes() {
|
||||
session = ( (HibernateEntityManager) em ).getSession();
|
||||
|
||||
// defaults...
|
||||
assertEquals( CacheStoreMode.USE, em.getProperties().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheRetrieveMode.USE, em.getProperties().get( AvailableSettings.SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheStoreMode.USE, em.getProperties().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheRetrieveMode.USE, em.getProperties().get( AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheMode.NORMAL, session.getCacheMode() );
|
||||
|
||||
// overrides...
|
||||
em.setProperty( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.REFRESH );
|
||||
assertEquals( CacheStoreMode.REFRESH, em.getProperties().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
em.setProperty( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.REFRESH );
|
||||
assertEquals( CacheStoreMode.REFRESH, em.getProperties().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.REFRESH, session.getCacheMode() );
|
||||
|
||||
em.setProperty( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.BYPASS );
|
||||
assertEquals( CacheStoreMode.BYPASS, em.getProperties().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
em.setProperty( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.BYPASS );
|
||||
assertEquals( CacheStoreMode.BYPASS, em.getProperties().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.GET, session.getCacheMode() );
|
||||
|
||||
em.setProperty( AvailableSettings.SHARED_CACHE_RETRIEVE_MODE, CacheRetrieveMode.BYPASS );
|
||||
assertEquals( CacheRetrieveMode.BYPASS, em.getProperties().get( AvailableSettings.SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
em.setProperty( AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE, CacheRetrieveMode.BYPASS );
|
||||
assertEquals( CacheRetrieveMode.BYPASS, em.getProperties().get( AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheMode.IGNORE, session.getCacheMode() );
|
||||
|
||||
em.setProperty( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.USE );
|
||||
assertEquals( CacheStoreMode.USE, em.getProperties().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
em.setProperty( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.USE );
|
||||
assertEquals( CacheStoreMode.USE, em.getProperties().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.PUT, session.getCacheMode() );
|
||||
|
||||
em.setProperty( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.REFRESH );
|
||||
assertEquals( CacheStoreMode.REFRESH, em.getProperties().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
em.setProperty( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.REFRESH );
|
||||
assertEquals( CacheStoreMode.REFRESH, em.getProperties().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.REFRESH, session.getCacheMode() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryCacheModes() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
org.hibernate.query.Query query = em.createQuery( "from SimpleEntity" ).unwrap( org.hibernate.query.Query.class );
|
||||
org.hibernate.query.Query<?> query = em.createQuery( "from SimpleEntity" ).unwrap( org.hibernate.query.Query.class );
|
||||
|
||||
query.setHint( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.USE );
|
||||
assertEquals( CacheStoreMode.USE, query.getHints().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
query.setHint( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.USE );
|
||||
assertEquals( CacheStoreMode.USE, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.NORMAL, query.getCacheMode() );
|
||||
|
||||
query.setHint( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.BYPASS );
|
||||
assertEquals( CacheStoreMode.BYPASS, query.getHints().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
query.setHint( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.BYPASS );
|
||||
assertEquals( CacheStoreMode.BYPASS, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.GET, query.getCacheMode() );
|
||||
|
||||
query.setHint( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.REFRESH );
|
||||
assertEquals( CacheStoreMode.REFRESH, query.getHints().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
query.setHint( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.REFRESH );
|
||||
assertEquals( CacheStoreMode.REFRESH, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.REFRESH, query.getCacheMode() );
|
||||
|
||||
query.setHint( AvailableSettings.SHARED_CACHE_RETRIEVE_MODE, CacheRetrieveMode.BYPASS );
|
||||
assertEquals( CacheRetrieveMode.BYPASS, query.getHints().get( AvailableSettings.SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheStoreMode.REFRESH, query.getHints().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
query.setHint( AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE, CacheRetrieveMode.BYPASS );
|
||||
assertEquals( CacheRetrieveMode.BYPASS, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheStoreMode.REFRESH, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.REFRESH, query.getCacheMode() );
|
||||
|
||||
query.setHint( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.BYPASS );
|
||||
assertEquals( CacheRetrieveMode.BYPASS, query.getHints().get( AvailableSettings.SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheStoreMode.BYPASS, query.getHints().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
query.setHint( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.BYPASS );
|
||||
assertEquals( CacheRetrieveMode.BYPASS, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheStoreMode.BYPASS, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.IGNORE, query.getCacheMode() );
|
||||
|
||||
query.setHint( AvailableSettings.SHARED_CACHE_STORE_MODE, CacheStoreMode.USE );
|
||||
assertEquals( CacheRetrieveMode.BYPASS, query.getHints().get( AvailableSettings.SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheStoreMode.USE, query.getHints().get( AvailableSettings.SHARED_CACHE_STORE_MODE ) );
|
||||
query.setHint( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE, CacheStoreMode.USE );
|
||||
assertEquals( CacheRetrieveMode.BYPASS, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE ) );
|
||||
assertEquals( CacheStoreMode.USE, query.getHints().get( AvailableSettings.JPA_SHARED_CACHE_STORE_MODE ) );
|
||||
assertEquals( CacheMode.PUT, query.getCacheMode() );
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
||||
@ -31,7 +31,7 @@ public class MappingClassMoreThanOnceTest extends BaseUnitTestCase {
|
||||
// @FailureExpected(jiraKey = "HHH-8775")
|
||||
public void testBootstrapWithClassMappedMOreThanOnce() {
|
||||
Map settings = new HashMap( );
|
||||
settings.put( AvailableSettings.HBXML_FILES, "org/hibernate/jpa/test/callbacks/hbmxml/ClassMappedMoreThanOnce.hbm.xml" );
|
||||
settings.put( AvailableSettings.HBM_XML_FILES, "org/hibernate/jpa/test/callbacks/hbmxml/ClassMappedMoreThanOnce.hbm.xml" );
|
||||
|
||||
final EntityManagerFactoryBuilder builder = Bootstrap.getEntityManagerFactoryBuilder(
|
||||
new BaseEntityManagerFunctionalTestCase.TestingPersistenceUnitDescriptorImpl( getClass().getSimpleName() ),
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.hibernate.jpa.test.PersistenceUnitInfoAdapter;
|
||||
|
||||
|
@ -10,8 +10,8 @@
|
||||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.jpa.test.Wallet;
|
||||
|
||||
|
@ -9,15 +9,13 @@
|
||||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.jpa.test.Wallet;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -16,13 +16,10 @@
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.SessionFactoryBuilder;
|
||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.test.Distributor;
|
||||
import org.hibernate.jpa.test.Item;
|
||||
@ -89,7 +86,7 @@ public void testDeprecatedConfiguredInterceptor() {
|
||||
@Test
|
||||
public void testDeprecatedConfiguredSessionInterceptor() {
|
||||
Map settings = basicSettings();
|
||||
settings.put( AvailableSettings.SESSION_INTERCEPTOR, LocalExceptionInterceptor.class.getName() );
|
||||
settings.put( AvailableSettings.SESSION_SCOPED_INTERCEPTOR, LocalExceptionInterceptor.class.getName() );
|
||||
buildEntityManagerFactory( settings );
|
||||
|
||||
Item i = new Item();
|
||||
@ -275,9 +272,9 @@ public void testOnLoadCallInInterceptor() {
|
||||
|
||||
protected Map basicSettings() {
|
||||
return SettingsGenerator.generateSettings(
|
||||
Environment.HBM2DDL_AUTO, "create-drop",
|
||||
Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true",
|
||||
Environment.DIALECT, Dialect.getDialect().getClass().getName(),
|
||||
AvailableSettings.HBM2DDL_AUTO, "create-drop",
|
||||
AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true",
|
||||
AvailableSettings.DIALECT, Dialect.getDialect().getClass().getName(),
|
||||
AvailableSettings.LOADED_CLASSES, Arrays.asList( getAnnotatedClasses() )
|
||||
);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.cache.spi.entry.CacheEntry;
|
||||
import org.hibernate.cache.spi.entry.CacheEntryStructure;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.internal.MutableEntityEntryFactory;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.engine.spi.EntityEntryFactory;
|
||||
@ -33,7 +34,6 @@
|
||||
import org.hibernate.engine.spi.ValueInclusion;
|
||||
import org.hibernate.id.IdentifierGenerator;
|
||||
import org.hibernate.internal.FilterAliasGenerator;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter;
|
||||
import org.hibernate.jpa.test.SettingsGenerator;
|
||||
|
@ -6,19 +6,18 @@
|
||||
*/
|
||||
package org.hibernate.jpa.test.ejb3configuration;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.SessionFactoryObserver;
|
||||
import org.hibernate.jpa.test.PersistenceUnitInfoAdapter;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
||||
import org.hibernate.jpa.test.PersistenceUnitInfoAdapter;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:emmanuel@hibernate.org">Emmanuel Bernard</a>
|
||||
|
@ -13,8 +13,8 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.PersistenceUnitInfoAdapter;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -21,9 +21,11 @@
|
||||
import javax.persistence.PessimisticLockException;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.QueryTimeoutException;
|
||||
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.TransactionException;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||
import org.hibernate.dialect.DerbyDialect;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
@ -31,20 +33,20 @@
|
||||
import org.hibernate.dialect.Oracle10gDialect;
|
||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||
import org.hibernate.dialect.SQLServerDialect;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.QueryHints;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||
import org.hibernate.testing.transaction.TransactionUtil;
|
||||
import org.hibernate.testing.util.ExceptionUtil;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@ -62,7 +64,7 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
|
||||
protected void addConfigOptions(Map options) {
|
||||
super.addConfigOptions( options );
|
||||
// We can't use a shared connection provider if we use TransactionUtil.setJdbcTimeout because that is set on the connection level
|
||||
options.remove( org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER );
|
||||
options.remove( AvailableSettings.CONNECTION_PROVIDER );
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -78,7 +80,7 @@ public void testFindWithTimeoutHint() {
|
||||
|
||||
doInJPA( this::entityManagerFactory, em -> {
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put( AvailableSettings.LOCK_TIMEOUT, 0L );
|
||||
properties.put( AvailableSettings.JPA_LOCK_TIMEOUT, 0L );
|
||||
em.find( Lock.class, 1, LockModeType.PESSIMISTIC_WRITE, properties );
|
||||
} );
|
||||
|
||||
@ -110,7 +112,7 @@ public void testFindWithPessimisticWriteLockTimeoutException() {
|
||||
try {
|
||||
TransactionUtil.setJdbcTimeout( entityManager.unwrap( Session.class ) );
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
properties.put( AvailableSettings.LOCK_TIMEOUT, 0L );
|
||||
properties.put( AvailableSettings.JPA_LOCK_TIMEOUT, 0L );
|
||||
|
||||
entityManager.find( Lock.class, lock.getId(), LockModeType.PESSIMISTIC_WRITE, properties );
|
||||
fail( "Exception should be thrown" );
|
||||
@ -284,7 +286,7 @@ public void testUpdateWithPessimisticReadLockSkipLocked() {
|
||||
|
||||
doInJPA( this::entityManagerFactory, _entityManagaer -> {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put( org.hibernate.cfg.AvailableSettings.JPA_LOCK_TIMEOUT, LockOptions.SKIP_LOCKED );
|
||||
properties.put( AvailableSettings.JPA_LOCK_TIMEOUT, LockOptions.SKIP_LOCKED );
|
||||
_entityManagaer.find( Lock.class, lock.getId(), LockModeType.PESSIMISTIC_READ, properties );
|
||||
|
||||
try {
|
||||
@ -680,7 +682,7 @@ public void testContendedPessimisticReadLockTimeout() throws Exception {
|
||||
log.info( "testContendedPessimisticReadLockTimeout: (BG) read write-locked entity" );
|
||||
Map<String, Object> props = new HashMap<String, Object>();
|
||||
// timeout is in milliseconds
|
||||
props.put( AvailableSettings.LOCK_TIMEOUT, 1000 );
|
||||
props.put( AvailableSettings.JPA_LOCK_TIMEOUT, 1000 );
|
||||
try {
|
||||
_entityManager.lock( lock2, LockModeType.PESSIMISTIC_READ, props );
|
||||
}
|
||||
@ -763,7 +765,7 @@ public void testContendedPessimisticWriteLockTimeout() throws Exception {
|
||||
log.info( "testContendedPessimisticWriteLockTimeout: (BG) read write-locked entity" );
|
||||
Map<String, Object> props = new HashMap<String, Object>();
|
||||
// timeout is in milliseconds
|
||||
props.put( AvailableSettings.LOCK_TIMEOUT, 1000 );
|
||||
props.put( AvailableSettings.JPA_LOCK_TIMEOUT, 1000 );
|
||||
try {
|
||||
_entityManager.lock( lock2, LockModeType.PESSIMISTIC_WRITE, props );
|
||||
}
|
||||
@ -843,7 +845,7 @@ public void testContendedPessimisticWriteLockNoWait() throws Exception {
|
||||
log.info( "testContendedPessimisticWriteLockNoWait: (BG) read write-locked entity" );
|
||||
Map<String, Object> props = new HashMap<String, Object>();
|
||||
// timeout of zero means no wait (for lock)
|
||||
props.put( AvailableSettings.LOCK_TIMEOUT, 0 );
|
||||
props.put( AvailableSettings.JPA_LOCK_TIMEOUT, 0 );
|
||||
try {
|
||||
_entityManager.lock( lock2, LockModeType.PESSIMISTIC_WRITE, props );
|
||||
}
|
||||
@ -1081,7 +1083,7 @@ public void testLockTimeoutEMProps() throws Exception {
|
||||
final CountDownLatch latch = new CountDownLatch( 1 );
|
||||
|
||||
final Map<String, Object> timeoutProps = new HashMap<String, Object>();
|
||||
timeoutProps.put( AvailableSettings.LOCK_TIMEOUT, 1000 ); // 1 second timeout
|
||||
timeoutProps.put( AvailableSettings.JPA_LOCK_TIMEOUT, 1000 ); // 1 second timeout
|
||||
final Lock lock = new Lock();
|
||||
|
||||
FutureTask<Boolean> bgTask = new FutureTask<>(
|
||||
@ -1095,7 +1097,7 @@ public void testLockTimeoutEMProps() throws Exception {
|
||||
Lock lock2 = _entityManager.getReference( Lock.class, lock.getId() );
|
||||
lock2.getName(); // force entity to be read
|
||||
log.info( "testLockTimeoutEMProps: (BG) read write-locked entity" );
|
||||
// em2 already has AvailableSettings.LOCK_TIMEOUT of 1 second applied
|
||||
// em2 already has AvailableSettings.JPA_LOCK_TIMEOUT of 1 second applied
|
||||
try {
|
||||
_entityManager.lock( lock2, LockModeType.PESSIMISTIC_WRITE );
|
||||
}
|
||||
|
@ -11,8 +11,8 @@
|
||||
import javax.persistence.LockModeType;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
@ -31,7 +31,7 @@
|
||||
public class LockTimeoutPropertyTest extends BaseEntityManagerFunctionalTestCase {
|
||||
@Override
|
||||
protected void addConfigOptions(Map options) {
|
||||
options.put( AvailableSettings.LOCK_TIMEOUT, "2000" );
|
||||
options.put( AvailableSettings.JPA_LOCK_TIMEOUT, "2000" );
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -51,9 +51,9 @@ public void testLockTimeoutASNamedQueryHint(){
|
||||
public void testTimeoutHint(){
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
boolean b= em.getProperties().containsKey( AvailableSettings.LOCK_TIMEOUT );
|
||||
boolean b= em.getProperties().containsKey( AvailableSettings.JPA_LOCK_TIMEOUT );
|
||||
assertTrue( b );
|
||||
int timeout = Integer.valueOf( em.getProperties().get( AvailableSettings.LOCK_TIMEOUT ).toString() );
|
||||
int timeout = Integer.valueOf( em.getProperties().get( AvailableSettings.JPA_LOCK_TIMEOUT ).toString() );
|
||||
assertEquals( 2000, timeout);
|
||||
org.hibernate.query.Query q = (org.hibernate.query.Query) em.createQuery( "select u from UnversionedLock u" );
|
||||
timeout = q.getLockOptions().getTimeOut();
|
||||
@ -61,7 +61,7 @@ public void testTimeoutHint(){
|
||||
|
||||
Query query = em.createQuery( "select u from UnversionedLock u" );
|
||||
query.setLockMode(LockModeType.PESSIMISTIC_WRITE);
|
||||
query.setHint( AvailableSettings.LOCK_TIMEOUT, 3000 );
|
||||
query.setHint( AvailableSettings.JPA_LOCK_TIMEOUT, 3000 );
|
||||
q = (org.hibernate.query.Query) query;
|
||||
timeout = q.getLockOptions().getTimeOut();
|
||||
assertEquals( 3000, timeout );
|
||||
|
@ -19,14 +19,16 @@
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import javax.persistence.criteria.ParameterExpression;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||
import org.hibernate.dialect.SQLServerDialect;
|
||||
import org.hibernate.internal.SessionImpl;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.QueryHints;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
|
@ -9,7 +9,7 @@
|
||||
import java.util.Arrays;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -6,16 +6,15 @@
|
||||
*/
|
||||
package org.hibernate.jpa.test.metagen.mappedsuperclass.embedded;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import java.util.Arrays;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
|
@ -6,16 +6,15 @@
|
||||
*/
|
||||
package org.hibernate.jpa.test.metagen.mappedsuperclass.embeddedid;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import java.util.Arrays;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
|
@ -6,16 +6,15 @@
|
||||
*/
|
||||
package org.hibernate.jpa.test.metagen.mappedsuperclass.idclass;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import java.util.Arrays;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
import java.util.Arrays;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
|
@ -15,7 +15,7 @@
|
||||
import javax.persistence.Table;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
@ -30,7 +30,7 @@ public class RemoveOrderingTest extends BaseEntityManagerFunctionalTestCase {
|
||||
@Override
|
||||
protected void addConfigOptions(Map options) {
|
||||
super.addConfigOptions( options );
|
||||
options.put( AvailableSettings.VALIDATION_MODE, "NONE" );
|
||||
options.put( AvailableSettings.JPA_VALIDATION_MODE, "NONE" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,11 +15,11 @@
|
||||
import javax.persistence.Persistence;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.internal.util.ConfigHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.test.Distributor;
|
||||
import org.hibernate.jpa.test.Item;
|
||||
@ -44,7 +44,6 @@
|
||||
import org.hibernate.stat.Statistics;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -295,7 +294,7 @@ public void testOverriddenPar() throws Exception {
|
||||
addPackageToClasspath( testPackage );
|
||||
|
||||
HashMap properties = new HashMap();
|
||||
properties.put( AvailableSettings.JTA_DATASOURCE, null );
|
||||
properties.put( AvailableSettings.JPA_JTA_DATASOURCE, null );
|
||||
Properties p = new Properties();
|
||||
p.load( ConfigHelper.getResourceAsStream( "/overridenpar.properties" ) );
|
||||
properties.putAll( p );
|
||||
|
@ -36,7 +36,7 @@ public class TwoPersistenceUnits2LCDisabledEnabled {
|
||||
@TestForIssue( jiraKey = "HHH-11516" )
|
||||
public void testDisabledEnabled() {
|
||||
final Map<Object, Object> config = Environment.getProperties();
|
||||
config.put( org.hibernate.jpa.AvailableSettings.LOADED_CLASSES, Collections.singletonList( AnEntity.class ) );
|
||||
config.put( AvailableSettings.LOADED_CLASSES, Collections.singletonList( AnEntity.class ) );
|
||||
config.put( "javax.persistence.sharedCache.mode", SharedCacheMode.ENABLE_SELECTIVE );
|
||||
config.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
|
||||
|
||||
|
@ -30,11 +30,11 @@
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||
|
@ -19,11 +19,11 @@
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.StoredProcedureQuery;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||
|
@ -12,8 +12,7 @@
|
||||
import javax.persistence.SharedCacheMode;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.QueryHints;
|
||||
import org.hibernate.jpa.spi.HibernateEntityManagerImplementor;
|
||||
@ -42,7 +41,7 @@ public void testCacheableQuery() {
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
|
||||
HibernateEntityManagerFactory hemf = (HibernateEntityManagerFactory) entityManagerFactory();
|
||||
HibernateEntityManagerFactory hemf = entityManagerFactory();
|
||||
Statistics stats = hemf.getSessionFactory().getStatistics();
|
||||
|
||||
assertEquals( 0, stats.getQueryCacheHitCount() );
|
||||
@ -157,10 +156,10 @@ public void testCacheableQuery() {
|
||||
}
|
||||
|
||||
protected void addConfigOptions(Map options) {
|
||||
options.put( AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.ALL );
|
||||
options.put( Environment.GENERATE_STATISTICS, "true" );
|
||||
options.put( Environment.USE_QUERY_CACHE, "true" );
|
||||
options.put( Environment.USE_SECOND_LEVEL_CACHE, "true" );
|
||||
options.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ALL );
|
||||
options.put( AvailableSettings.GENERATE_STATISTICS, "true" );
|
||||
options.put( AvailableSettings.USE_QUERY_CACHE, "true" );
|
||||
options.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,12 +21,16 @@
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_ACTION;
|
||||
import static org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET;
|
||||
import static org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET;
|
||||
import static org.hibernate.cfg.AvailableSettings.LOADED_CLASSES;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
@ -41,13 +45,13 @@ public class SchemaCreateDropUtf8WithoutHbm2DdlCharsetNameTest {
|
||||
|
||||
protected Map getConfig() {
|
||||
final Map<Object, Object> config = Environment.getProperties();
|
||||
config.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, createSchema.toPath() );
|
||||
config.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET, dropSchema.toPath() );
|
||||
config.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
|
||||
config.put( HBM2DDL_SCRIPTS_CREATE_TARGET, createSchema.toPath() );
|
||||
config.put( HBM2DDL_SCRIPTS_DROP_TARGET, dropSchema.toPath() );
|
||||
config.put( HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
|
||||
ArrayList<Class> classes = new ArrayList<Class>();
|
||||
|
||||
classes.addAll( Arrays.asList( new Class[] {TestEntity.class} ) );
|
||||
config.put( org.hibernate.jpa.AvailableSettings.LOADED_CLASSES, classes );
|
||||
config.put( LOADED_CLASSES, classes );
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.tool.schema.spi.CommandAcceptanceException;
|
||||
import org.hibernate.tool.schema.spi.SchemaManagementException;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -123,7 +123,7 @@ private Map getConfig() {
|
||||
ArrayList<Class> classes = new ArrayList<>();
|
||||
|
||||
classes.addAll( Arrays.asList( new Class[] { TestEntity.class } ) );
|
||||
config.put( org.hibernate.jpa.AvailableSettings.LOADED_CLASSES, classes );
|
||||
config.put( AvailableSettings.LOADED_CLASSES, classes );
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
@ -110,13 +110,13 @@ private PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
||||
|
||||
private Map getConfig() {
|
||||
final Map<Object, Object> config = Environment.getProperties();
|
||||
config.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET, writer );
|
||||
config.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
|
||||
config.put( AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET, writer );
|
||||
config.put( AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
|
||||
config.put( AvailableSettings.HBM2DDL_HALT_ON_ERROR, "true" );
|
||||
ArrayList<Class> classes = new ArrayList<>();
|
||||
|
||||
classes.addAll( Arrays.asList( new Class[] { TestEntity.class } ) );
|
||||
config.put( org.hibernate.jpa.AvailableSettings.LOADED_CLASSES, classes );
|
||||
config.put( AvailableSettings.LOADED_CLASSES, classes );
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
||||
@ -108,13 +109,13 @@ private PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
||||
|
||||
private Map getConfig() {
|
||||
final Map<Object, Object> config = Environment.getProperties();
|
||||
config.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, createSchema.toPath() );
|
||||
config.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET, dropSchema.toPath() );
|
||||
config.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
|
||||
config.put( AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, createSchema.toPath() );
|
||||
config.put( AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET, dropSchema.toPath() );
|
||||
config.put( AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
|
||||
ArrayList<Class> classes = new ArrayList<Class>();
|
||||
|
||||
classes.addAll( Arrays.asList( new Class[] {TestEntity.class} ) );
|
||||
config.put( org.hibernate.jpa.AvailableSettings.LOADED_CLASSES, classes );
|
||||
config.put( AvailableSettings.LOADED_CLASSES, classes );
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,9 @@
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl;
|
||||
import org.hibernate.internal.SessionImpl;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
@ -49,8 +49,8 @@ public class CloseEntityManagerWithActiveTransactionTest extends BaseEntityManag
|
||||
protected void addConfigOptions(Map options) {
|
||||
super.addConfigOptions( options );
|
||||
TestingJtaBootstrap.prepare( options );
|
||||
options.put( AvailableSettings.TRANSACTION_TYPE, "JTA" );
|
||||
options.put( org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_COMPLIANCE, "true" );
|
||||
options.put( AvailableSettings.JPA_TRANSACTION_TYPE, "JTA" );
|
||||
options.put( AvailableSettings.JPA_TRANSACTION_COMPLIANCE, "true" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
@ -27,8 +27,8 @@ public class JtaGetTransactionThrowsExceptionTest extends BaseEntityManagerFunct
|
||||
protected void addConfigOptions(Map options) {
|
||||
super.addConfigOptions( options );
|
||||
TestingJtaBootstrap.prepare( options );
|
||||
options.put( AvailableSettings.TRANSACTION_TYPE, "JTA" );
|
||||
options.put( org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_COMPLIANCE, "true" );
|
||||
options.put( AvailableSettings.JPA_TRANSACTION_TYPE, "JTA" );
|
||||
options.put( AvailableSettings.JPA_TRANSACTION_COMPLIANCE, "true" );
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
|
@ -14,9 +14,9 @@
|
||||
import javax.persistence.criteria.CriteriaDelete;
|
||||
import javax.persistence.criteria.CriteriaUpdate;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
||||
|
||||
@ -43,7 +43,7 @@ public class SynchronizationTypeTest extends BaseEntityManagerFunctionalTestCase
|
||||
protected void addConfigOptions(Map options) {
|
||||
super.addConfigOptions( options );
|
||||
TestingJtaBootstrap.prepare( options );
|
||||
options.put( AvailableSettings.TRANSACTION_TYPE, "JTA" );
|
||||
options.put( AvailableSettings.JPA_TRANSACTION_TYPE, "JTA" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,10 +15,10 @@
|
||||
import javax.transaction.Status;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||
import org.hibernate.internal.SessionImpl;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
||||
|
||||
@ -42,7 +42,7 @@ public class TransactionJoiningTest extends BaseEntityManagerFunctionalTestCase
|
||||
protected void addConfigOptions(Map options) {
|
||||
super.addConfigOptions( options );
|
||||
TestingJtaBootstrap.prepare( options );
|
||||
options.put( AvailableSettings.TRANSACTION_TYPE, "JTA" );
|
||||
options.put( AvailableSettings.JPA_TRANSACTION_TYPE, "JTA" );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -6,21 +6,19 @@
|
||||
*/
|
||||
package org.hibernate.jpa.test.transaction;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.RollbackException;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.SystemException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@ -35,7 +33,7 @@ public class TransactionRolledBackInDifferentThreadTest extends BaseEntityManage
|
||||
protected void addConfigOptions(Map options) {
|
||||
super.addConfigOptions( options );
|
||||
TestingJtaBootstrap.prepare( options );
|
||||
options.put( AvailableSettings.TRANSACTION_TYPE, "JTA" );
|
||||
options.put( AvailableSettings.JPA_TRANSACTION_TYPE, "JTA" );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -10,8 +10,8 @@
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
@ -42,7 +42,7 @@ public Class[] getAnnotatedClasses() {
|
||||
}
|
||||
|
||||
protected void addConfigOptions(Map options) {
|
||||
options.put( AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE );
|
||||
options.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -396,7 +396,7 @@ public void testCfgXmlBaseline() {
|
||||
final PersistenceUnitInfoAdapter info = new PersistenceUnitInfoAdapter() {
|
||||
private final Properties props = new Properties();
|
||||
{
|
||||
props.put( org.hibernate.jpa.AvailableSettings.CFG_FILE, "org/hibernate/orm/test/bootstrap/jpa/hibernate.cfg.xml" );
|
||||
props.put( AvailableSettings.CFG_XML_FILE, "org/hibernate/orm/test/bootstrap/jpa/hibernate.cfg.xml" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -437,7 +437,7 @@ public void testIntegrationOverridesOfCfgXml() {
|
||||
final PersistenceUnitInfoAdapter info = new PersistenceUnitInfoAdapter() {
|
||||
private final Properties props = new Properties();
|
||||
{
|
||||
props.put( org.hibernate.jpa.AvailableSettings.CFG_FILE, "org/hibernate/orm/test/bootstrap/jpa/hibernate.cfg.xml" );
|
||||
props.put( AvailableSettings.CFG_XML_FILE, "org/hibernate/orm/test/bootstrap/jpa/hibernate.cfg.xml" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -177,10 +177,11 @@ public static class AnEntity {
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "AnEntity_aCollection", joinColumns = { @JoinColumn( name = "AnEntity_id" ) })
|
||||
@CollectionId(
|
||||
columns = { @Column },
|
||||
//columns = { @Column },
|
||||
column = @Column( name = "collection_id" ),
|
||||
type = @Type(type = "long"),
|
||||
generator = "increment"
|
||||
)
|
||||
private List<String> aCollection = new ArrayList<String>();
|
||||
private List<String> aCollection = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,13 @@
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
import org.hibernate.bytecode.enhance.spi.EnhancementContext;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||
@ -273,7 +273,7 @@ private StandardServiceRegistryImpl buildServiceRegistry(BootstrapServiceRegistr
|
||||
private Properties buildProperties() {
|
||||
Properties properties = Environment.getProperties();
|
||||
|
||||
properties.put( org.hibernate.cfg.AvailableSettings.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() );
|
||||
properties.put( AvailableSettings.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() );
|
||||
for ( Map.Entry<Class, String> entry : getCachedClasses().entrySet() ) {
|
||||
properties.put( AvailableSettings.CLASS_CACHE_PREFIX + "." + entry.getKey().getName(), entry.getValue() );
|
||||
}
|
||||
@ -284,10 +284,10 @@ private Properties buildProperties() {
|
||||
configure( properties );
|
||||
|
||||
if ( createSchema() ) {
|
||||
properties.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||
properties.put( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||
}
|
||||
properties.put( org.hibernate.cfg.AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
|
||||
properties.put( org.hibernate.cfg.AvailableSettings.DIALECT, getDialect().getClass().getName() );
|
||||
properties.put( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
|
||||
properties.put( AvailableSettings.DIALECT, getDialect().getClass().getName() );
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
@ -16,11 +16,11 @@
|
||||
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||
import org.hibernate.envers.AuditReader;
|
||||
import org.hibernate.envers.AuditReaderFactory;
|
||||
@ -29,17 +29,16 @@
|
||||
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
||||
import org.hibernate.hql.spi.id.local.LocalTemporaryTableBulkIdStrategy;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||
import org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter;
|
||||
|
||||
import org.hibernate.testing.AfterClassOnce;
|
||||
import org.hibernate.testing.BeforeClassOnce;
|
||||
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||
import org.hibernate.testing.junit4.Helper;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.junit.After;
|
||||
|
||||
/**
|
||||
@ -99,7 +98,7 @@ private Map buildSettings() {
|
||||
addMappings( settings );
|
||||
|
||||
if ( createSchema() ) {
|
||||
settings.put( org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||
settings.put( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||
final String secondSchemaName = createSecondSchema();
|
||||
if ( StringHelper.isNotEmpty( secondSchemaName ) ) {
|
||||
if ( !(getDialect() instanceof H2Dialect) ) {
|
||||
@ -119,8 +118,8 @@ private Map buildSettings() {
|
||||
|
||||
settings.put( EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false" );
|
||||
|
||||
settings.put( org.hibernate.cfg.AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
|
||||
settings.put( org.hibernate.cfg.AvailableSettings.DIALECT, getDialect().getClass().getName() );
|
||||
settings.put( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
|
||||
settings.put( AvailableSettings.DIALECT, getDialect().getClass().getName() );
|
||||
return settings;
|
||||
}
|
||||
|
||||
@ -138,16 +137,16 @@ protected Map getConfig() {
|
||||
}
|
||||
|
||||
if ( getEjb3DD().length > 0 ) {
|
||||
ArrayList<String> dds = new ArrayList<String>();
|
||||
ArrayList<String> dds = new ArrayList<>();
|
||||
dds.addAll( Arrays.asList( getEjb3DD() ) );
|
||||
config.put( AvailableSettings.XML_FILE_NAMES, dds );
|
||||
config.put( AvailableSettings.ORM_XML_FILES, dds );
|
||||
}
|
||||
|
||||
config.put( GlobalTemporaryTableBulkIdStrategy.DROP_ID_TABLES, "true" );
|
||||
config.put( LocalTemporaryTableBulkIdStrategy.DROP_ID_TABLES, "true" );
|
||||
if ( !Environment.getProperties().containsKey( Environment.CONNECTION_PROVIDER ) ) {
|
||||
if ( ! Environment.getProperties().containsKey( AvailableSettings.CONNECTION_PROVIDER ) ) {
|
||||
config.put(
|
||||
org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER,
|
||||
AvailableSettings.CONNECTION_PROVIDER,
|
||||
SharedDriverManagerConnectionProviderImpl.getInstance()
|
||||
);
|
||||
}
|
||||
@ -160,7 +159,7 @@ protected Map getConfig() {
|
||||
protected void addMappings(Map settings) {
|
||||
String[] mappings = getMappings();
|
||||
if ( mappings != null ) {
|
||||
settings.put( AvailableSettings.HBXML_FILES, String.join( ",", mappings ) );
|
||||
settings.put( AvailableSettings.HBM_XML_FILES, String.join( ",", mappings ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.envers.AuditReader;
|
||||
@ -20,7 +21,6 @@
|
||||
import org.hibernate.envers.configuration.EnversSettings;
|
||||
import org.hibernate.envers.boot.internal.EnversIntegrator;
|
||||
import org.hibernate.envers.test.AbstractEnversTest;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.HibernateEntityManagerFactory;
|
||||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
@ -83,8 +83,8 @@ protected void init(boolean audited, String auditStrategy) throws IOException {
|
||||
configurationProperties.setProperty( EnversIntegrator.AUTO_REGISTER, "false" );
|
||||
}
|
||||
if ( createSchema() ) {
|
||||
configurationProperties.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||
configurationProperties.setProperty( Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
|
||||
configurationProperties.setProperty( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||
configurationProperties.setProperty( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
|
||||
configurationProperties.setProperty( EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false" );
|
||||
}
|
||||
if ( auditStrategy != null && !"".equals( auditStrategy ) ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user