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 @@ -99,11 +99,11 @@ private void applyLocalConvert(
Map<String,AttributeConversionInfo> elementAttributeConversionInfoMap,
Map<String,AttributeConversionInfo> keyAttributeConversionInfoMap) {

// IMPL NOTE : the rules here are quite more lenient than what JPA says. For example, JPA says that @Convert
// on a Map of basic types should default to "value" but it should explicitly specify attributeName of "key"
// IMPL NOTE: the rules here are quite more lenient than what JPA says. For example, JPA says that @Convert
// on a Map of basic types should default to "value" but it should explicitly specify 'attributeName' of "key"
// (or prefixed with "key." for embedded paths) to be applied on the key. However, we try to see if conversion
// of either is disabled for whatever reason. For example, if the Map is annotated with @Enumerated the
// elements cannot be converted so any @Convert likely meant the key, so we apply it to the key
// of either is disabled for whatever reason. For example, if the Map is annotated with @Enumerated, the
// elements cannot be converted, and so any @Convert likely meant the key, so we apply it to the key

final var info = new AttributeConversionInfo( convertAnnotation, collectionProperty );
final String attributeName = info.getAttributeName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;
import java.util.Objects;

import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.TransactionSettings;
import org.hibernate.engine.transaction.jta.platform.internal.AtomikosJtaPlatform;
import org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform;
import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform;
Expand All @@ -18,7 +18,8 @@
import org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform;
import org.hibernate.engine.transaction.jta.platform.internal.WildFlyStandAloneJtaPlatform;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.internal.log.DeprecationLogger;

import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;

public class DefaultJtaPlatformSelector implements LazyServiceResolver<JtaPlatform> {

Expand All @@ -35,8 +36,9 @@ else if ( name.startsWith( "org." ) ) {
return switch ( name ) {
case "JBossAS" -> JBossAppServerJtaPlatform.class;
case "JBossTS" -> {
DeprecationLogger.DEPRECATION_LOGGER.logDeprecatedJtaPlatformSetting(
AvailableSettings.JTA_PLATFORM, name, List.of( "Narayana", "WildFlyStandadlone" ) );
DEPRECATION_LOGGER.deprecatedJtaPlatformSetting(
TransactionSettings.JTA_PLATFORM, name,
List.of( "Narayana", "WildFlyStandadlone" ) );
yield JBossStandAloneJtaPlatform.class;
}
case "Weblogic" -> WeblogicJtaPlatform.class;
Expand Down Expand Up @@ -66,8 +68,9 @@ private static Class<? extends JtaPlatform> legacy(
return JBossAppServerJtaPlatform.class;
}
case "org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform" -> {
DeprecationLogger.DEPRECATION_LOGGER.logDeprecatedJtaPlatformSetting(
AvailableSettings.JTA_PLATFORM, name, List.of( "Narayana", "WildFlyStandadlone" ) );
DEPRECATION_LOGGER.deprecatedJtaPlatformSetting(
TransactionSettings.JTA_PLATFORM, name,
List.of( "Narayana", "WildFlyStandadlone" ) );
return JBossStandAloneJtaPlatform.class;
}
case "org.hibernate.engine.transaction.jta.platform.internal.NarayanaJtaPlatform" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.spi.ServiceRegistryImplementor;

import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
import static org.hibernate.cfg.CacheSettings.CACHE_REGION_FACTORY;
import static org.hibernate.cfg.CacheSettings.USE_QUERY_CACHE;
import static org.hibernate.cfg.CacheSettings.USE_SECOND_LEVEL_CACHE;
Expand All @@ -30,8 +29,6 @@
*/
public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFactory> {

private static final CoreMessageLogger LOG = CoreLogging.messageLogger( RegionFactoryInitiator.class );

/**
* Singleton access
*/
Expand All @@ -46,10 +43,10 @@ public Class<RegionFactory> getServiceInitiated() {
public RegionFactory initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final var regionFactory = resolveRegionFactory( configurationValues, registry );
if ( regionFactory instanceof NoCachingRegionFactory ) {
LOG.noRegionFactory();
L2CACHE_LOGGER.noRegionFactory();
}
else {
LOG.regionFactory( regionFactory.getClass().getTypeName() );
L2CACHE_LOGGER.regionFactory( regionFactory.getClass().getTypeName() );
}
return regionFactory;
}
Expand All @@ -74,7 +71,7 @@ protected RegionFactory resolveRegionFactory(Map<String,Object> configurationVal
// 1) both are explicitly FALSE
// 2) USE_SECOND_LEVEL_CACHE is FALSE and USE_QUERY_CACHE is null
if ( useSecondLevelCache == FALSE ) {
if ( useQueryCache == null || useQueryCache == FALSE ) {
if ( useQueryCache == null || !useQueryCache ) {
return NoCachingRegionFactory.INSTANCE;
}
}
Expand Down Expand Up @@ -102,7 +99,6 @@ protected RegionFactory resolveRegionFactory(Map<String,Object> configurationVal
return regionFactory;
}


final var fallback = getFallback( configurationValues, registry );
if ( fallback != null ) {
return fallback;
Expand All @@ -115,10 +111,7 @@ protected RegionFactory resolveRegionFactory(Map<String,Object> configurationVal
return registeredFactory;
}
else {
LOG.debugf(
"Cannot default RegionFactory based on registered strategies as `%s` RegionFactory strategies were registered",
implementors
);
L2CACHE_LOGGER.cannotDefaultRegionFactory( implementors.size() );
}

return NoCachingRegionFactory.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.lang.invoke.MethodHandles;

import static org.jboss.logging.Logger.Level.DEBUG;
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.TRACE;
import static org.jboss.logging.Logger.Level.WARN;
Expand Down Expand Up @@ -221,4 +222,25 @@ public interface SecondLevelCacheLogger extends BasicLogger {
id = NAMESPACE + 24
)
void lastUpdateTimestampForSpace(String space, Long lastUpdate, Long timestamp);

@LogMessage(level = INFO)
@Message(
value = "Second-level cache region factory [%s]",
id = NAMESPACE + 28
)
void regionFactory(String name);

@LogMessage(level = DEBUG)
@Message(
value = "Second-level cache disabled",
id = NAMESPACE + 29
)
void noRegionFactory();

@LogMessage(level = INFO)
@Message(
value = "Cannot default RegionFactory based on registered strategies as %s RegionFactory strategies were registered",
id = NAMESPACE + 30
)
void cannotDefaultRegionFactory(int size);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
import org.jboss.logging.annotations.ValidIdRange;

import java.lang.invoke.MethodHandles;
import java.sql.SQLException;

import static org.jboss.logging.Logger.Level.DEBUG;
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.TRACE;
import static org.jboss.logging.Logger.Level.WARN;

/**
* Sub-system logging related to JDBC interactions
* Subsystem logging related to JDBC interactions
*
* @author Steve Ebersole
*/
Expand All @@ -38,7 +39,6 @@
public interface JdbcLogging extends BasicLogger {
String NAME = SubSystemLogging.BASE + ".jdbc";

Logger JDBC_LOGGER = Logger.getLogger( NAME );
JdbcLogging JDBC_MESSAGE_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), JdbcLogging.class, NAME );

@LogMessage(level = WARN)
Expand Down Expand Up @@ -176,4 +176,17 @@ public interface JdbcLogging extends BasicLogger {
@LogMessage(level = DEBUG)
@Message(value = "Encountered failure rolling back failed commit", id = 100038)
void encounteredFailureRollingBackFailedCommit(@Cause Throwable cause);

@LogMessage(level = DEBUG)
@Message(value = "Could not access DatabaseMetaData while building the JdbcEnvironment", id = 100039)
void noDatabaseMetaData(@Cause SQLException sqle);

@LogMessage(level = WARN)
@Message(value = "Could not obtain connection metadata: %s", id = 100045)
void unableToObtainConnectionMetadata(SQLException error);

@LogMessage(level = WARN)
@Message(value = "Could not obtain connection to query JDBC database metadata", id = 100046)
void unableToObtainConnectionToQueryMetadata(@Cause Exception e);

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.jboss.logging.Logger.Level.WARN;

/**
* Sub-system logging related to JDBC batch execution
* Subsystem logging related to JDBC batch execution
*
* @author Steve Ebersole
*/
Expand All @@ -35,38 +35,50 @@
public interface JdbcBatchLogging extends BasicLogger {
String NAME = "org.hibernate.orm.jdbc.batch";

Logger BATCH_LOGGER = Logger.getLogger( NAME );
JdbcBatchLogging BATCH_MESSAGE_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), JdbcBatchLogging.class, NAME );

@LogMessage(level = INFO)
@Message(id=100501, value = "Automatic JDBC statement batching enabled (maximum batch size %s)")
void batchingEnabled(int batchSize);

@LogMessage(level = WARN)
@Message(id = 100502, value = "Unable to release batch statement")
@Message(id = 100502, value = "Unable to release JDBC batch statement")
void unableToReleaseBatchStatement();

@LogMessage(level = INFO)
@Message(id=100503, value = "On release of batch it still contained JDBC statements")
@Message(id=100503, value = "JDBC batch still contained JDBC statements on release")
void batchContainedStatementsOnRelease();

@LogMessage(level = TRACE)
@Message("Created JDBC batch (%s) - [%s]")
void createBatch(int batchSize, String string);
void createBatch(int batchSize, String batchKey);

@LogMessage(level = TRACE)
@Message("Adding to JDBC batch (%s / %s) - [%s]")
void addToBatch(int batchPosition, int batchSize, String string);
void addToBatch(int batchPosition, int batchSize, String batchKey);

@LogMessage(level = TRACE)
@Message("Executing JDBC batch (%s / %s) - [%s]")
void executeBatch(int batchPosition, int batchSize, String string);
void executeBatch(int batchPosition, int batchSize, String batchKey);

@LogMessage(level = TRACE)
@Message("Conditionally executing JDBC batch - [%s]")
void conditionallyExecuteBatch(String string);
void conditionallyExecuteBatch(String batchKey);

@LogMessage(level = TRACE)
@Message("Aborting JDBC batch - [%s]")
void abortBatch(String string);
void abortBatch(String batchKey);

@LogMessage(level = TRACE)
@Message("Using standard JDBC batch builder")
void usingStandardBatchBuilder();

@LogMessage(level = TRACE)
@Message("No statements to execute in JDBC batch - [%s]")
void emptyBatch(String batchKey);

// this might actually belong in JdbcLogging
@LogMessage(level = TRACE)
@Message("PreparedStatementDetails did not contain PreparedStatement on releaseStatements: %s")
void noPreparedStatements(String sqlString);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.hibernate.sql.model.jdbc.JdbcInsertMutation;

import static java.util.Collections.emptyList;
import static org.hibernate.engine.jdbc.batch.JdbcBatchLogging.BATCH_LOGGER;
import static org.hibernate.engine.jdbc.batch.JdbcBatchLogging.BATCH_MESSAGE_LOGGER;

/**
Expand All @@ -40,7 +39,7 @@ public BatchBuilderImpl(int globalBatchSize) {
if ( globalBatchSize > 1 ) {
BATCH_MESSAGE_LOGGER.batchingEnabled( globalBatchSize );
}
BATCH_LOGGER.trace( "Using standard BatchBuilder");
BATCH_MESSAGE_LOGGER.usingStandardBatchBuilder();
this.globalBatchSize = globalBatchSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import static java.util.Objects.requireNonNull;
import static org.hibernate.engine.jdbc.JdbcLogging.JDBC_MESSAGE_LOGGER;
import static org.hibernate.engine.jdbc.batch.JdbcBatchLogging.BATCH_LOGGER;
import static org.hibernate.engine.jdbc.batch.JdbcBatchLogging.BATCH_MESSAGE_LOGGER;
import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER;

Expand Down Expand Up @@ -64,7 +63,7 @@ public BatchImpl(
sqlStatementLogger = jdbcServices.getSqlStatementLogger();
sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();

if ( BATCH_LOGGER.isTraceEnabled() ) {
if ( BATCH_MESSAGE_LOGGER.isTraceEnabled() ) {
BATCH_MESSAGE_LOGGER.createBatch(
batchSizeToUse,
key.toLoggableString()
Expand Down Expand Up @@ -102,7 +101,7 @@ public void addToBatch(

@Override
public void addToBatch(JdbcValueBindings jdbcValueBindings, TableInclusionChecker inclusionChecker) {
final boolean loggerTraceEnabled = BATCH_LOGGER.isTraceEnabled();
final boolean loggerTraceEnabled = BATCH_MESSAGE_LOGGER.isTraceEnabled();
if ( loggerTraceEnabled ) {
BATCH_MESSAGE_LOGGER.addToBatch(
batchPosition + 1,
Expand Down Expand Up @@ -132,10 +131,9 @@ public void addToBatch(JdbcValueBindings jdbcValueBindings, TableInclusionChecke
try {
statement.addBatch();
}
catch (SQLException e) {
BATCH_LOGGER.debug( "SQLException escaped proxy", e );
catch (SQLException exception) {
throw sqlExceptionHelper.convert(
e,
exception,
"Could not perform addBatch",
sqlString
);
Expand Down Expand Up @@ -212,14 +210,11 @@ protected void abortBatch(Exception cause) {
@Override
public void execute() {
notifyObserversExplicitExecution();
if ( getStatementGroup().getNumberOfStatements() != 0 ) {
if ( getStatementGroup().getNumberOfStatements() > 0 ) {
try {
if ( batchPosition == 0 ) {
if ( !batchExecuted && BATCH_LOGGER.isDebugEnabled() ) {
BATCH_LOGGER.debugf(
"No batched statements to execute - %s",
getKey().toLoggableString()
);
if ( !batchExecuted && BATCH_MESSAGE_LOGGER.isTraceEnabled() ) {
BATCH_MESSAGE_LOGGER.emptyBatch( getKey().toLoggableString() );
}
}
else {
Expand All @@ -233,7 +228,7 @@ public void execute() {
}

protected void performExecution() {
if ( BATCH_LOGGER.isTraceEnabled() ) {
if ( BATCH_MESSAGE_LOGGER.isTraceEnabled() ) {
BATCH_MESSAGE_LOGGER.executeBatch(
batchPosition,
batchSizeToUse,
Expand Down Expand Up @@ -314,7 +309,7 @@ private void checkRowCounts(int[] rowCounts, PreparedStatementDetails statementD
public void release() {
if ( BATCH_MESSAGE_LOGGER.isInfoEnabled() ) {
final var statementGroup = getStatementGroup();
if ( statementGroup.getNumberOfStatements() != 0
if ( statementGroup.getNumberOfStatements() > 0
&& statementGroup.hasMatching( statementDetails -> statementDetails.getStatement() != null ) ) {
BATCH_MESSAGE_LOGGER.batchContainedStatementsOnRelease();
}
Expand Down
Loading
Loading