Remove some deprecations in org.hibernate.cfg and

org.hibernate.collection.spi

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2022-01-24 22:24:12 +01:00 committed by Jan Schatteman
parent d2643fc2b5
commit cc0b198142
22 changed files with 57 additions and 886 deletions

View File

@ -351,14 +351,14 @@ public interface MetadataBuilder {
MetadataBuilder applyAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject);
/**
* Adds an AttributeConverter by an AttributeConverterDefinition
* Adds an AttributeConverter by a {@link ConverterDescriptor}
*
* @param definition The definition
* @param descriptor The descriptor
*
* @return {@code this} for method chaining
*
*/
MetadataBuilder applyAttributeConverter(ConverterDescriptor definition);
MetadataBuilder applyAttributeConverter(ConverterDescriptor descriptor);
/**
* Adds an AttributeConverter by its Class.

View File

@ -1,200 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.cfg;
import java.lang.reflect.Constructor;
import java.lang.reflect.ParameterizedType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.boot.AttributeConverterInfo;
import org.hibernate.boot.model.convert.internal.ConverterHelper;
import org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.internal.util.GenericsHelper;
/**
* Externalized representation of an AttributeConverter
*
* @author Steve Ebersole
*
* @deprecated forces the converter instance to be built too early,
* which precludes the ability to resolve them from CDI, etc. See
* {@link ConverterDescriptor} instead
*/
@Deprecated(since = "5.3")
public class AttributeConverterDefinition implements AttributeConverterInfo {
private final AttributeConverter attributeConverter;
private final boolean autoApply;
private final Class entityAttributeType;
private final Class databaseColumnType;
/**
* Build an AttributeConverterDefinition from the AttributeConverter Class reference and
* whether or not to auto-apply it.
*
* @param attributeConverterClass The AttributeConverter Class
* @param autoApply Should the AttributeConverter be auto-applied?
*
* @return The constructed definition
*/
public static AttributeConverterDefinition from(Class<? extends AttributeConverter> attributeConverterClass, boolean autoApply) {
return new AttributeConverterDefinition(
instantiateAttributeConverter( attributeConverterClass ),
autoApply
);
}
private static AttributeConverter instantiateAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass) {
try {
Constructor<? extends AttributeConverter> constructor = attributeConverterClass.getDeclaredConstructor();
constructor.setAccessible( true );
return constructor.newInstance();
}
catch (Exception e) {
throw new AnnotationException(
"Unable to instantiate AttributeConverter [" + attributeConverterClass.getName() + "]",
e
);
}
}
/**
* Build an AttributeConverterDefinition from the AttributeConverter Class reference. The
* converter is searched for a {@link Converter} annotation to determine whether it should
* be treated as auto-apply. If the annotation is present, {@link Converter#autoApply()} is
* used to make that determination. If the annotation is not present, {@code false} is assumed.
*
* @param attributeConverterClass The converter class
*
* @return The constructed definition
*/
public static AttributeConverterDefinition from(Class<? extends AttributeConverter> attributeConverterClass) {
return from( instantiateAttributeConverter( attributeConverterClass ) );
}
/**
* Build an AttributeConverterDefinition from an AttributeConverter instance. The
* converter is searched for a {@link Converter} annotation to determine whether it should
* be treated as auto-apply. If the annotation is present, {@link Converter#autoApply()} is
* used to make that determination. If the annotation is not present, {@code false} is assumed.
*
* @param attributeConverter The AttributeConverter instance
*
* @return The constructed definition
*/
public static AttributeConverterDefinition from(AttributeConverter attributeConverter) {
boolean autoApply = false;
Converter converterAnnotation = attributeConverter.getClass().getAnnotation( Converter.class );
if ( converterAnnotation != null ) {
autoApply = converterAnnotation.autoApply();
}
return new AttributeConverterDefinition( attributeConverter, autoApply );
}
/**
* Build an AttributeConverterDefinition from the AttributeConverter instance and
* whether or not to auto-apply it.
*
* @param attributeConverter The AttributeConverter instance
* @param autoApply Should the AttributeConverter be auto-applied?
*
* @return The constructed definition
*/
public static AttributeConverterDefinition from(AttributeConverter attributeConverter, boolean autoApply) {
return new AttributeConverterDefinition( attributeConverter, autoApply );
}
public AttributeConverterDefinition(AttributeConverter attributeConverter, boolean autoApply) {
this.attributeConverter = attributeConverter;
this.autoApply = autoApply;
final Class attributeConverterClass = attributeConverter.getClass();
final ParameterizedType attributeConverterSignature = ConverterHelper.extractAttributeConverterParameterizedType( attributeConverterClass );
if ( attributeConverterSignature == null ) {
throw new AssertionFailure(
"Could not extract ParameterizedType representation of AttributeConverter definition " +
"from AttributeConverter implementation class [" + attributeConverterClass.getName() + "]"
);
}
if ( attributeConverterSignature.getActualTypeArguments().length < 2 ) {
throw new AnnotationException(
"AttributeConverter [" + attributeConverterClass.getName()
+ "] did not retain parameterized type information"
);
}
if ( attributeConverterSignature.getActualTypeArguments().length > 2 ) {
throw new AnnotationException(
"AttributeConverter [" + attributeConverterClass.getName()
+ "] specified more than 2 parameterized types"
);
}
entityAttributeType = GenericsHelper.extractClass( attributeConverterSignature.getActualTypeArguments()[0] );
if ( entityAttributeType == null ) {
throw new AnnotationException(
"Could not determine 'entity attribute' type from given AttributeConverter [" +
attributeConverterClass.getName() + "]"
);
}
databaseColumnType = GenericsHelper.extractClass(attributeConverterSignature.getActualTypeArguments()[1]);
if ( databaseColumnType == null ) {
throw new AnnotationException(
"Could not determine 'database column' type from given AttributeConverter [" +
attributeConverterClass.getName() + "]"
);
}
}
public AttributeConverter getAttributeConverter() {
return attributeConverter;
}
public boolean isAutoApply() {
return autoApply;
}
public Class getEntityAttributeType() {
return entityAttributeType;
}
public Class getDatabaseColumnType() {
return databaseColumnType;
}
@Override
public Class<? extends AttributeConverter> getConverterClass() {
return attributeConverter.getClass();
}
@Override
public String toString() {
return String.format(
"%s[converterClass=%s, domainType=%s, jdbcType=%s]",
this.getClass().getName(),
attributeConverter.getClass().getName(),
entityAttributeType.getName(),
databaseColumnType.getName()
);
}
@Override
public ConverterDescriptor toConverterDescriptor(MetadataBuildingContext context) {
return new InstanceBasedConverterDescriptor(
getAttributeConverter(),
isAutoApply(),
context.getBootstrapContext().getClassmateContext()
);
}
}

View File

@ -309,81 +309,6 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
return false;
}
// @Override
// public AttributeConverterDefinition resolveAttributeConverter(String attributeName) {
//
// // @Convert annotations take precedence if present
// final Convert convertAnnotation = locateConvertAnnotation( property );
// if ( convertAnnotation != null ) {
// log.debugf(
// "Applying located @Convert AttributeConverter [%s] to attribute [%]",
// convertAnnotation.converter().getName(),
// property.getName()
// );
// attributeConverterDefinition = getMetadata().locateAttributeConverter( convertAnnotation.converter() );
// }
// else {
// attributeConverterDefinition = locateAutoApplyAttributeConverter( property );
// }
// }
//
// @SuppressWarnings("unchecked")
// private Convert locateConvertAnnotation(XProperty property) {
// LOG.debugf(
// "Attempting to locate Convert annotation for property [%s:%s]",
// persistentClassName,
// property.getName()
// );
//
// // first look locally on the property for @Convert/@Converts
// {
// Convert localConvertAnnotation = property.getAnnotation( Convert.class );
// if ( localConvertAnnotation != null ) {
// LOG.debugf(
// "Found matching local @Convert annotation [disableConversion=%s]",
// localConvertAnnotation.disableConversion()
// );
// return localConvertAnnotation.disableConversion()
// ? null
// : localConvertAnnotation;
// }
// }
//
// {
// Converts localConvertsAnnotation = property.getAnnotation( Converts.class );
// if ( localConvertsAnnotation != null ) {
// for ( Convert localConvertAnnotation : localConvertsAnnotation.value() ) {
// if ( isLocalMatch( localConvertAnnotation, property ) ) {
// LOG.debugf(
// "Found matching @Convert annotation as part local @Converts [disableConversion=%s]",
// localConvertAnnotation.disableConversion()
// );
// return localConvertAnnotation.disableConversion()
// ? null
// : localConvertAnnotation;
// }
// }
// }
// }
//
// if ( persistentClassName == null ) {
// LOG.debug( "Persistent Class name not known during attempt to locate @Convert annotations" );
// return null;
// }
//
// final XClass owner;
// try {
// final Class ownerClass = ReflectHelper.classForName( persistentClassName );
// owner = mappings.getReflectionManager().classForName( persistentClassName, ownerClass );
// }
// catch (ClassNotFoundException e) {
// throw new AnnotationException( "Unable to resolve Class reference during attempt to locate @Convert annotations" );
// }
//
// return lookForEntityDefinedConvertAnnotation( property, owner );
// }
@Override
public String toString() {
return super.toString() + "(" + getEntityName() + ")";

View File

@ -449,22 +449,6 @@ public class Configuration {
return this;
}
/**
* Read mappings from a DOM {@code Document}
*
* @param doc The DOM document
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems reading the DOM or processing
* the mapping document.
*
* @deprecated Use addURL, addResource, addFile, etc. instead
*/
@Deprecated
public Configuration addDocument(org.w3c.dom.Document doc) throws MappingException {
metadataSources.addDocument( doc );
return this;
}
/**
* Read mappings from an {@link InputStream}.
*
@ -478,15 +462,6 @@ public class Configuration {
return this;
}
/**
* @deprecated This form (accepting a ClassLoader) is no longer supported. Instead, add the ClassLoader
* to the ClassLoaderService on the ServiceRegistry associated with this Configuration
*/
@Deprecated
public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
return addResource( resourceName );
}
/**
* Read mappings as a application resourceName (i.e. classpath lookup)
* trying different class loaders.

View File

@ -240,14 +240,6 @@ class PropertyContainer {
return classLevelAccessType;
}
/**
* @deprecated Use the {@link #propertyIterator()} method instead.
*/
@Deprecated
public Collection<XProperty> getProperties() {
return Collections.unmodifiableCollection( this.persistentAttributes );
}
public Iterable<XProperty> propertyIterator() {
return persistentAttributes;
}

View File

@ -1,289 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.cfg;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.SchemaAutoTooling;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsCacheFactory;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.query.sqm.NullPrecedence;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
import org.jboss.logging.Logger;
/**
* Settings that affect the behaviour of Hibernate at runtime.
*
* @author Gavin King
* @author Steve Ebersole
*
* @deprecated Use {@link SessionFactoryOptions} instead.
*/
@SuppressWarnings("unused")
@Deprecated(since = "6.0")
public final class Settings {
private static final Logger LOG = Logger.getLogger( Settings.class );
private final SessionFactoryOptions sessionFactoryOptions;
private final String defaultCatalogName;
private final String defaultSchemaName;
public Settings(SessionFactoryOptions sessionFactoryOptions) {
this( sessionFactoryOptions, null, null );
}
public Settings(SessionFactoryOptions sessionFactoryOptions, Metadata metadata) {
this(
sessionFactoryOptions,
extractName( metadata.getDatabase().getPhysicalImplicitNamespaceName().getCatalog() ),
extractName( metadata.getDatabase().getPhysicalImplicitNamespaceName().getSchema() )
);
}
private static String extractName(Identifier identifier) {
return identifier == null ? null : identifier.render();
}
public Settings(SessionFactoryOptions sessionFactoryOptions, String defaultCatalogName, String defaultSchemaName) {
this.sessionFactoryOptions = sessionFactoryOptions;
this.defaultCatalogName = sessionFactoryOptions.getDefaultCatalog() != null ? sessionFactoryOptions.getDefaultCatalog() : defaultCatalogName;
this.defaultSchemaName = sessionFactoryOptions.getDefaultSchema() != null ? sessionFactoryOptions.getDefaultSchema() : defaultSchemaName;
if ( LOG.isDebugEnabled() ) {
LOG.debugf( "SessionFactory name : %s", sessionFactoryOptions.getSessionFactoryName() );
LOG.debugf( "Automatic flush during beforeCompletion(): %s", enabledDisabled( sessionFactoryOptions.isFlushBeforeCompletionEnabled() ) );
LOG.debugf( "Automatic session close at end of transaction: %s", enabledDisabled( sessionFactoryOptions.isAutoCloseSessionEnabled() ) );
LOG.debugf( "Statistics: %s", enabledDisabled( sessionFactoryOptions.isStatisticsEnabled() ) );
LOG.debugf( "Deleted entity synthetic identifier rollback: %s", enabledDisabled( sessionFactoryOptions.isIdentifierRollbackEnabled() ) );
LOG.debugf( "Check Nullability in Core (should be disabled when Bean Validation is on): %s", enabledDisabled( sessionFactoryOptions.isCheckNullability() ) );
LOG.debugf( "Allow initialization of lazy state outside session : %s", enabledDisabled( sessionFactoryOptions.isInitializeLazyStateOutsideTransactionsEnabled() ) );
LOG.debugf( "Using BatchFetchStyle : %s", sessionFactoryOptions.getBatchFetchStyle().name() );
LOG.debugf( "Default batch fetch size: %s", sessionFactoryOptions.getDefaultBatchFetchSize() );
LOG.debugf( "Maximum outer join fetch depth: %s", sessionFactoryOptions.getMaximumFetchDepth() );
LOG.debugf( "Default null ordering: %s", sessionFactoryOptions.getDefaultNullPrecedence() );
LOG.debugf( "Order SQL updates by primary key: %s", enabledDisabled( sessionFactoryOptions.isOrderUpdatesEnabled() ) );
LOG.debugf( "Order SQL inserts for batching: %s", enabledDisabled( sessionFactoryOptions.isOrderInsertsEnabled() ) );
LOG.debugf( "multi-tenancy enabled : %s", sessionFactoryOptions.isMultiTenancyEnabled() );
LOG.debugf( "JTA Track by Thread: %s", enabledDisabled( sessionFactoryOptions.isJtaTrackByThread() ) );
LOG.debugf( "Named query checking : %s", enabledDisabled( sessionFactoryOptions.isNamedQueryStartupCheckingEnabled() ) );
LOG.debugf( "Second-level cache: %s", enabledDisabled( sessionFactoryOptions.isSecondLevelCacheEnabled() ) );
LOG.debugf( "Second-level query cache: %s", enabledDisabled( sessionFactoryOptions.isQueryCacheEnabled() ) );
LOG.debugf( "Second-level query cache factory: %s", sessionFactoryOptions.getTimestampsCacheFactory() );
LOG.debugf( "Second-level cache region prefix: %s", sessionFactoryOptions.getCacheRegionPrefix() );
LOG.debugf( "Optimize second-level cache for minimal puts: %s", enabledDisabled( sessionFactoryOptions.isMinimalPutsEnabled() ) );
LOG.debugf( "Structured second-level cache entries: %s", enabledDisabled( sessionFactoryOptions.isStructuredCacheEntriesEnabled() ) );
LOG.debugf( "Second-level cache direct-reference entries: %s", enabledDisabled( sessionFactoryOptions.isDirectReferenceCacheEntriesEnabled() ) );
LOG.debugf( "Automatic eviction of collection cache: %s", enabledDisabled( sessionFactoryOptions.isAutoEvictCollectionCache() ) );
LOG.debugf( "JDBC batch size: %s", sessionFactoryOptions.getJdbcBatchSize() );
LOG.debugf( "JDBC batch updates for versioned data: %s", enabledDisabled( sessionFactoryOptions.isJdbcBatchVersionedData() ) );
LOG.debugf( "Scrollable result sets: %s", enabledDisabled( sessionFactoryOptions.isScrollableResultSetsEnabled() ) );
LOG.debugf( "JDBC3 getGeneratedKeys(): %s", enabledDisabled( sessionFactoryOptions.isGetGeneratedKeysEnabled() ) );
LOG.debugf( "JDBC result set fetch size: %s", sessionFactoryOptions.getJdbcFetchSize() );
LOG.debugf( "Connection handling mode: %s", sessionFactoryOptions.getPhysicalConnectionHandlingMode() );
LOG.debugf( "Generate SQL with comments: %s", enabledDisabled( sessionFactoryOptions.isCommentsEnabled() ) );
LOG.debugf( "JPA compliance - query : %s", enabledDisabled( sessionFactoryOptions.getJpaCompliance().isJpaQueryComplianceEnabled() ) );
LOG.debugf( "JPA compliance - closed-handling : %s", enabledDisabled( sessionFactoryOptions.getJpaCompliance().isJpaClosedComplianceEnabled() ) );
LOG.debugf( "JPA compliance - lists : %s", enabledDisabled( sessionFactoryOptions.getJpaCompliance().isJpaListComplianceEnabled() ) );
LOG.debugf( "JPA compliance - transactions : %s", enabledDisabled( sessionFactoryOptions.getJpaCompliance().isJpaTransactionComplianceEnabled() ) );
}
}
private static String enabledDisabled(boolean value) {
return value ? "enabled" : "disabled";
}
public String getDefaultSchemaName() {
return defaultSchemaName;
}
public String getDefaultCatalogName() {
return defaultCatalogName;
}
public String getSessionFactoryName() {
return sessionFactoryOptions.getSessionFactoryName();
}
public boolean isSessionFactoryNameAlsoJndiName() {
return sessionFactoryOptions.isSessionFactoryNameAlsoJndiName();
}
public boolean isFlushBeforeCompletionEnabled() {
return sessionFactoryOptions.isFlushBeforeCompletionEnabled();
}
public boolean isAutoCloseSessionEnabled() {
return sessionFactoryOptions.isAutoCloseSessionEnabled();
}
public boolean isStatisticsEnabled() {
return sessionFactoryOptions.isStatisticsEnabled();
}
public BaselineSessionEventsListenerBuilder getBaselineSessionEventsListenerBuilder() {
return sessionFactoryOptions.getBaselineSessionEventsListenerBuilder();
}
public boolean isIdentifierRollbackEnabled() {
return sessionFactoryOptions.isIdentifierRollbackEnabled();
}
public EntityTuplizerFactory getEntityTuplizerFactory() {
return sessionFactoryOptions.getEntityTuplizerFactory();
}
public boolean isCheckNullability() {
return sessionFactoryOptions.isCheckNullability();
}
public boolean isInitializeLazyStateOutsideTransactionsEnabled() {
return sessionFactoryOptions.isInitializeLazyStateOutsideTransactionsEnabled();
}
/**
* @deprecated No longer used internally
*/
@Deprecated(since = "6.0")
public BatchFetchStyle getBatchFetchStyle() {
return sessionFactoryOptions.getBatchFetchStyle();
}
public int getDefaultBatchFetchSize() {
return sessionFactoryOptions.getDefaultBatchFetchSize();
}
public Integer getMaximumFetchDepth() {
return sessionFactoryOptions.getMaximumFetchDepth();
}
public NullPrecedence getDefaultNullPrecedence() {
return sessionFactoryOptions.getDefaultNullPrecedence();
}
public boolean isOrderUpdatesEnabled() {
return sessionFactoryOptions.isOrderUpdatesEnabled();
}
public boolean isOrderInsertsEnabled() {
return sessionFactoryOptions.isOrderInsertsEnabled();
}
public boolean isMultiTenancyEnabled() {
return sessionFactoryOptions.isMultiTenancyEnabled();
}
public boolean isJtaTrackByThread() {
return sessionFactoryOptions.isJtaTrackByThread();
}
public boolean isNamedQueryStartupCheckingEnabled() {
return sessionFactoryOptions.isNamedQueryStartupCheckingEnabled();
}
public boolean isSecondLevelCacheEnabled() {
return sessionFactoryOptions.isSecondLevelCacheEnabled();
}
public boolean isQueryCacheEnabled() {
return sessionFactoryOptions.isQueryCacheEnabled();
}
public TimestampsCacheFactory getTimestampsCacheFactory() {
return sessionFactoryOptions.getTimestampsCacheFactory();
}
public String getCacheRegionPrefix() {
return sessionFactoryOptions.getCacheRegionPrefix();
}
public boolean isMinimalPutsEnabled() {
return sessionFactoryOptions.isMinimalPutsEnabled();
}
public boolean isStructuredCacheEntriesEnabled() {
return sessionFactoryOptions.isStructuredCacheEntriesEnabled();
}
public boolean isDirectReferenceCacheEntriesEnabled() {
return sessionFactoryOptions.isDirectReferenceCacheEntriesEnabled();
}
public boolean isAutoEvictCollectionCache() {
return sessionFactoryOptions.isAutoEvictCollectionCache();
}
public boolean isAutoCreateSchema() {
return sessionFactoryOptions.getSchemaAutoTooling() == SchemaAutoTooling.CREATE
|| sessionFactoryOptions.getSchemaAutoTooling() == SchemaAutoTooling.CREATE_DROP
|| sessionFactoryOptions.getSchemaAutoTooling() == SchemaAutoTooling.CREATE_ONLY;
}
public boolean isAutoDropSchema() {
return sessionFactoryOptions.getSchemaAutoTooling() == SchemaAutoTooling.CREATE_DROP;
}
public boolean isAutoUpdateSchema() {
return sessionFactoryOptions.getSchemaAutoTooling() == SchemaAutoTooling.UPDATE;
}
public boolean isAutoValidateSchema() {
return sessionFactoryOptions.getSchemaAutoTooling() == SchemaAutoTooling.VALIDATE;
}
public int getJdbcBatchSize() {
return sessionFactoryOptions.getJdbcBatchSize();
}
public boolean isJdbcBatchVersionedData() {
return sessionFactoryOptions.isJdbcBatchVersionedData();
}
public Integer getJdbcFetchSize() {
return sessionFactoryOptions.getJdbcFetchSize();
}
public boolean isScrollableResultSetsEnabled() {
return sessionFactoryOptions.isScrollableResultSetsEnabled();
}
public boolean isGetGeneratedKeysEnabled() {
return sessionFactoryOptions.isGetGeneratedKeysEnabled();
}
public boolean isCommentsEnabled() {
return sessionFactoryOptions.isCommentsEnabled();
}
public RegionFactory getRegionFactory() {
return sessionFactoryOptions.getServiceRegistry().getService( RegionFactory.class );
}
public JtaPlatform getJtaPlatform() {
return sessionFactoryOptions.getServiceRegistry().getService( JtaPlatform.class );
}
public void setCheckNullability(boolean enabled) {
// ugh, used by org.hibernate.cfg.beanvalidation.TypeSafeActivator as part of the BV integrator
sessionFactoryOptions.setCheckNullability( enabled );
}
public boolean isPreferUserTransaction() {
return sessionFactoryOptions.isPreferUserTransaction();
}
}

View File

@ -770,20 +770,6 @@ public class TableBinder {
return holders;
}
/**
* @deprecated Use {@link #buildUniqueConstraintHolders} instead
*/
@Deprecated
public static List<String[]> buildUniqueConstraints(UniqueConstraint[] constraintsArray) {
List<String[]> result = new ArrayList<>();
if ( constraintsArray.length != 0 ) {
for (UniqueConstraint uc : constraintsArray) {
result.add( uc.columnNames() );
}
}
return result;
}
/**
* Build a list of {@link UniqueConstraintHolder} instances given a list of
* {@link UniqueConstraint} annotations.

View File

@ -26,7 +26,6 @@ import org.hibernate.engine.spi.CollectionEntry;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.Status;
import org.hibernate.engine.spi.TypedValue;
@ -84,14 +83,6 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
this.session = session;
}
/**
* @deprecated {@link #AbstractPersistentCollection(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
protected AbstractPersistentCollection(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
@Override
public final String getRole() {
return role;
@ -1301,26 +1292,6 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
}
}
/**
* Removes entity entries that have an equal identifier with the incoming entity instance
*
* @param list The list containing the entity instances
* @param entityInstance The entity instance to match elements.
* @param entityName The entity name
* @param session The session
*
* @deprecated {@link #identityRemove(Collection, Object, String, SharedSessionContractImplementor)}
* should be used instead.
*/
@Deprecated
public static void identityRemove(
Collection<?> list,
Object entityInstance,
String entityName,
SessionImplementor session) {
identityRemove( list, entityInstance, entityName, (SharedSessionContractImplementor) session );
}
@Override
public Object getIdentifier(Object entry, int i) {
throw new UnsupportedOperationException();

View File

@ -16,8 +16,6 @@ import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.collection.spi.AbstractPersistentCollection;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
@ -56,20 +54,6 @@ public class PersistentArrayHolder<E> extends AbstractPersistentCollection<E> {
setInitialized();
}
/**
* Constructs a PersistentCollection instance for holding an array.
*
* @param session The session
* @param array The array (the persistent "collection").
*
* @deprecated {@link #PersistentArrayHolder(SharedSessionContractImplementor, Object)}
* should be used instead.
*/
@Deprecated
public PersistentArrayHolder(SessionImplementor session, Object array) {
this( (SharedSessionContractImplementor) session, array );
}
/**
* Constructs a PersistentCollection instance for holding an array.
*
@ -81,20 +65,6 @@ public class PersistentArrayHolder<E> extends AbstractPersistentCollection<E> {
elementClass = persister.getElementClass();
}
/**
* Constructs a PersistentCollection instance for holding an array.
*
* @param session The session
* @param persister The persister for the array
*
* @deprecated {@link #PersistentArrayHolder(SharedSessionContractImplementor, CollectionPersister)}
* should be used instead.
*/
@Deprecated
public PersistentArrayHolder(SessionImplementor session, CollectionPersister persister) {
this( (SharedSessionContractImplementor) session, persister );
}
@Override
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
// final int length = (array==null) ? tempList.size() : Array.getLength( array );

View File

@ -18,7 +18,6 @@ import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
@ -61,18 +60,6 @@ public class PersistentBag<E> extends AbstractPersistentCollection<E> implements
super( session );
}
/**
* Constructs a PersistentBag
*
* @param session The session
*
* @deprecated {@link #PersistentBag(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentBag(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/**
* Constructs a PersistentBag
*
@ -92,20 +79,6 @@ public class PersistentBag<E> extends AbstractPersistentCollection<E> implements
setDirectlyAccessible( true );
}
/**
* Constructs a PersistentBag
*
* @param session The session
* @param coll The base elements.
*
* @deprecated {@link #PersistentBag(SharedSessionContractImplementor, Collection)}
* should be used instead.
*/
@Deprecated
public PersistentBag(SessionImplementor session, Collection<E> coll) {
this( (SharedSessionContractImplementor) session, coll );
}
@Override
public boolean isWrapper(Object collection) {
return bag == collection;

View File

@ -17,7 +17,6 @@ import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
@ -65,17 +64,6 @@ public class PersistentIdentifierBag<E> extends AbstractPersistentCollection<E>
super( session );
}
/**
* Constructs a PersistentIdentifierBag.
*
* @param session The session
* @deprecated {@link #PersistentIdentifierBag(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentIdentifierBag(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/**
* Constructs a PersistentIdentifierBag.
*
@ -96,18 +84,6 @@ public class PersistentIdentifierBag<E> extends AbstractPersistentCollection<E>
identifiers = new HashMap<>();
}
/**
* Constructs a PersistentIdentifierBag.
*
* @param session The session
* @param coll The base elements
* @deprecated {@link #PersistentIdentifierBag(SharedSessionContractImplementor, Collection)} should be used instead.
*/
@Deprecated
public PersistentIdentifierBag(SessionImplementor session, Collection<E> coll) {
this( (SharedSessionContractImplementor) session, coll );
}
@Override
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException {

View File

@ -15,7 +15,6 @@ import java.util.ListIterator;
import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
@ -49,17 +48,6 @@ public class PersistentList<E> extends AbstractPersistentCollection<E> implement
super( session );
}
/**
* Constructs a PersistentList.
*
* @param session The session
* @deprecated {@link #PersistentList(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentList(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/**
* Constructs a PersistentList.
*
@ -73,18 +61,6 @@ public class PersistentList<E> extends AbstractPersistentCollection<E> implement
setDirectlyAccessible( true );
}
/**
* Constructs a PersistentList.
*
* @param session The session
* @param list The raw list
* @deprecated {@link #PersistentList(SharedSessionContractImplementor, List)} should be used instead.
*/
@Deprecated
public PersistentList(SessionImplementor session, List<E> list) {
this( (SharedSessionContractImplementor) session, list );
}
protected List<E> getRawList() {
return list;
}

View File

@ -17,7 +17,6 @@ import java.util.Set;
import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
@ -58,17 +57,6 @@ public class PersistentMap<K,E> extends AbstractPersistentCollection<E> implemen
super( session );
}
/**
* Instantiates a lazy map (the underlying map is un-initialized).
*
* @param session The session to which this map will belong.
* @deprecated {@link #PersistentMap(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentMap(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/**
* Instantiates a non-lazy map (the underlying map is constructed
* from the incoming map reference).
@ -83,19 +71,6 @@ public class PersistentMap<K,E> extends AbstractPersistentCollection<E> implemen
setDirectlyAccessible( true );
}
/**
* Instantiates a non-lazy map (the underlying map is constructed
* from the incoming map reference).
*
* @param session The session to which this map will belong.
* @param map The underlying map data.
* @deprecated {@link #PersistentMap(SharedSessionContractImplementor, Map)} should be used instead.
*/
@Deprecated
public PersistentMap(SessionImplementor session, Map<K,E> map) {
this( (SharedSessionContractImplementor) session, map );
}
@Override
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
final HashMap<K,E> clonedMap = CollectionHelper.mapOfSize( map.size() );

View File

@ -16,7 +16,6 @@ import java.util.Set;
import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
@ -57,17 +56,6 @@ public class PersistentSet<E> extends AbstractPersistentCollection<E> implements
super( session );
}
/**
* Instantiates a lazy set (the underlying set is un-initialized).
*
* @param session The session to which this set will belong.
* @deprecated {@link #PersistentSet(SharedSessionContractImplementor)} should be used instead.
*/
@Deprecated
public PersistentSet(SessionImplementor session) {
this( (SharedSessionContractImplementor) session );
}
/**
* Instantiates a non-lazy set (the underlying set is constructed
* from the incoming set reference).
@ -86,19 +74,6 @@ public class PersistentSet<E> extends AbstractPersistentCollection<E> implements
setDirectlyAccessible( true );
}
/**
* Instantiates a non-lazy set (the underlying set is constructed
* from the incoming set reference).
*
* @param session The session to which this set will belong.
* @param set The underlying set data.
* @deprecated {@link #PersistentSet(SharedSessionContractImplementor, Set)} should be used instead.
*/
@Deprecated
public PersistentSet(SessionImplementor session, Set<E> set) {
this( (SharedSessionContractImplementor) session, set );
}
@Override
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
final HashMap<E,E> clonedSet = CollectionHelper.mapOfSize( set.size() );

View File

@ -16,7 +16,6 @@ import java.util.TreeMap;
import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.collection.BasicCollectionPersister;
@ -51,17 +50,6 @@ public class PersistentSortedMap<K,E> extends PersistentMap<K,E> implements Sort
this.comparator = comparator;
}
/**
* Constructs a PersistentSortedMap.
*
* @param session The session
* @deprecated {@link #PersistentSortedMap(SharedSessionContractImplementor, Comparator)} should be used instead.
*/
@Deprecated
public PersistentSortedMap(SessionImplementor session) {
this( session, (Comparator<K>) null );
}
/**
* Constructs a PersistentSortedMap.
*
@ -73,18 +61,6 @@ public class PersistentSortedMap<K,E> extends PersistentMap<K,E> implements Sort
comparator = map.comparator();
}
/**
* Constructs a PersistentSortedMap.
*
* @param session The session
* @param map The underlying map data
* @deprecated {@link #PersistentSortedMap(SharedSessionContractImplementor, SortedMap)} should be used instead.
*/
@Deprecated
public PersistentSortedMap(SessionImplementor session, SortedMap<K,E> map) {
this( (SharedSessionContractImplementor) session, map );
}
@SuppressWarnings("UnusedParameters")
protected Serializable snapshot(BasicCollectionPersister persister) throws HibernateException {
final TreeMap<K,E> clonedMap = new TreeMap<>( comparator );

View File

@ -13,7 +13,6 @@ import java.util.TreeMap;
import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.collection.BasicCollectionPersister;
@ -48,17 +47,6 @@ public class PersistentSortedSet<E> extends PersistentSet<E> implements SortedSe
this.comparator = comparator;
}
/**
* Constructs a PersistentSortedSet
*
* @param session The session
* @deprecated {@link #PersistentSortedSet(SharedSessionContractImplementor, Comparator)} should be used instead.
*/
@Deprecated
public PersistentSortedSet(SessionImplementor session) {
this( session, (Comparator<E>) null );
}
/**
* Constructs a PersistentSortedSet
*
@ -70,18 +58,6 @@ public class PersistentSortedSet<E> extends PersistentSet<E> implements SortedSe
comparator = set.comparator();
}
/**
* Constructs a PersistentSortedSet
*
* @param session The session
* @param set The underlying set data
* @deprecated {@link #PersistentSortedSet(SharedSessionContractImplementor, SortedSet)} should be used instead.
*/
@Deprecated
public PersistentSortedSet(SessionImplementor session, SortedSet<E> set) {
this( (SharedSessionContractImplementor) session, set );
}
@SuppressWarnings("UnusedParameters")
protected Serializable snapshot(BasicCollectionPersister persister)
throws HibernateException {

View File

@ -55,7 +55,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
// not defined as an Environment constant...
//
// it is used to control whether we should consult the JDBC metadata to determine
// certain Settings default values; it is useful to *not* do this when the database
// certain default values; it is useful to *not* do this when the database
// may not be available (mainly in tools usage).
final boolean useJdbcMetadata = ConfigurationHelper.getBoolean(
"hibernate.temp.use_jdbc_metadata_defaults",

View File

@ -60,7 +60,6 @@ import org.hibernate.cache.spi.CacheImplementor;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.Settings;
import org.hibernate.context.internal.JTASessionContext;
import org.hibernate.context.internal.ManagedSessionContext;
import org.hibernate.context.internal.ThreadLocalSessionContext;
@ -159,7 +158,6 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
private final transient SessionFactoryObserverChain observer = new SessionFactoryObserverChain();
private final transient SessionFactoryOptions sessionFactoryOptions;
private final transient Settings settings;
private final transient Map<String,Object> properties;
private final transient SessionFactoryServiceRegistry serviceRegistry;
@ -200,7 +198,6 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
final BootstrapContext bootstrapContext = bootModelBuildingContext.getBootstrapContext();
this.sessionFactoryOptions = options;
this.settings = new Settings( options, bootMetamodel );
this.serviceRegistry = options
.getServiceRegistry()
@ -213,7 +210,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
final CfgXmlAccessService cfgXmlAccessService = serviceRegistry.getService( CfgXmlAccessService.class );
String sfName = settings.getSessionFactoryName();
String sfName = sessionFactoryOptions.getSessionFactoryName();
if ( cfgXmlAccessService.getAggregatedConfig() != null ) {
if ( sfName == null ) {
sfName = cfgXmlAccessService.getAggregatedConfig().getSessionFactoryName();
@ -384,7 +381,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
SessionFactoryRegistry.INSTANCE.addSessionFactory(
getUuid(),
name,
settings.isSessionFactoryNameAlsoJndiName(),
sessionFactoryOptions.isSessionFactoryNameAlsoJndiName(),
this,
serviceRegistry.getService( JndiService.class )
);
@ -815,7 +812,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
SessionFactoryRegistry.INSTANCE.removeSessionFactory(
getUuid(),
name,
settings.isSessionFactoryNameAlsoJndiName(),
sessionFactoryOptions.isSessionFactoryNameAlsoJndiName(),
serviceRegistry.getService( JndiService.class )
);
}

View File

@ -16,13 +16,14 @@ import jakarta.persistence.Id;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.cfg.AttributeConverterDefinition;
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.boot.BootstrapContextImpl;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
import org.junit.jupiter.api.Test;
@ -44,8 +45,16 @@ public class ParameterizedAttributeConverterParameterTypeTest {
@Test
@TestForIssue(jiraKey = "HHH-8804")
public void testGenericTypeParameters() {
AttributeConverterDefinition def = AttributeConverterDefinition.from( CustomAttributeConverter.class );
assertEquals( List.class, def.getEntityAttributeType() );
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl();
try {
final ClassBasedConverterDescriptor converterDescriptor = new ClassBasedConverterDescriptor(
CustomAttributeConverter.class,
bootstrapContext.getClassmateContext()
);
assertEquals( List.class, converterDescriptor.getDomainValueResolvedType().getErasedType() );
} finally {
bootstrapContext.close();
}
}
@Test

View File

@ -10,7 +10,6 @@ import java.util.List;
import jakarta.persistence.AttributeConverter;
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
import org.hibernate.cfg.AttributeConverterDefinition;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.boot.BootstrapContextImpl;
@ -79,8 +78,18 @@ public class AttributeConverterOnSuperclassTest extends BaseUnitTestCase {
@Test
public void testAttributeConverterOnInterface() {
AttributeConverterDefinition def = AttributeConverterDefinition.from( StringLongAttributeConverterImpl.class );
assertEquals( String.class, def.getEntityAttributeType() );
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl();
try {
final ClassBasedConverterDescriptor converterDescriptor = new ClassBasedConverterDescriptor(
StringLongAttributeConverterImpl.class,
bootstrapContext.getClassmateContext()
);
assertEquals( String.class, converterDescriptor.getDomainValueResolvedType().getErasedType() );
}
finally {
bootstrapContext.close();
}
}
public static class NoopAttributeConverter<T> implements AttributeConverter<T, T> {
@ -101,8 +110,18 @@ public class AttributeConverterOnSuperclassTest extends BaseUnitTestCase {
@Test
public void testTypeVariableAttributeConverterTypeArguments() {
AttributeConverterDefinition def = AttributeConverterDefinition.from( StringNoopAttributeConverter.class );
assertEquals( String.class, def.getEntityAttributeType() );
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl();
try {
final ClassBasedConverterDescriptor converterDescriptor = new ClassBasedConverterDescriptor(
StringNoopAttributeConverter.class,
bootstrapContext.getClassmateContext()
);
assertEquals( String.class, converterDescriptor.getDomainValueResolvedType().getErasedType() );
}
finally {
bootstrapContext.close();
}
}
public static class ListNoopAttributeConverter<T> extends NoopAttributeConverter<List<T>> {
@ -113,8 +132,18 @@ public class AttributeConverterOnSuperclassTest extends BaseUnitTestCase {
@Test
public void testParameterizedTypeWithTypeVariableAttributeConverterTypeArguments() {
AttributeConverterDefinition def = AttributeConverterDefinition.from( StringListNoopAttributeConverter.class );
assertEquals( List.class, def.getEntityAttributeType() );
final BootstrapContextImpl bootstrapContext = new BootstrapContextImpl();
try {
final ClassBasedConverterDescriptor converterDescriptor = new ClassBasedConverterDescriptor(
StringListNoopAttributeConverter.class,
bootstrapContext.getClassmateContext()
);
assertEquals( List.class, converterDescriptor.getDomainValueResolvedType().getErasedType() );
}
finally {
bootstrapContext.close();
}
}
}

View File

@ -111,15 +111,6 @@ public class MappingExceptionTest {
assertEquals( "nothere", e.getOrigin().getName() );
}
try {
cfg.addResource( "nothere", getClass().getClassLoader() );
fail();
}
catch (org.hibernate.boot.MappingNotFoundException e) {
assertEquals( SourceType.RESOURCE, e.getOrigin().getType() );
assertEquals( "nothere", e.getOrigin().getName() );
}
try {
cfg.addURL( new URL( "file://nothere" ) );
fail();
@ -211,15 +202,6 @@ public class MappingExceptionTest {
assertEquals( resourceName, inv.getPath() );
}
try {
cfg.addResource( resourceName, getClass().getClassLoader() );
fail();
}
catch (InvalidMappingException inv) {
assertEquals( "resource", inv.getType() );
assertEquals( resourceName, inv.getPath() );
}
try {
cfg.addURL( ConfigHelper.findAsResource( resourceName ) );
fail();

View File

@ -212,13 +212,10 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
if ( mappings != null ) {
for ( String mapping : mappings ) {
if ( mapping.startsWith( "/" ) ) {
configuration.addResource( mapping, getClass().getClassLoader() );
configuration.addResource( mapping );
}
else {
configuration.addResource(
getBaseForMappings() + mapping,
getClass().getClassLoader()
);
configuration.addResource( getBaseForMappings() + mapping );
}
}
}