Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.metamodel.mapping.EntityMappingType;
Expand Down Expand Up @@ -79,7 +78,6 @@
import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.logging.Logger;

import java.lang.invoke.MethodHandles;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Types;
Expand All @@ -100,11 +98,7 @@
*/
public class HSQLLegacyDialect extends Dialect {

private static final CoreMessageLogger LOG = Logger.getMessageLogger(
MethodHandles.lookup(),
CoreMessageLogger.class,
org.hibernate.community.dialect.HSQLLegacyDialect.class.getName()
);
private static final Logger LOG = Logger.getLogger( HSQLLegacyDialect.class );

private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate( this );
private final HSQLIdentityColumnSupport identityColumnSupport;
Expand Down Expand Up @@ -762,7 +756,7 @@ private ReadUncommittedLockingStrategy(EntityPersister lockable, LockMode lockMo
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session)
throws StaleObjectStateException, JDBCException {
if ( getLockMode().greaterThan( LockMode.READ ) ) {
LOG.hsqldbSupportsOnlyReadCommittedIsolation();
LOG.warn( "HSQLDB supports only READ_UNCOMMITTED isolation" );
}
super.lock( id, version, object, timeout, session );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import java.util.Locale;

import static org.hibernate.cfg.SchemaToolingSettings.HBM2DDL_AUTO;

/**
* Defines the possible values for {@value AvailableSettings#HBM2DDL_AUTO}.
*
Expand Down Expand Up @@ -65,15 +67,13 @@ public static SchemaAutoTooling interpret(String configurationValue) {
return null;
}
else {
for ( SchemaAutoTooling value : values() ) {
for ( var value : values() ) {
if ( value.externalForm().equals( configurationValue ) ) {
return value;
}
}
throw new HibernateException(
"Unrecognized " + AvailableSettings.HBM2DDL_AUTO + " value: '" + configurationValue
+ "'. Supported values include 'create', 'create-drop', 'create-only', 'drop', 'update', 'none' and 'validate'."
);
throw new HibernateException( "Unrecognized " + HBM2DDL_AUTO + " value: '" + configurationValue
+ "' (supported values include 'create', 'create-drop', 'create-only', 'drop', 'update', 'none', and 'validate')" );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.hibernate.result.internal.OutputsImpl;
import org.jboss.logging.Logger;

import static org.hibernate.engine.internal.CacheHelper.fromSharedCache;
import static org.hibernate.internal.CoreMessageLogger.LOGGER;
import static org.hibernate.internal.util.collections.CollectionHelper.linkedMapOfSize;
import static org.hibernate.internal.util.collections.CollectionHelper.linkedSetOfSize;
import static org.hibernate.internal.util.collections.CollectionHelper.mapOfSize;
Expand All @@ -37,6 +38,8 @@
*/
public class BatchFetchQueue {

private static final Logger LOG = Logger.getLogger( OutputsImpl.class );

private final PersistenceContext context;

/**
Expand Down Expand Up @@ -106,8 +109,8 @@ public void addSubselect(EntityKey key, SubselectFetch subquery) {
}

final var previous = subselectsByEntityKey.put( key, subquery );
if ( previous != null && LOGGER.isDebugEnabled() ) {
LOGGER.tracef(
if ( previous != null && LOG.isDebugEnabled() ) {
LOG.tracef(
"SubselectFetch previously registered with BatchFetchQueue for '%s.s'",
key.getEntityName(),
key.getIdentifier()
Expand All @@ -129,6 +132,10 @@ public void removeSubselect(EntityKey key) {

// entity batch support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

private LoadQueryInfluencers getLoadQueryInfluencers() {
return context.getSession().getLoadQueryInfluencers();
}

/**
* If an EntityKey represents a batch loadable entity, add
* it to the queue.
Expand All @@ -140,7 +147,7 @@ public void removeSubselect(EntityKey key) {
* already associated with the {@link PersistenceContext}.
*/
public void addBatchLoadableEntityKey(EntityKey key) {
if ( key.isBatchLoadable( context.getSession().getLoadQueryInfluencers() ) ) {
if ( key.isBatchLoadable( getLoadQueryInfluencers() ) ) {
if ( batchLoadableEntityKeys == null ) {
batchLoadableEntityKeys = mapOfSize( 12 );
}
Expand All @@ -156,7 +163,7 @@ public void addBatchLoadableEntityKey(EntityKey key) {
* if necessary
*/
public void removeBatchLoadableEntityKey(EntityKey key) {
if ( key.isBatchLoadable( context.getSession().getLoadQueryInfluencers() )
if ( key.isBatchLoadable( getLoadQueryInfluencers() )
&& batchLoadableEntityKeys != null ) {
final var entityKeys = batchLoadableEntityKeys.get( key.getEntityName() );
if ( entityKeys != null ) {
Expand All @@ -169,7 +176,7 @@ public void removeBatchLoadableEntityKey(EntityKey key) {
* Intended for test usage. Really has no use-case in Hibernate proper.
*/
public boolean containsEntityKey(EntityKey key) {
if ( key.isBatchLoadable( context.getSession().getLoadQueryInfluencers() )
if ( key.isBatchLoadable( getLoadQueryInfluencers() )
&& batchLoadableEntityKeys != null ) {
final var entityKeys = batchLoadableEntityKeys.get( key.getEntityName() );
if ( entityKeys != null ) {
Expand All @@ -196,22 +203,25 @@ public <T> void collectBatchLoadableEntityIds(
if ( batchLoadableEntityKeys != null ) {
final var entityKeys = batchLoadableEntityKeys.get( entityDescriptor.getEntityName() );
if ( entityKeys != null ) {
final var session = context.getSession();
final var identifierMapping = entityDescriptor.getIdentifierMapping();
int batchPosition = 1;
int end = -1;
boolean checkForEnd = false;
for ( var entityKey : entityKeys ) {
if ( checkForEnd && batchPosition == end ) {
// the first id found after the given id
return;
}
else if ( identifierMapping.areEqual( loadingId, entityKey.getIdentifier(),
context.getSession() ) ) {
end = batchPosition;
return; // end the loop
}
else if ( !isCached( entityKey, entityDescriptor.getEntityPersister() ) ) {
//noinspection unchecked
collector.accept( batchPosition++, (T) entityKey.getIdentifier() );
else {
final Object identifier = entityKey.getIdentifier();
if ( identifierMapping.areEqual( loadingId, identifier, session ) ) {
end = batchPosition;
}
else if ( !isCached( entityKey, entityDescriptor.getEntityPersister() ) ) {
//noinspection unchecked
collector.accept( batchPosition++, (T) identifier );
}
}

if ( batchPosition == domainBatchSize ) {
Expand Down Expand Up @@ -296,13 +306,13 @@ public void addBatchLoadableCollection(PersistentCollection<?> collection, Colle
* need to batch fetch it anymore, remove it from the queue
* if necessary
*/
public void removeBatchLoadableCollection(CollectionEntry ce) {
final var persister = ce.getLoadedPersister();
public void removeBatchLoadableCollection(CollectionEntry collectionEntry) {
final var persister = collectionEntry.getLoadedPersister();
assert persister != null : "@AssumeAssertion(nullness)";
if ( batchLoadableCollections != null ) {
final var map = batchLoadableCollections.get( persister.getRole() );
if ( map != null ) {
map.remove( ce );
map.remove( collectionEntry );
}
}
}
Expand All @@ -328,9 +338,9 @@ public <T> void collectBatchLoadableCollectionKeys(
int end = -1;
boolean checkForEnd = false;
for ( var me : map.entrySet() ) {
final CollectionEntry ce = me.getKey();
final var ce = me.getKey();
final Object loadedKey = ce.getLoadedKey();
final PersistentCollection<?> collection = me.getValue();
final var collection = me.getValue();

// the loadedKey of the collectionEntry might be null as it might have been reset to null
// (see for example Collections.processDereferencedCollection()
Expand Down Expand Up @@ -397,9 +407,9 @@ else if ( !isCached( loadedKey, pluralAttributeMapping.getCollectionDescriptor()
final var map = batchLoadableCollections.get( collectionPersister.getRole() );
if ( map != null ) {
for ( var me : map.entrySet() ) {
final CollectionEntry ce = me.getKey();
final Object loadedKey = ce.getLoadedKey();
final PersistentCollection<?> collection = me.getValue();
final var collectionEntry = me.getKey();
final Object loadedKey = collectionEntry.getLoadedKey();
final var collection = me.getValue();

// the loadedKey of the collectionEntry might be null as it might have been reset to null
// (see for example Collections.processDereferencedCollection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public interface SequenceGeneratorLogger extends BasicLogger {
String NAME = SubSystemLogging.BASE + ".id.table";

SequenceGeneratorLogger SEQUENCE_GENERATOR_MESSAGE_LOGGER = Logger.getMessageLogger(
SequenceGeneratorLogger SEQUENCE_GENERATOR_LOGGER = Logger.getMessageLogger(
MethodHandles.lookup(),
SequenceGeneratorLogger.class,
NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import static org.hibernate.cfg.MappingSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY;
import static org.hibernate.id.IdentifierGeneratorHelper.getNamingStrategy;
import static org.hibernate.id.enhanced.OptimizerFactory.determineImplicitOptimizerName;
import static org.hibernate.id.enhanced.SequenceGeneratorLogger.SEQUENCE_GENERATOR_MESSAGE_LOGGER;
import static org.hibernate.id.enhanced.SequenceGeneratorLogger.SEQUENCE_GENERATOR_LOGGER;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.config.ConfigurationHelper.getBoolean;
import static org.hibernate.internal.util.config.ConfigurationHelper.getInt;
Expand Down Expand Up @@ -214,7 +214,7 @@ public void configure(GeneratorCreationContext creationContext, Properties param
&& optimizationStrategy.isPooled()
&& !dialect.getSequenceSupport().supportsPooledSequences() ) {
forceTableUse = true;
SEQUENCE_GENERATOR_MESSAGE_LOGGER.forcingTableUse();
SEQUENCE_GENERATOR_LOGGER.forcingTableUse();
}

this.databaseStructure = buildDatabaseStructure(
Expand Down Expand Up @@ -292,13 +292,13 @@ private int validatedIncrementSize(
case NONE -> incrementSize;
case FIX -> {
// log at TRACE level
SEQUENCE_GENERATOR_MESSAGE_LOGGER.sequenceIncrementSizeMismatchFixed(
SEQUENCE_GENERATOR_LOGGER.sequenceIncrementSizeMismatchFixed(
databaseSequenceName, incrementSize, dbIncrementValue );
yield dbIncrementValue;
}
case LOG -> {
// log at WARN level
SEQUENCE_GENERATOR_MESSAGE_LOGGER.sequenceIncrementSizeMismatch(
SEQUENCE_GENERATOR_LOGGER.sequenceIncrementSizeMismatch(
databaseSequenceName, incrementSize, dbIncrementValue );
yield incrementSize;
}
Expand Down Expand Up @@ -448,7 +448,7 @@ protected OptimizerDescriptor determineOptimizationStrategy(Properties params, i
protected int determineAdjustedIncrementSize(OptimizerDescriptor optimizationStrategy, int incrementSize) {
if ( optimizationStrategy == StandardOptimizerDescriptor.NONE ) {
if ( incrementSize < -1 ) {
SEQUENCE_GENERATOR_MESSAGE_LOGGER.honoringOptimizerSetting(
SEQUENCE_GENERATOR_LOGGER.honoringOptimizerSetting(
StandardOptimizerDescriptor.NONE.getExternalName(),
INCREMENT_PARAM,
incrementSize,
Expand All @@ -458,7 +458,7 @@ protected int determineAdjustedIncrementSize(OptimizerDescriptor optimizationStr
return -1;
}
else if ( incrementSize > 1 ) {
SEQUENCE_GENERATOR_MESSAGE_LOGGER.honoringOptimizerSetting(
SEQUENCE_GENERATOR_LOGGER.honoringOptimizerSetting(
StandardOptimizerDescriptor.NONE.getExternalName(),
INCREMENT_PARAM,
incrementSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import static org.hibernate.boot.model.internal.GeneratorBinder.applyIfNotEmpty;
import static org.hibernate.cfg.MappingSettings.TABLE_GENERATOR_STORE_LAST_USED;
import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN;
import static org.hibernate.id.enhanced.TableGeneratorLogger.TABLE_GENERATOR_MESSAGE_LOGGER;
import static org.hibernate.id.enhanced.TableGeneratorLogger.TABLE_GENERATOR_LOGGER;
import static org.hibernate.id.IdentifierGeneratorHelper.getNamingStrategy;
import static org.hibernate.id.enhanced.OptimizerFactory.determineImplicitOptimizerName;
import static org.hibernate.internal.util.StringHelper.isEmpty;
Expand Down Expand Up @@ -454,7 +454,7 @@ protected String determineSegmentValue(Properties params) {
protected String determineDefaultSegmentValue(Properties params) {
final boolean preferSegmentPerEntity = getBoolean( CONFIG_PREFER_SEGMENT_PER_ENTITY, params );
final String defaultToUse = preferSegmentPerEntity ? params.getProperty( TABLE ) : DEF_SEGMENT_VALUE;
TABLE_GENERATOR_MESSAGE_LOGGER.usingDefaultIdGeneratorSegmentValue(
TABLE_GENERATOR_LOGGER.usingDefaultIdGeneratorSegmentValue(
qualifiedTableName.render(), segmentColumnName, defaultToUse );
return defaultToUse;
}
Expand Down Expand Up @@ -549,15 +549,15 @@ private IntegralDataTypeHolder nextValue(
final IntegralDataTypeHolder value = makeValue();
int rows;
do {
TABLE_GENERATOR_MESSAGE_LOGGER.retrievingCurrentValueForSegment( segmentValue );
TABLE_GENERATOR_LOGGER.retrievingCurrentValueForSegment( segmentValue );
try ( var prepareStatement = prepareStatement( connection, selectQuery, logger, listener, session ) ) {
prepareStatement.setString( 1, segmentValue );
final var resultSet = executeQuery( prepareStatement, listener, selectQuery, session );
if ( !resultSet.next() ) {
final long initializationValue = storeLastUsedValue ? initialValue - 1 : initialValue;
value.initialize( initializationValue );

TABLE_GENERATOR_MESSAGE_LOGGER.insertingInitialValueForSegment( value, segmentValue );
TABLE_GENERATOR_LOGGER.insertingInitialValueForSegment( value, segmentValue );
try ( PreparedStatement statement = prepareStatement( connection, insertQuery, logger, listener, session ) ) {
statement.setString( 1, segmentValue );
value.bind( statement, 2 );
Expand All @@ -577,7 +577,7 @@ private IntegralDataTypeHolder nextValue(
resultSet.close();
}
catch (SQLException e) {
TABLE_GENERATOR_MESSAGE_LOGGER.unableToReadOrInitializeHiValue( physicalTableName.render(), e );
TABLE_GENERATOR_LOGGER.unableToReadOrInitializeHiValue( physicalTableName.render(), e );
throw e;
}

Expand All @@ -588,15 +588,15 @@ private IntegralDataTypeHolder nextValue(
else {
updateValue.increment();
}
TABLE_GENERATOR_MESSAGE_LOGGER.updatingCurrentValueForSegment( updateValue, segmentValue );
TABLE_GENERATOR_LOGGER.updatingCurrentValueForSegment( updateValue, segmentValue );
try ( var statement = prepareStatement( connection, updateQuery, logger, listener, session ) ) {
updateValue.bind( statement, 1 );
value.bind( statement, 2 );
statement.setString( 3, segmentValue );
rows = executeUpdate( statement, listener, updateQuery, session );
}
catch (SQLException e) {
TABLE_GENERATOR_MESSAGE_LOGGER.unableToUpdateHiValue( physicalTableName.render(), e );
TABLE_GENERATOR_LOGGER.unableToUpdateHiValue( physicalTableName.render(), e );
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public interface TableGeneratorLogger extends BasicLogger {
String NAME = SubSystemLogging.BASE + ".id.table";

TableGeneratorLogger TABLE_GENERATOR_MESSAGE_LOGGER = Logger.getMessageLogger(
TableGeneratorLogger TABLE_GENERATOR_LOGGER = Logger.getMessageLogger(
MethodHandles.lookup(),
TableGeneratorLogger.class,
NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

import static org.hibernate.LockMode.PESSIMISTIC_WRITE;
import static org.hibernate.id.IdentifierGeneratorHelper.getIntegralDataTypeHolder;
import static org.hibernate.id.enhanced.TableGeneratorLogger.TABLE_GENERATOR_MESSAGE_LOGGER;
import static org.hibernate.id.enhanced.TableGeneratorLogger.TABLE_GENERATOR_LOGGER;

/**
* Describes a table used to mimic sequence behavior
Expand Down Expand Up @@ -185,7 +185,7 @@ public IntegralDataTypeHolder execute(Connection connection) throws SQLException
selectRS.close();
}
catch (SQLException sqle) {
TABLE_GENERATOR_MESSAGE_LOGGER.unableToReadHiValue( physicalTableName.render(), sqle );
TABLE_GENERATOR_LOGGER.unableToReadHiValue( physicalTableName.render(), sqle );
throw sqle;
}

Expand All @@ -204,7 +204,7 @@ public IntegralDataTypeHolder execute(Connection connection) throws SQLException
rows = executeUpdate( updatePS, statsCollector, updateQuery, session );
}
catch (SQLException e) {
TABLE_GENERATOR_MESSAGE_LOGGER.unableToUpdateHiValue( physicalTableName.render(), e );
TABLE_GENERATOR_LOGGER.unableToUpdateHiValue( physicalTableName.render(), e );
throw e;
}
} while ( rows == 0 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public interface CoreMessageLogger extends BasicLogger {

String NAME = SubSystemLogging.BASE + ".core";

Logger LOGGER = Logger.getLogger( NAME );
CoreMessageLogger CORE_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), CoreMessageLogger.class, NAME );

@LogMessage(level = INFO)
Expand Down Expand Up @@ -90,10 +89,6 @@ void expectedType(String name,
+ " to unsafe use of the session): %s", id = 99)
void failed(Throwable throwable);

@LogMessage(level = WARN)
@Message(value = "HSQLDB supports only READ_UNCOMMITTED isolation", id = 118)
void hsqldbSupportsOnlyReadCommittedIsolation();

@LogMessage(level = ERROR)
@Message(value = "IllegalArgumentException in class: %s, getter method of property: %s", id = 122)
void illegalPropertyGetterArgument(String name, String propertyName);
Expand Down
Loading