even more removals of deprecated stuff

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-05-31 20:57:54 +02:00 committed by Steve Ebersole
parent 8ac9db495a
commit 21b7d3f229
51 changed files with 130 additions and 1393 deletions

View File

@ -1,28 +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.annotations;
import jakarta.persistence.AttributeConverter;
import org.hibernate.Remove;
/**
* @author Steve Ebersole
*
* @deprecated this class is no longer used
*/
@Deprecated(since= "6.2") @Remove
public class NoAttributeConverter<O,R> implements AttributeConverter<O,R> {
@Override
public R convertToDatabaseColumn(Object attribute) {
throw new UnsupportedOperationException();
}
@Override
public O convertToEntityAttribute(Object dbData) {
throw new UnsupportedOperationException();
}
}

View File

@ -18,7 +18,6 @@ import org.hibernate.annotations.CacheLayout;
import org.hibernate.cache.spi.TimestampsCacheFactory;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
@ -269,20 +268,6 @@ public interface SessionFactoryBuilder {
*/
SessionFactoryBuilder applyTempTableDdlTransactionHandling(TempTableDdlTransactionHandling handling);
/**
* What style of batching should be used?
*
* @param style The style to use
*
* @return {@code this}, for method chaining
*
* @see org.hibernate.cfg.AvailableSettings#BATCH_FETCH_STYLE
*
* @deprecated : an appropriate style is selected
*/
@Deprecated(since = "6.0")
SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style);
/**
* Should entity {@linkplain org.hibernate.loader.ast.spi.Loader loaders} be
* generated immediately? Or should the creation be delayed until first need?

View File

@ -26,7 +26,6 @@ import org.hibernate.bytecode.spi.BytecodeProvider;
import org.hibernate.cache.spi.TimestampsCacheFactory;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
@ -201,12 +200,6 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
return this;
}
@Override
public SessionFactoryBuilder applyBatchFetchStyle(BatchFetchStyle style) {
this.optionsBuilder.applyBatchFetchStyle( style );
return this;
}
@Override
public SessionFactoryBuilder applyDelayedEntityLoaderCreations(boolean delay) {
this.optionsBuilder.applyDelayedEntityLoaderCreations( delay );

View File

@ -54,7 +54,6 @@ 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;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.NullPrecedence;
@ -83,7 +82,6 @@ import static org.hibernate.cfg.AvailableSettings.ALLOW_UPDATE_OUTSIDE_TRANSACTI
import static org.hibernate.cfg.AvailableSettings.AUTO_CLOSE_SESSION;
import static org.hibernate.cfg.AvailableSettings.AUTO_EVICT_COLLECTION_CACHE;
import static org.hibernate.cfg.AvailableSettings.AUTO_SESSION_EVENTS_LISTENER;
import static org.hibernate.cfg.AvailableSettings.BATCH_FETCH_STYLE;
import static org.hibernate.cfg.AvailableSettings.BATCH_VERSIONED_DATA;
import static org.hibernate.cfg.AvailableSettings.CACHE_REGION_PREFIX;
import static org.hibernate.cfg.AvailableSettings.CALLABLE_NAMED_PARAMS_ENABLED;
@ -201,7 +199,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
private boolean checkNullability;
private boolean initializeLazyStateOutsideTransactions;
private TempTableDdlTransactionHandling tempTableDdlTransactionHandling;
private BatchFetchStyle batchFetchStyle;
private boolean delayBatchFetchLoaderCreations;
private int defaultBatchFetchSize;
private Integer maximumFetchDepth;
@ -380,7 +377,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
configurationSettings.get( MULTI_TENANT_IDENTIFIER_RESOLVER )
);
this.batchFetchStyle = BatchFetchStyle.interpret( configurationSettings.get( BATCH_FETCH_STYLE ) );
this.delayBatchFetchLoaderCreations = configurationService.getSetting( DELAY_ENTITY_LOADER_CREATIONS, BOOLEAN, true );
this.defaultBatchFetchSize = getInt( DEFAULT_BATCH_FETCH_SIZE, configurationSettings, -1 );
this.subselectFetchEnabled = getBoolean( USE_SUBSELECT_FETCH, configurationSettings );
@ -1025,11 +1021,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
return tempTableDdlTransactionHandling;
}
@Override
public BatchFetchStyle getBatchFetchStyle() {
return batchFetchStyle;
}
@Override
public boolean isDelayBatchFetchLoaderCreationsEnabled() {
return delayBatchFetchLoaderCreations;
@ -1443,14 +1434,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
this.tempTableDdlTransactionHandling = handling;
}
/**
* @deprecated : No longer used internally
*/
@Deprecated(since = "6.0")
public void applyBatchFetchStyle(BatchFetchStyle style) {
this.batchFetchStyle = style;
}
public void applyDelayedEntityLoaderCreations(boolean delay) {
this.delayBatchFetchLoaderCreations = delay;
}

View File

@ -171,11 +171,6 @@ public class PluralAttributeMapKeyManyToAnySourceImpl
return Nature.ANY;
}
@Override
public boolean isReferencedEntityAttribute() {
return false;
}
@Override
public PluralAttributeIndexNature getNature() {
return PluralAttributeIndexNature.MANY_TO_ANY;

View File

@ -143,11 +143,6 @@ public class PluralAttributeMapKeyManyToManySourceImpl
return Nature.MANY_TO_MANY;
}
@Override
public boolean isReferencedEntityAttribute() {
return true;
}
@Override
public List<RelationalValueSource> getRelationalValueSources() {
return relationalValueSources;

View File

@ -22,20 +22,9 @@ public interface PluralAttributeMapKeySource extends PluralAttributeIndexSource
ANY
}
Nature getMapKeyNature();
/**
* Is this plural attribute index source for an attribute of the referenced
* entity (relevant only for one-to-many and many-to-many associations)?
* <p>
* If this method returns {@code true}, then this object can safely
* be cast to {@link PluralAttributeMapKeyManyToManySource}.
*
* @return true, if this plural attribute index source for an attribute of
* the referenced entity; false, otherwise.
*
* @deprecated no longer used, so this should be removed
* @deprecated No longer used
*/
@Deprecated(since = "6.4")
boolean isReferencedEntityAttribute();
@Deprecated(since = "7.0", forRemoval = true)
Nature getMapKeyNature();
}

View File

@ -16,14 +16,11 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.hibernate.Internal;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
@ -84,32 +81,6 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
this.aggregatedClassLoader = new AggregatedClassLoader( orderedClassLoaderSet, lookupPrecedence );
}
/**
* No longer used/supported!
*
* @param configValues The config values
*
* @return The built service
*
* @deprecated No longer used/supported!
*/
@Deprecated
@SuppressWarnings("unchecked")
@Internal
public static ClassLoaderServiceImpl fromConfigSettings(Map configValues) {
final List<ClassLoader> providedClassLoaders = new ArrayList<>();
final Collection<ClassLoader> classLoaders = (Collection<ClassLoader>) configValues.get( AvailableSettings.CLASSLOADERS );
if ( classLoaders != null ) {
providedClassLoaders.addAll( classLoaders );
}
return new ClassLoaderServiceImpl(
providedClassLoaders,
TcclLookupPrecedence.from( configValues, TcclLookupPrecedence.AFTER )
);
}
@Override
@SuppressWarnings("unchecked")
public <T> Class<T> classForName(String className) {

View File

@ -18,7 +18,6 @@ import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.TempTableDdlTransactionHandling;
import org.hibernate.cache.spi.TimestampsCacheFactory;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
@ -157,12 +156,6 @@ public abstract class AbstractDelegatingSessionFactoryBuilder<T extends SessionF
return getThis();
}
@Override
public T applyBatchFetchStyle(BatchFetchStyle style) {
delegate.applyBatchFetchStyle( style );
return getThis();
}
@Override
public T applyDelayedEntityLoaderCreations(boolean delay) {
delegate.applyDelayedEntityLoaderCreations( delay );

View File

@ -23,7 +23,6 @@ import org.hibernate.cache.spi.TimestampsCacheFactory;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.internal.BaselineSessionEventsListenerBuilder;
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.criteria.ValueHandlingMode;
@ -170,11 +169,6 @@ public class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOp
return delegate.getTempTableDdlTransactionHandling();
}
@Override
public BatchFetchStyle getBatchFetchStyle() {
return delegate.getBatchFetchStyle();
}
@Override
public boolean isDelayBatchFetchLoaderCreationsEnabled() {
return delegate.isDelayBatchFetchLoaderCreationsEnabled();

View File

@ -24,7 +24,6 @@ import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.BaselineSessionEventsListenerBuilder;
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.criteria.ValueHandlingMode;
@ -136,12 +135,6 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
TempTableDdlTransactionHandling getTempTableDdlTransactionHandling();
/**
* @deprecated : No longer used internally
*/
@Deprecated(since = "6.0")
BatchFetchStyle getBatchFetchStyle();
boolean isDelayBatchFetchLoaderCreationsEnabled();
int getDefaultBatchFetchSize();

View File

@ -48,15 +48,4 @@ public interface FetchSettings {
* @see org.hibernate.boot.SessionFactoryBuilder#applySubselectFetchEnabled(boolean)
*/
String USE_SUBSELECT_FETCH = "hibernate.use_subselect_fetch";
/**
* Specifies the {@link org.hibernate.loader.BatchFetchStyle} to use,
* either the name of a {code BatchFetchStyle} instance, or an instance
* of {@code BatchFetchStyle}.
*
* @deprecated An appropriate batch-fetch style is selected automatically
*/
@Deprecated(since = "6.0")
@SuppressWarnings("DeprecatedIsStillUsed")
String BATCH_FETCH_STYLE = "hibernate.batch_fetch_style";
}

View File

@ -17,36 +17,12 @@ import org.hibernate.jdbc.Expectations;
*/
public class BasicBatchKey implements BatchKey {
private final String comparison;
private final int statementCount;
private final Expectation expectation;
/**
* Constructs a BasicBatchKey with {@link Expectations#NONE}
*/
public BasicBatchKey(String comparison) {
this( comparison, Expectations.NONE );
}
/**
* Constructs a BasicBatchKey
*
* @param comparison A string used to compare batch keys.
* @param expectation The expectation for the batch
*/
public BasicBatchKey(String comparison, Expectation expectation) {
this.comparison = comparison;
this.statementCount = 1;
this.expectation = expectation;
}
@Override
public Expectation getExpectation() {
return expectation;
}
@Override
public int getBatchedStatementCount() {
return statementCount;
}
@Override

View File

@ -6,36 +6,12 @@
*/
package org.hibernate.engine.jdbc.batch.spi;
import org.hibernate.jdbc.Expectation;
/**
* Unique key for batch identification.
*
* @author Steve Ebersole
*/
public interface BatchKey {
/**
* How many statements will be in this batch?
* <p>
* Note that this is distinctly different to the size of the batch.
*
* @return The number of statements.
*
* @deprecated With no replacement. No longer used
*/
@Deprecated
int getBatchedStatementCount();
/**
* Get the expectation pertaining to the outcome of the {@link Batch} associated with this key.
*
* @return The expectations
*
* @deprecated With no replacement. No longer used
*/
@Deprecated
Expectation getExpectation();
default String toLoggableString() {
return toString();
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.engine.spi;
import java.io.Serializable;
import java.util.Collection;
import org.hibernate.CustomEntityDirtinessStrategy;
@ -202,16 +201,6 @@ public interface SessionFactoryImplementor
@Deprecated(since = "6.2")
IdentifierGenerator getIdentifierGenerator(String rootEntityName);
/**
* Contract for resolving this SessionFactory on deserialization
*
* @deprecated this is no longer used
*/
@Deprecated(since = "6.2", forRemoval = true)
interface DeserializationResolver<T extends SessionFactoryImplementor> extends Serializable {
T resolve();
}
/**
* @deprecated no longer for internal use, use {@link #getMappingMetamodel()} or {@link #getJpaMetamodel()}
*/

View File

@ -27,20 +27,6 @@ public class OptimizerFactory {
OptimizerFactory.class.getName()
);
/**
* Does the given optimizer name represent a pooled strategy?
*
* @param optimizerName The name of the optimizer
*
* @return {@code true} indicates the optimizer is a pooled strategy.
*
* @deprecated No longer used
*/
@Deprecated(since = "6.3")
public static boolean isPooledOptimizer(String optimizerName) {
return StandardOptimizerDescriptor.fromExternalName( optimizerName ).isPooled();
}
private static final Class<?>[] CTOR_SIG = new Class[] { Class.class, int.class };
private static Optimizer buildOptimizer(OptimizerDescriptor descriptor, Class<?> returnClass, int incrementSize) {

View File

@ -28,9 +28,6 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.property.access.internal.PropertyAccessStrategyMixedImpl;
import org.hibernate.property.access.spi.Getter;
import org.hibernate.type.BasicType;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.spi.PrimitiveJavaType;
import jakarta.persistence.Transient;
@ -349,52 +346,6 @@ public final class ReflectHelper {
return Modifier.isFinal( clazz.getModifiers() );
}
/**
* Retrieve a constructor for the given class, with arguments matching
* the specified Hibernate mapping {@linkplain Type types}.
*
* @param clazz The class needing instantiation
* @param types The types representing the required ctor param signature
* @return The matching constructor
* @throws PropertyNotFoundException Indicates we could not locate an appropriate constructor
*
* @deprecated no longer used, since we moved away from the {@link Type} interface
*/
// todo : again with PropertyNotFoundException???
@Deprecated(since = "6", forRemoval = true)
public static Constructor<?> getConstructor(Class<?> clazz, Type[] types) throws PropertyNotFoundException {
final Constructor<?>[] candidates = clazz.getConstructors();
Constructor<?> constructor = null;
int numberOfMatchingConstructors = 0;
for ( final Constructor<?> candidate : candidates ) {
final Class<?>[] params = candidate.getParameterTypes();
if ( params.length == types.length ) {
boolean found = true;
for ( int j = 0; j < params.length; j++ ) {
final boolean ok = types[j] == null || params[j].isAssignableFrom( types[j].getReturnedClass() ) || (
types[j] instanceof BasicType<?> && ( (BasicType<?>) types[j] ).getJavaTypeDescriptor() instanceof PrimitiveJavaType
&& params[j] == ( (PrimitiveJavaType<?>) ( ( (BasicType<?>) types[j] ).getJavaTypeDescriptor() ) ).getPrimitiveClass()
);
if ( !ok ) {
found = false;
break;
}
}
if ( found ) {
numberOfMatchingConstructors ++;
ensureAccessibility( candidate );
constructor = candidate;
}
}
}
if ( numberOfMatchingConstructors == 1 ) {
return constructor;
}
throw new PropertyNotFoundException( "no appropriate constructor in class: " + clazz.getName() );
}
/**
* Retrieve a constructor for the given class, with arguments matching
* the specified Java {@linkplain Class types}, or return {@code null}

View File

@ -11,6 +11,7 @@ import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -27,6 +28,7 @@ import org.hibernate.boot.jaxb.configuration.spi.JaxbPersistenceImpl.JaxbPersist
import org.hibernate.boot.jaxb.internal.ConfigurationBinder;
import org.hibernate.boot.jaxb.spi.Binding;
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.EntityManagerMessageLogger;
@ -55,28 +57,16 @@ public class PersistenceXmlParser {
*
* @return List of descriptors for all discovered persistence-units.
*/
@SuppressWarnings({ "removal", "deprecation" })
public static List<ParsedPersistenceXmlDescriptor> locatePersistenceUnits(Map<?,?> integration) {
@SuppressWarnings("removal")
final PersistenceXmlParser parser = new PersistenceXmlParser(
ClassLoaderServiceImpl.fromConfigSettings( integration ),
fromConfigSettings( integration ),
PersistenceUnitTransactionType.RESOURCE_LOCAL
);
parser.doResolve( integration );
return new ArrayList<>( parser.persistenceUnits.values() );
}
/**
* Parse a specific {@code persistence.xml} with the assumption that it defines a single
* persistence-unit.
*
* @param persistenceXmlUrl The {@code persistence.xml} URL
*
* @return The single persistence-unit descriptor
*/
public static ParsedPersistenceXmlDescriptor locateIndividualPersistenceUnit(URL persistenceXmlUrl) {
return locateIndividualPersistenceUnit( persistenceXmlUrl, Collections.emptyMap() );
}
/**
* Parse a specific {@code persistence.xml} with the assumption that it defines a single
* persistence-unit.
@ -101,13 +91,13 @@ public class PersistenceXmlParser {
*
* @return The single persistence-unit descriptor
*/
@SuppressWarnings({ "removal", "deprecation" })
public static ParsedPersistenceXmlDescriptor locateIndividualPersistenceUnit(
URL persistenceXmlUrl,
@SuppressWarnings("removal")
PersistenceUnitTransactionType transactionType,
Map<?,?> integration) {
final PersistenceXmlParser parser = new PersistenceXmlParser(
ClassLoaderServiceImpl.fromConfigSettings( integration ),
fromConfigSettings( integration ),
transactionType
);
@ -154,16 +144,16 @@ public class PersistenceXmlParser {
*
* @return The matching persistence-unit descriptor
*/
@SuppressWarnings({ "removal", "deprecation" })
public static ParsedPersistenceXmlDescriptor locateNamedPersistenceUnit(
URL persistenceXmlUrl,
String name,
@SuppressWarnings("removal")
PersistenceUnitTransactionType transactionType,
Map<?,?> integration) {
assert StringHelper.isNotEmpty( name );
final PersistenceXmlParser parser = new PersistenceXmlParser(
ClassLoaderServiceImpl.fromConfigSettings( integration ),
fromConfigSettings( integration ),
transactionType
);
@ -195,13 +185,13 @@ public class PersistenceXmlParser {
*
* @return Map of persistence-unit descriptors keyed by the PU name
*/
@SuppressWarnings({ "removal", "deprecation" })
public static Map<String, ParsedPersistenceXmlDescriptor> parse(
URL persistenceXmlUrl,
@SuppressWarnings("removal")
PersistenceUnitTransactionType transactionType,
Map<?,?> integration) {
PersistenceXmlParser parser = new PersistenceXmlParser(
ClassLoaderServiceImpl.fromConfigSettings( integration ),
fromConfigSettings( integration ),
transactionType
);
@ -210,6 +200,7 @@ public class PersistenceXmlParser {
}
private final ClassLoaderService classLoaderService;
@SuppressWarnings("removal")
private final PersistenceUnitTransactionType defaultTransactionType;
private final Map<String, ParsedPersistenceXmlDescriptor> persistenceUnits;
@ -220,8 +211,20 @@ public class PersistenceXmlParser {
this.persistenceUnits = new ConcurrentHashMap<>();
}
protected List<ParsedPersistenceXmlDescriptor> getResolvedPersistenceUnits() {
return new ArrayList<>(persistenceUnits.values());
private static ClassLoaderServiceImpl fromConfigSettings(Map<?,?> configValues) {
final List<ClassLoader> providedClassLoaders = new ArrayList<>();
@SuppressWarnings("unchecked")
final Collection<ClassLoader> classLoaders =
(Collection<ClassLoader>) configValues.get( AvailableSettings.CLASSLOADERS );
if ( classLoaders != null ) {
providedClassLoaders.addAll( classLoaders );
}
return new ClassLoaderServiceImpl(
providedClassLoaders,
TcclLookupPrecedence.from( configValues, TcclLookupPrecedence.AFTER )
);
}
private void doResolve(Map<?,?> integration) {
@ -290,7 +293,7 @@ public class PersistenceXmlParser {
persistenceUnitDescriptor.setJtaDataSource( jaxbPersistenceUnit.getJtaDataSource() );
persistenceUnitDescriptor.setSharedCacheMode( jaxbPersistenceUnit.getSharedCacheMode() );
persistenceUnitDescriptor.setValidationMode( jaxbPersistenceUnit.getValidationMode() );
persistenceUnitDescriptor.setExcludeUnlistedClasses( handleBoolean( jaxbPersistenceUnit.isExcludeUnlistedClasses(), false ) );
persistenceUnitDescriptor.setExcludeUnlistedClasses( handleBoolean( jaxbPersistenceUnit.isExcludeUnlistedClasses() ) );
persistenceUnitDescriptor.addClasses( jaxbPersistenceUnit.getClasses() );
persistenceUnitDescriptor.addMappingFiles( jaxbPersistenceUnit.getMappingFiles() );
persistenceUnitDescriptor.addJarFileUrls( jaxbPersistenceUnit.getJarFiles() );
@ -306,11 +309,11 @@ public class PersistenceXmlParser {
}
}
private boolean handleBoolean(Boolean incoming, boolean fallback) {
private boolean handleBoolean(Boolean incoming) {
if ( incoming != null ) {
return incoming;
}
return fallback;
return false;
}
@SuppressWarnings("deprecation")
@ -370,25 +373,23 @@ public class PersistenceXmlParser {
@SuppressWarnings("removal")
private void applyTransactionTypeOverride(ParsedPersistenceXmlDescriptor persistenceUnitDescriptor) {
// if transaction type is set already, use that value
if ( persistenceUnitDescriptor.getTransactionType() != null ) {
return;
}
// else
// if JTA DS
// use JTA
// else if NOT JTA DS
// use RESOURCE_LOCAL
// else
// use defaultTransactionType
if ( persistenceUnitDescriptor.getJtaDataSource() != null ) {
persistenceUnitDescriptor.setTransactionType( PersistenceUnitTransactionType.JTA );
}
else if ( persistenceUnitDescriptor.getNonJtaDataSource() != null ) {
persistenceUnitDescriptor.setTransactionType( PersistenceUnitTransactionType.RESOURCE_LOCAL );
}
else {
persistenceUnitDescriptor.setTransactionType( defaultTransactionType );
if ( persistenceUnitDescriptor.getTransactionType() == null ) {
// else
// if JTA DS
// use JTA
// else if NOT JTA DS
// use RESOURCE_LOCAL
// else
// use defaultTransactionType
if ( persistenceUnitDescriptor.getJtaDataSource() != null ) {
persistenceUnitDescriptor.setTransactionType( PersistenceUnitTransactionType.JTA );
}
else if ( persistenceUnitDescriptor.getNonJtaDataSource() != null ) {
persistenceUnitDescriptor.setTransactionType( PersistenceUnitTransactionType.RESOURCE_LOCAL );
}
else {
persistenceUnitDescriptor.setTransactionType( defaultTransactionType );
}
}
}

View File

@ -63,6 +63,7 @@ public final class Bootstrap {
public static EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(
URL persistenceXmlUrl,
String persistenceUnitName,
@SuppressWarnings("removal")
PersistenceUnitTransactionType transactionType,
Map integration) {
return new EntityManagerFactoryBuilderImpl(

View File

@ -1,80 +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.loader;
import java.util.Locale;
import org.hibernate.loader.ast.spi.MultiKeyLoadSizingStrategy;
import org.jboss.logging.Logger;
/**
* Defines a type of batch loading.
*
* @see org.hibernate.cfg.AvailableSettings#BATCH_FETCH_STYLE
*
* @author Steve Ebersole
*
* @deprecated see {@link MultiKeyLoadSizingStrategy} instead
*/
@Deprecated(since = "6.0")
public enum BatchFetchStyle {
/**
* The legacy algorithm where we keep a set of pre-built batch sizes based on
* {@code org.hibernate.internal.util.collections.ArrayHelper#getBatchSizes}. Batches are performed
* using the next-smaller pre-built batch size from the number of existing batchable identifiers.
* <p>
* For example, with a batch-size setting of 32 the pre-built batch sizes would be [32, 16, 10, 9, 8, 7, .., 1].
* An attempt to batch load 31 identifiers would result in batches of 16, 10, and 5.
*/
LEGACY,
/**
* Still keeps the concept of pre-built batch sizes, but uses the next-bigger batch size and pads the extra
* identifier placeholders.
* <p>
* Using the same example of a batch-size setting of 32 the pre-built batch sizes would be the same. However, the
* attempt to batch load 31 identifiers would result just a single batch of size 32. The identifiers to load would
* be "padded" (aka, repeated) to make up the difference.
*/
PADDED,
/**
* Dynamically builds its SQL based on the actual number of available ids. Does still limit to the batch-size
* defined on the entity/collection
*/
DYNAMIC;
private static final Logger log = Logger.getLogger( BatchFetchStyle.class );
public static BatchFetchStyle byName(String name) {
return valueOf( name.toUpperCase(Locale.ROOT) );
}
public static BatchFetchStyle interpret(Object setting) {
log.tracef( "Interpreting BatchFetchStyle from setting : %s", setting );
if ( setting == null ) {
return LEGACY; // as default
}
if ( setting instanceof BatchFetchStyle ) {
return (BatchFetchStyle) setting;
}
try {
final BatchFetchStyle byName = byName( setting.toString() );
if ( byName != null ) {
return byName;
}
}
catch (Exception ignore) {
}
log.debugf( "Unable to interpret given setting [%s] as BatchFetchStyle", setting );
return LEGACY; // again as default.
}
}

View File

@ -1,62 +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.mapping;
import org.hibernate.Remove;
import java.io.Serializable;
import java.util.Properties;
/**
* Identifier generator container,
* Useful to keep named generator in annotations
*
* @author Emmanuel Bernard
*
* @deprecated this class is no longer used
*/
@Deprecated(since = "6.2") @Remove
public class IdGenerator implements Serializable {
private String name;
private String identifierGeneratorStrategy;
private Properties params = new Properties();
/**
* @return identifier generator strategy
*/
public String getIdentifierGeneratorStrategy() {
return identifierGeneratorStrategy;
}
/**
* @return generator name
*/
public String getName() {
return name;
}
/**
* @return generator configuration parameters
*/
public Properties getParams() {
return params;
}
public void setIdentifierGeneratorStrategy(String string) {
identifierGeneratorStrategy = string;
}
public void setName(String string) {
name = string;
}
public void addParam(String key, String value) {
params.setProperty( key, value );
}
}

View File

@ -1,22 +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.mapping;
/**
* A consumer like {@link java.util.function.BiConsumer} but also accepts an integer as index.
*
* @author Christian Beikov
*
* @deprecated Use {@link org.hibernate.internal.util.IndexedBiConsumer} instead
*/
@Deprecated
@FunctionalInterface
public interface IndexedBiConsumer<T, U> {
void accept(int index, T t, U u);
}

View File

@ -1,20 +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.mapping;
/**
* A consumer like {@link java.util.function.Consumer} but also accepts an integer as index.
*
* @author Christian Beikov
*
* @deprecated Use {@link org.hibernate.internal.util.IndexedConsumer} instead
*/
@Deprecated
@FunctionalInterface
public interface IndexedConsumer<T> {
void accept(int index, T t);
}

View File

@ -1,66 +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.mapping;
import org.hibernate.Remove;
import java.io.Serializable;
/**
* Indicates whether given properties are generated by the database and, if
* so, at what time(s) they are generated.
*
* @author Steve Ebersole
*
* @deprecated This is replaced by {@link org.hibernate.tuple.ValueGeneration} and
* {@link org.hibernate.tuple.GenerationTiming}, and is no longer used
*/
@Deprecated @Remove
public class PropertyGeneration implements Serializable {
/**
* Values for this property are never generated by the database.
*/
public static final PropertyGeneration NEVER = new PropertyGeneration( "never" );
/**
* Values for this property are generated by the database on insert.
*/
public static final PropertyGeneration INSERT = new PropertyGeneration( "insert" );
/**
* Values for this property are generated by the database on both insert and update.
*/
public static final PropertyGeneration ALWAYS = new PropertyGeneration( "always" );
private final String name;
private PropertyGeneration(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static PropertyGeneration parse(String name) {
if ( "insert".equalsIgnoreCase( name ) ) {
return INSERT;
}
else if ( "always".equalsIgnoreCase( name ) ) {
return ALWAYS;
}
else {
return NEVER;
}
}
private Object readResolve() {
return parse( name );
}
public String toString() {
return getClass().getSimpleName() + "(" + getName() + ")";
}
}

View File

@ -1,21 +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.mapping;
import org.hibernate.Remove;
import org.hibernate.collection.spi.CollectionSemantics;
/**
* @author Steve Ebersole
*
* @deprecated this is no longer used
*/
@FunctionalInterface
@Deprecated @Remove
public interface SemanticsResolver {
CollectionSemantics<?, ?> resolve(org.hibernate.type.CollectionType explicitType);
}

View File

@ -1,36 +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.mapping;
import org.hibernate.Remove;
import java.io.Serializable;
import java.util.Properties;
/**
* Placeholder for typedef information
*
* @deprecated no longer used
*/
@Deprecated @Remove
public class TypeDef implements Serializable {
private String typeClass;
private Properties parameters;
public TypeDef(String typeClass, Properties parameters) {
this.typeClass = typeClass;
this.parameters = parameters;
}
public Properties getParameters() {
return parameters;
}
public String getTypeClass() {
return typeClass;
}
}

View File

@ -64,10 +64,7 @@ public class InsertCoordinatorStandard extends AbstractMutationCoordinator imple
batchKey = null;
}
else {
batchKey = new BasicBatchKey(
entityPersister.getEntityName() + "#INSERT",
null
);
batchKey = new BasicBatchKey( entityPersister.getEntityName() + "#INSERT" );
}
if ( entityPersister.getEntityMetamodel().isDynamicInsert() ) {

View File

@ -98,14 +98,8 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
this.versionUpdateBatchkey = null;
}
else {
this.batchKey = new BasicBatchKey(
entityPersister.getEntityName() + "#UPDATE",
null
);
this.versionUpdateBatchkey = new BasicBatchKey(
entityPersister.getEntityName() + "#UPDATE_VERSION",
null
);
this.batchKey = new BasicBatchKey( entityPersister.getEntityName() + "#UPDATE" );
this.versionUpdateBatchkey = new BasicBatchKey( entityPersister.getEntityName() + "#UPDATE_VERSION" );
}
}

View File

@ -42,7 +42,10 @@ public enum NullPrecedence {
/**
* Is this null precedence the default for the given sort order and null ordering.
*
* @deprecated No longer called
*/
@Deprecated(since = "7.0", forRemoval = true)
public boolean isDefaultOrdering(SortDirection sortOrder, NullOrdering nullOrdering) {
switch (this) {
case NONE:

View File

@ -11,7 +11,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.internal.FilterJdbcParameter;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
@ -26,22 +25,6 @@ public class AbstractJdbcOperationQuery implements JdbcOperationQuery {
protected final Set<String> affectedTableNames;
protected final Map<JdbcParameter, JdbcParameterBinding> appliedParameters;
/**
* @deprecated {@code filterJdbcParameters} is no longer used
*/
@Deprecated
public AbstractJdbcOperationQuery(
String sql,
List<JdbcParameterBinder> parameterBinders,
Set<String> affectedTableNames,
Set<FilterJdbcParameter> filterJdbcParameters) {
this(
sql,
parameterBinders,
affectedTableNames
);
}
public AbstractJdbcOperationQuery(
String sql,
List<JdbcParameterBinder> parameterBinders,
@ -54,19 +37,6 @@ public class AbstractJdbcOperationQuery implements JdbcOperationQuery {
);
}
/**
* @deprecated {@code filterJdbcParameters} is no longer used
*/
@Deprecated
public AbstractJdbcOperationQuery(
String sql,
List<JdbcParameterBinder> parameterBinders,
Set<String> affectedTableNames,
Set<FilterJdbcParameter> filterJdbcParameters,
Map<JdbcParameter, JdbcParameterBinding> appliedParameters) {
this( sql, parameterBinders, affectedTableNames, appliedParameters );
}
public AbstractJdbcOperationQuery(
String sql,
List<JdbcParameterBinder> parameterBinders,

View File

@ -6,11 +6,9 @@
*/
package org.hibernate.sql.exec.spi;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.hibernate.internal.FilterJdbcParameter;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
@ -26,18 +24,6 @@ public interface JdbcOperationQuery extends JdbcOperation {
*/
Set<String> getAffectedTableNames();
/**
* Any parameters to apply for filters
*
* @see org.hibernate.annotations.Filter
*
* @deprecated No longer used.
*/
@Deprecated(since = "6.2")
default Set<FilterJdbcParameter> getFilterJdbcParameters() {
return Collections.emptySet();
}
/**
* Signals that the SQL depends on the parameter bindings e.g. due to the need for inlining
* of parameter values or multiValued parameters.
@ -46,7 +32,10 @@ public interface JdbcOperationQuery extends JdbcOperation {
/**
* The parameters which were inlined into the query as literals.
*
* @deprecated No longer called
*/
@Deprecated(since = "7.0", forRemoval = true)
Map<JdbcParameter, JdbcParameterBinding> getAppliedParameters();
boolean isCompatibleWith(JdbcParameterBindings jdbcParameterBindings, QueryOptions queryOptions);

View File

@ -10,27 +10,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.internal.FilterJdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
/**
* @author Steve Ebersole
*/
public class JdbcOperationQueryDelete extends AbstractJdbcOperationQuery implements JdbcOperationQueryMutation {
/**
* @deprecated {@code filterJdbcParameters} is no longer used
*/
@Deprecated
public JdbcOperationQueryDelete(
String sql,
List<JdbcParameterBinder> parameterBinders,
Set<String> affectedTableNames,
Set<FilterJdbcParameter> filterJdbcParameters,
Map<JdbcParameter, JdbcParameterBinding> appliedParameters) {
this( sql, parameterBinders, affectedTableNames, appliedParameters );
}
public JdbcOperationQueryDelete(
String sql,
List<JdbcParameterBinder> parameterBinders,

View File

@ -11,7 +11,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.internal.FilterJdbcParameter;
import org.hibernate.query.spi.Limit;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
@ -30,24 +29,6 @@ public class JdbcOperationQuerySelect extends AbstractJdbcOperationQuery {
private final JdbcParameter limitParameter;
private final JdbcLockStrategy jdbcLockStrategy;
/**
* @deprecated {@code filterJdbcParameters} is no longer used
*/
@Deprecated
public JdbcOperationQuerySelect(
String sql,
List<JdbcParameterBinder> parameterBinders,
JdbcValuesMappingProducer jdbcValuesMappingProducer,
Set<String> affectedTableNames,
Set<FilterJdbcParameter> filterJdbcParameters) {
this(
sql,
parameterBinders,
jdbcValuesMappingProducer,
affectedTableNames
);
}
public JdbcOperationQuerySelect(
String sql,
List<JdbcParameterBinder> parameterBinders,
@ -58,44 +39,13 @@ public class JdbcOperationQuerySelect extends AbstractJdbcOperationQuery {
parameterBinders,
jdbcValuesMappingProducer,
affectedTableNames,
null,
0,
Integer.MAX_VALUE,
Collections.emptyMap(),
JdbcLockStrategy.AUTO,
null,
null
);
}
/**
* @deprecated {@code filterJdbcParameters} is no longer used
*/
@Deprecated
public JdbcOperationQuerySelect(
String sql,
List<JdbcParameterBinder> parameterBinders,
JdbcValuesMappingProducer jdbcValuesMappingProducer,
Set<String> affectedTableNames,
Set<FilterJdbcParameter> filterJdbcParameters,
int rowsToSkip,
int maxRows,
Map<JdbcParameter, JdbcParameterBinding> appliedParameters,
JdbcLockStrategy jdbcLockStrategy,
JdbcParameter offsetParameter,
JdbcParameter limitParameter) {
this(
sql,
parameterBinders,
jdbcValuesMappingProducer,
affectedTableNames,
rowsToSkip,
maxRows,
appliedParameters,
jdbcLockStrategy,
offsetParameter,
limitParameter
);
);
}
public JdbcOperationQuerySelect(

View File

@ -10,7 +10,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.internal.FilterJdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
/**
@ -19,19 +18,6 @@ import org.hibernate.sql.ast.tree.expression.JdbcParameter;
public class JdbcOperationQueryUpdate
extends AbstractJdbcOperationQuery
implements JdbcOperationQueryMutation {
/**
* @deprecated {@code filterJdbcParameters} is no longer used
*/
@Deprecated
public JdbcOperationQueryUpdate(
String sql,
List<JdbcParameterBinder> parameterBinders,
Set<String> affectedTableNames,
Set<FilterJdbcParameter> filterJdbcParameters,
Map<JdbcParameter, JdbcParameterBinding> appliedParameters) {
this( sql, parameterBinders, affectedTableNames, appliedParameters );
}
public JdbcOperationQueryUpdate(
String sql,
List<JdbcParameterBinder> parameterBinders,

View File

@ -12,5 +12,8 @@
* Deprecated, use {@link org.hibernate.query.TupleTransformer}
* and/or {@link org.hibernate.query.ResultListTransformer}
* which are defined in {@link org.hibernate.query}.
*
* @deprecated The contents of this package are deprecated
*/
@Deprecated
package org.hibernate.transform;

View File

@ -1,59 +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.tuple;
import org.hibernate.Internal;
import org.hibernate.Remove;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.SourceType;
import org.hibernate.dialect.Dialect;
/**
* Value generation implementation for {@link CreationTimestamp}, no longer used.
*
* @author Gunnar Morling
*
* @deprecated use {@link org.hibernate.generator.internal.CurrentTimestampGeneration}
*/
@Internal
@Deprecated(since = "6.2") @Remove
public class CreationTimestampGeneration implements AnnotationValueGeneration<CreationTimestamp> {
private ValueGenerator<?> generator;
@Override
public void initialize(CreationTimestamp annotation, Class<?> propertyType) {
if ( annotation.source() == SourceType.VM ) {
generator = TimestampGenerators.get( propertyType );
}
}
@Override
public GenerationTiming getGenerationTiming() {
return GenerationTiming.INSERT;
}
@Override
public ValueGenerator<?> getValueGenerator() {
return generator;
}
@Override
public boolean referenceColumnInSql() {
return false;
}
@Override
public String getDatabaseGeneratedReferencedColumnValue() {
return "current_timestamp";
}
@Override
public String getDatabaseGeneratedReferencedColumnValue(Dialect dialect) {
return dialect.currentTimestamp();
}
}

View File

@ -1,70 +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.tuple;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.hibernate.mapping.PersistentClass;
/**
* Instantiator for entities represented as {@link Map}s.
*
* @deprecated since {@link Instantiator} is deprecated
*/
@Deprecated(since = "6.2")
public class DynamicMapInstantiator implements Instantiator {
public static final String KEY = "$type$";
private final String roleName;
private final Set<String> isInstanceEntityNames = new HashSet<>();
public DynamicMapInstantiator() {
this.roleName = null;
}
public DynamicMapInstantiator(PersistentClass mappingInfo) {
this.roleName = mappingInfo.getEntityName();
isInstanceEntityNames.add( roleName );
if ( mappingInfo.hasSubclasses() ) {
for ( PersistentClass subclassInfo : mappingInfo.getSubclassClosure() ) {
isInstanceEntityNames.add( subclassInfo.getEntityName() );
}
}
}
public final Object instantiate(Object id) {
return instantiate();
}
public final Object instantiate() {
Map map = generateMap();
if ( roleName != null ) {
map.put( KEY, roleName );
}
return map;
}
public final boolean isInstance(Object object) {
if ( object instanceof Map ) {
if ( roleName == null ) {
return true;
}
final String type = (String) ( (Map) object ).get( KEY );
return type == null || isInstanceEntityNames.contains( type );
}
else {
return false;
}
}
protected Map generateMap() {
return new HashMap();
}
}

View File

@ -1,49 +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.tuple;
import java.io.Serializable;
import org.hibernate.metamodel.spi.ManagedTypeRepresentationStrategy;
/**
* Contract for implementors responsible for instantiating entity/component instances.
*
* @deprecated This contract is no longer used by Hibernate. Implement/use
* {@link org.hibernate.metamodel.spi.Instantiator} instead. See
* {@link ManagedTypeRepresentationStrategy}
*/
@Deprecated(since = "6.0")
public interface Instantiator extends Serializable {
/**
* Perform the requested entity instantiation.
* <p>
* This form is never called for component instantiation, only entity instantiation.
*
* @param id The id of the entity to be instantiated.
* @return An appropriately instantiated entity.
*/
Object instantiate(Object id);
/**
* Perform the requested instantiation.
*
* @return The instantiated data structure.
*/
Object instantiate();
/**
* Performs check to see if the given object is an instance of the entity
* or component which this Instantiator instantiates.
*
* @param object The object to be checked.
* @return True is the object does represent an instance of the underlying
* entity/component.
*/
boolean isInstance(Object object);
}

View File

@ -1,125 +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.tuple;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import org.hibernate.InstantiationException;
import org.hibernate.PropertyNotFoundException;
import org.hibernate.bytecode.spi.ReflectionOptimizer;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.mapping.Component;
/**
* Defines a POJO-based instantiator for use from the tuplizers.
*
* @deprecated Like {@link Instantiator} itself, deprecated.
*/
@Deprecated(since = "6.0")
public class PojoInstantiator implements Instantiator, Serializable {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( PojoInstantiator.class.getName() );
private transient Constructor<?> constructor;
private final Class<?> mappedClass;
private final transient ReflectionOptimizer.InstantiationOptimizer optimizer;
private final boolean embeddedIdentifier;
private final boolean isAbstract;
/**
* @deprecated See {@link PojoInstantiator}
*/
@Deprecated(since = "6.0")
public PojoInstantiator(
Class<?> mappedClass,
ReflectionOptimizer.InstantiationOptimizer optimizer,
boolean embeddedIdentifier) {
this.mappedClass = mappedClass;
this.optimizer = optimizer;
this.embeddedIdentifier = embeddedIdentifier;
this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
try {
constructor = ReflectHelper.getDefaultConstructor(mappedClass);
}
catch ( PropertyNotFoundException pnfe ) {
LOG.noDefaultConstructor( mappedClass.getName() );
constructor = null;
}
}
/**
* @deprecated See {@link PojoInstantiator}
*/
@Deprecated(since = "6.0")
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
this( component.getComponentClass(), optimizer );
}
/**
* @deprecated See {@link PojoInstantiator}
*/
@Deprecated(since = "6.0")
public PojoInstantiator(Class<?> componentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) {
this.mappedClass = componentClass;
this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
this.optimizer = optimizer;
this.embeddedIdentifier = false;
try {
constructor = ReflectHelper.getDefaultConstructor(mappedClass);
}
catch ( PropertyNotFoundException pnfe ) {
LOG.noDefaultConstructor(mappedClass.getName());
constructor = null;
}
}
private void readObject(java.io.ObjectInputStream stream) throws ClassNotFoundException, IOException {
stream.defaultReadObject();
constructor = ReflectHelper.getDefaultConstructor( mappedClass );
}
public Object instantiate() {
if ( isAbstract ) {
throw new InstantiationException( "Cannot instantiate abstract class or interface", mappedClass );
}
else if ( optimizer != null ) {
return optimizer.newInstance();
}
else if ( constructor == null ) {
throw new InstantiationException( "No default constructor for entity", mappedClass );
}
else {
try {
return applyInterception( constructor.newInstance( (Object[]) null ) );
}
catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate entity", mappedClass, e );
}
}
}
protected Object applyInterception(Object entity) {
return entity;
}
public Object instantiate(Object id) {
final boolean useEmbeddedIdentifierInstanceAsEntity = embeddedIdentifier &&
id != null &&
id.getClass().equals(mappedClass);
return useEmbeddedIdentifierInstanceAsEntity ? id : instantiate();
}
public boolean isInstance(Object object) {
return mappedClass.isInstance( object );
}
}

View File

@ -1,123 +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.tuple;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.MonthDay;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.Year;
import java.time.YearMonth;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.hibernate.HibernateException;
/**
* Generators for obtaining the current VM timestamp in different representations.
*
* @author Gunnar Morling
*
* @deprecated This style of generation has been replaced by {@link org.hibernate.generator}
*/
@Deprecated
public final class TimestampGenerators {
private static final Map<Class<?>, ValueGenerator<?>> generators;
private TimestampGenerators() {
}
static {
generators = new HashMap<>();
generators.put(
Date.class,
(session, owner) -> new Date()
);
generators.put(
Calendar.class,
(session, owner) -> {
Calendar calendar = Calendar.getInstance();
calendar.setTime( new Date() );
return calendar;
}
);
generators.put(
java.sql.Date.class,
(session, owner) -> new java.sql.Date( System.currentTimeMillis() )
);
generators.put(
Time.class,
(session, owner) -> new Time( System.currentTimeMillis() )
);
generators.put(
Timestamp.class,
(session, owner) -> new Timestamp( System.currentTimeMillis() )
);
generators.put(
Instant.class,
(session, owner) -> Instant.now()
);
generators.put(
LocalDate.class,
(session, owner) -> LocalDate.now()
);
generators.put(
LocalDateTime.class,
(session, owner) -> LocalDateTime.now()
);
generators.put(
LocalTime.class,
(session, owner) -> LocalTime.now()
);
generators.put(
MonthDay.class,
(session, owner) -> MonthDay.now()
);
generators.put(
OffsetDateTime.class,
(session, owner) -> OffsetDateTime.now()
);
generators.put(
OffsetTime.class,
(session, owner) -> OffsetTime.now()
);
generators.put(
Year.class,
(session, owner) -> Year.now()
);
generators.put(
YearMonth.class,
(session, owner) -> YearMonth.now()
);
generators.put(
ZonedDateTime.class,
(session, owner) -> ZonedDateTime.now()
);
}
@SuppressWarnings("unchecked")
public static <T> ValueGenerator<T> get(final Class<T> type) {
final ValueGenerator<?> valueGeneratorSupplier = generators.get( type );
if ( Objects.isNull( valueGeneratorSupplier ) ) {
throw new HibernateException(
"Unsupported property type [" + type.getName() + "] for @CreationTimestamp or @UpdateTimestamp generator annotation" );
}
return (ValueGenerator<T>) valueGeneratorSupplier;
}
}

View File

@ -1,67 +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.tuple;
import org.hibernate.metamodel.spi.ManagedTypeRepresentationStrategy;
import org.hibernate.metamodel.RepresentationMode;
import org.hibernate.property.access.spi.Getter;
/**
* A tuplizer defines the contract for things which know how to manage
* a particular representation of a piece of data, given that
* representation's {@link RepresentationMode} (the entity-mode
* essentially defining which representation).
* <p>
* If that given piece of data is thought of as a data structure, then a tuplizer
* is the thing which knows how to<ul>
* <li>create such a data structure appropriately
* <li>extract values from and inject values into such a data structure
* </ul>
* <p>
* For example, a given piece of data might be represented as a POJO class.
* Here, it's representation and entity-mode is POJO. Well a tuplizer for POJO
* entity-modes would know how to<ul>
* <li>create the data structure by calling the POJO's constructor
* <li>extract and inject values through getters/setter, or by direct field access, etc
* </ul>
*
* @author Steve Ebersole
*
* @deprecated See {@link ManagedTypeRepresentationStrategy}
*/
@Deprecated
public interface Tuplizer {
/**
* Extract the value of a particular property from the given entity.
*
* @param entity The entity from which to extract the property value.
* @param i The index of the property for which to extract the value.
* @return The current value of the given property on the given entity.
*/
Object getPropertyValue(Object entity, int i);
/**
* Return the pojo class managed by this tuplizer.
* <p>
* Need to determine how to best handle this for the Tuplizers for EntityModes
* other than POJO.
* <p>
* todo : be really nice to not have this here since it is essentially pojo specific...
*
* @return The persistent class.
*/
Class<?> getMappedClass();
/**
* Retrieve the getter for the specified property.
*
* @param i The property index.
* @return The property getter.
*/
Getter getGetter(int i);
}

View File

@ -1,59 +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.tuple;
import org.hibernate.Internal;
import org.hibernate.Remove;
import org.hibernate.annotations.SourceType;
import org.hibernate.annotations.UpdateTimestamp;
import org.hibernate.dialect.Dialect;
/**
* Value generation implementation for {@link UpdateTimestamp}, no longer used.
*
* @author Gunnar Morling
*
* @deprecated use {@link org.hibernate.generator.internal.CurrentTimestampGeneration}
*/
@Internal
@Deprecated(since = "6.2") @Remove
public class UpdateTimestampGeneration implements AnnotationValueGeneration<UpdateTimestamp> {
private ValueGenerator<?> generator;
@Override
public void initialize(UpdateTimestamp annotation, Class<?> propertyType) {
if ( annotation.source() == SourceType.VM ) {
generator = TimestampGenerators.get( propertyType );
}
}
@Override
public GenerationTiming getGenerationTiming() {
return GenerationTiming.ALWAYS;
}
@Override
public ValueGenerator<?> getValueGenerator() {
return generator;
}
@Override
public boolean referenceColumnInSql() {
return false;
}
@Override
public String getDatabaseGeneratedReferencedColumnValue() {
return "current_timestamp";
}
@Override
public String getDatabaseGeneratedReferencedColumnValue(Dialect dialect) {
return dialect.currentTimestamp();
}
}

View File

@ -11,8 +11,11 @@
* <p>
* Value-generation related contracts have been replaced by
* {@link org.hibernate.generator}
*
* @deprecated The contents of this package and its subpackages
* are deprecated
*/
@Remove
@Remove @Deprecated
package org.hibernate.tuple;
import org.hibernate.Remove;

View File

@ -19,6 +19,7 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -42,13 +43,20 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
*/
@DomainModel(
annotatedClasses = {
AbstractBatchingTest.ParentEntity.class, AbstractBatchingTest.ChildEntity.class
BatchingTest.ParentEntity.class, BatchingTest.ChildEntity.class
}
)
@SessionFactory
@ServiceRegistry(
settings = {
@Setting( name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "100" ),
@Setting( name = AvailableSettings.GENERATE_STATISTICS, value = "true" ),
}
)
@BytecodeEnhanced
@CustomEnhancementContext({ NoDirtyCheckEnhancementContext.class })
public abstract class AbstractBatchingTest {
@JiraKey("HHH-14108")
public abstract class BatchingTest {
protected String childName = SafeRandomUUIDGenerator.safeRandomUUIDAsString();
protected Long parentId;

View File

@ -1,28 +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.orm.test.bytecode.enhancement.lazy.proxy.batch;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.Setting;
/**
* @author Andrea Boriero
*/
@JiraKey("HHH-14108")
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.BATCH_FETCH_STYLE, value = "DYNAMIC"),
@Setting( name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "100" ),
@Setting( name = AvailableSettings.GENERATE_STATISTICS, value = "true" ),
}
)
public class DynamicBatchingTest extends AbstractBatchingTest {
}

View File

@ -1,27 +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.orm.test.bytecode.enhancement.lazy.proxy.batch;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.Setting;
/**
* @author Andrea Boriero
*/
@JiraKey("HHH-14108")
@ServiceRegistry(
settings = {
@Setting(name = AvailableSettings.BATCH_FETCH_STYLE, value = "PADDED"),
@Setting( name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "100" ),
@Setting( name = AvailableSettings.GENERATE_STATISTICS, value = "true" ),
}
)
public class PaddedBatchingTest extends AbstractBatchingTest {
}

View File

@ -41,16 +41,6 @@ import static org.junit.Assert.assertTrue;
public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey {
private final String SANDBOX_TBL = "SANDBOX_JDBC_TST";
@Override
public int getBatchedStatementCount() {
return 1;
}
@Override
public Expectation getExpectation() {
return Expectations.BASIC;
}
@Test
public void testBatchingUsage() throws Exception {
final Session session = openSession();

View File

@ -9,8 +9,6 @@ package org.hibernate.orm.test.mapping.inheritance.dynamic;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.tuple.DynamicMapInstantiator;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -19,6 +17,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.metamodel.internal.AbstractDynamicMapInstantiator.TYPE_KEY;
/**
* @author Steve Ebersole
@ -31,8 +30,8 @@ public class DynamicJoinedInheritanceTests {
scope.inTransaction( (session) -> {
final Map<String,?> entity = (Map<String, ?>) session.get( "Sub", 1 );
assertThat( entity ).isNotNull();
assertThat( entity.get( DynamicMapInstantiator.KEY ) ).isNotNull();
assertThat( entity.get( DynamicMapInstantiator.KEY ) ).isEqualTo( "Sub" );
assertThat( entity.get( TYPE_KEY ) ).isNotNull();
assertThat( entity.get( TYPE_KEY ) ).isEqualTo( "Sub" );
} );
}

View File

@ -51,7 +51,6 @@ import static org.assertj.core.api.Assertions.assertThat;
)
@ServiceRegistry(
settings = {
@Setting( name = AvailableSettings.BATCH_FETCH_STYLE, value = "PADDED" ),
@Setting( name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "10" ),
}
)

View File

@ -17,6 +17,7 @@ import jakarta.persistence.criteria.Selection;
import org.hibernate.CacheMode;
import org.hibernate.Hibernate;
import org.hibernate.PropertyNotFoundException;
import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -30,8 +31,10 @@ import org.hibernate.transform.AliasToBeanConstructorResultTransformer;
import org.hibernate.transform.AliasToEntityMapResultTransformer;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.transform.Transformers;
import org.hibernate.type.BasicType;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.LongJavaType;
import org.hibernate.type.descriptor.java.spi.PrimitiveJavaType;
import org.hibernate.type.descriptor.jdbc.BigIntJdbcType;
import org.hibernate.type.internal.BasicTypeImpl;
@ -42,6 +45,7 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.hibernate.internal.util.ReflectHelper.ensureAccessibility;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@ -3074,7 +3078,7 @@ public abstract class AbstractQueryCacheResultTransformerTest {
scope.getSessionFactory().getMappingMetamodel()
.getEntityDescriptor( Student.class.getName() )
.getPropertyType( "name" );
return ReflectHelper.getConstructor(
return findConstructor(
Student.class,
new Type[] {
new BasicTypeImpl<>(
@ -3403,4 +3407,49 @@ public abstract class AbstractQueryCacheResultTransformerTest {
int deletes = (int) sessionFactory.getStatistics().getEntityDeleteCount();
assertEquals( expected, deletes, "unexpected delete counts" );
}
}
/**
* Retrieve a constructor for the given class, with arguments matching
* the specified Hibernate mapping {@linkplain Type types}.
*
* @param clazz The class needing instantiation
* @param types The types representing the required ctor param signature
* @return The matching constructor
* @throws PropertyNotFoundException Indicates we could not locate an appropriate constructor
*
* @deprecated no longer used, since we moved away from the {@link Type} interface
*/
// todo : again with PropertyNotFoundException???
@Deprecated(since = "6", forRemoval = true)
public static Constructor<?> findConstructor(Class<?> clazz, Type[] types) throws PropertyNotFoundException {
final Constructor<?>[] candidates = clazz.getConstructors();
Constructor<?> constructor = null;
int numberOfMatchingConstructors = 0;
for ( final Constructor<?> candidate : candidates ) {
final Class<?>[] params = candidate.getParameterTypes();
if ( params.length == types.length ) {
boolean found = true;
for ( int j = 0; j < params.length; j++ ) {
final boolean ok = types[j] == null || params[j].isAssignableFrom( types[j].getReturnedClass() ) || (
types[j] instanceof BasicType<?> && ( (BasicType<?>) types[j] ).getJavaTypeDescriptor() instanceof PrimitiveJavaType
&& params[j] == ( (PrimitiveJavaType<?>) ( ( (BasicType<?>) types[j] ).getJavaTypeDescriptor() ) ).getPrimitiveClass()
);
if ( !ok ) {
found = false;
break;
}
}
if ( found ) {
numberOfMatchingConstructors ++;
ensureAccessibility( candidate );
constructor = candidate;
}
}
}
if ( numberOfMatchingConstructors == 1 ) {
return constructor;
}
throw new PropertyNotFoundException( "no appropriate constructor in class: " + clazz.getName() );
}}

View File

@ -48,7 +48,6 @@ import org.hibernate.internal.FastSessionServices;
import org.hibernate.jpa.internal.MutableJpaComplianceImpl;
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.jpa.spi.MutableJpaCompliance;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.mapping.Property;
import org.hibernate.metamodel.AttributeClassification;
import org.hibernate.metamodel.CollectionClassification;
@ -563,11 +562,6 @@ public abstract class MockSessionFactory
return NO_RESOLVERS;
}
@Override
public BatchFetchStyle getBatchFetchStyle() {
return BatchFetchStyle.LEGACY;
}
@Override
public boolean isDelayBatchFetchLoaderCreationsEnabled() {
return false;