Log usage of deprecated Dialect classes using DeprecationLogger
We want people to stop using the ones annotated @Deprecated.
This commit is contained in:
parent
60ead26c4b
commit
1503f09a41
|
@ -89,6 +89,7 @@ import java.time.temporal.TemporalAccessor;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;
|
||||||
import static org.hibernate.type.descriptor.DateTimeUtils.*;
|
import static org.hibernate.type.descriptor.DateTimeUtils.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +143,7 @@ public abstract class Dialect implements ConversionContext {
|
||||||
// constructors and factory methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// constructors and factory methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
protected Dialect() {
|
protected Dialect() {
|
||||||
LOG.usingDialect( this );
|
logSelectedDialect();
|
||||||
|
|
||||||
registerColumnType( Types.BIT, 1, "bit" );
|
registerColumnType( Types.BIT, 1, "bit" );
|
||||||
registerColumnType( Types.BIT, "bit($l)" );
|
registerColumnType( Types.BIT, "bit($l)" );
|
||||||
|
@ -231,6 +232,22 @@ public abstract class Dialect implements ConversionContext {
|
||||||
defaultSizeStrategy = new DefaultSizeStrategyImpl();
|
defaultSizeStrategy = new DefaultSizeStrategyImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logSelectedDialect() {
|
||||||
|
LOG.usingDialect( this );
|
||||||
|
|
||||||
|
Class<? extends Dialect> dialect = getClass();
|
||||||
|
if ( dialect.isAnnotationPresent(Deprecated.class) ) {
|
||||||
|
Class<?> superDialect = dialect.getSuperclass();
|
||||||
|
if ( !superDialect.isAnnotationPresent(Deprecated.class)
|
||||||
|
&& !superDialect.equals(Dialect.class) ) {
|
||||||
|
DEPRECATION_LOGGER.deprecatedDialect( dialect.getSimpleName(), superDialect.getName() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DEPRECATION_LOGGER.deprecatedDialect( dialect.getSimpleName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Useful conversion for databases which represent the
|
* Useful conversion for databases which represent the
|
||||||
* precision of a float(p) using p expressed in decimal
|
* precision of a float(p) using p expressed in decimal
|
||||||
|
|
|
@ -181,15 +181,6 @@ public interface CoreMessageLogger extends BasicLogger {
|
||||||
@Message(value = "@ForceDiscriminator is deprecated use @DiscriminatorOptions instead.", id = 62)
|
@Message(value = "@ForceDiscriminator is deprecated use @DiscriminatorOptions instead.", id = 62)
|
||||||
void deprecatedForceDescriminatorAnnotation();
|
void deprecatedForceDescriminatorAnnotation();
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
|
||||||
@Message(value = "The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead",
|
|
||||||
id = 63)
|
|
||||||
void deprecatedOracle9Dialect();
|
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
|
||||||
@Message(value = "The OracleDialect dialect has been deprecated; use Oracle8iDialect instead", id = 64)
|
|
||||||
void deprecatedOracleDialect();
|
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
@LogMessage(level = WARN)
|
||||||
@Message(value = "DEPRECATED : use [%s] instead with custom [%s] implementation", id = 65)
|
@Message(value = "DEPRECATED : use [%s] instead with custom [%s] implementation", id = 65)
|
||||||
void deprecatedUuidGenerator(String name, String name2);
|
void deprecatedUuidGenerator(String name, String name2);
|
||||||
|
@ -1521,15 +1512,6 @@ public interface CoreMessageLogger extends BasicLogger {
|
||||||
@Message(value = "Setting entity-identifier value binding where one already existed : %s.", id = 429)
|
@Message(value = "Setting entity-identifier value binding where one already existed : %s.", id = 429)
|
||||||
void entityIdentifierValueBindingExists(String name);
|
void entityIdentifierValueBindingExists(String name);
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
|
||||||
@Message(value = "The DerbyDialect dialect has been deprecated; use one of the version-specific dialects instead",
|
|
||||||
id = 430)
|
|
||||||
void deprecatedDerbyDialect();
|
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
|
||||||
@Message(value = "Unable to determine H2 database version, certain features may not work", id = 431)
|
|
||||||
void undeterminedH2Version();
|
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
@LogMessage(level = WARN)
|
||||||
@Message(value = "There were not column names specified for index %s on table %s", id = 432)
|
@Message(value = "There were not column names specified for index %s on table %s", id = 432)
|
||||||
void noColumnsSpecifiedForIndex(String indexName, String tableName);
|
void noColumnsSpecifiedForIndex(String indexName, String tableName);
|
||||||
|
|
|
@ -249,4 +249,15 @@ public interface DeprecationLogger extends BasicLogger {
|
||||||
"5.3 in upgrading. It will be removed in a later version."
|
"5.3 in upgrading. It will be removed in a later version."
|
||||||
)
|
)
|
||||||
void logUseOfDeprecatedZeroBasedJdbcStyleParams();
|
void logUseOfDeprecatedZeroBasedJdbcStyleParams();
|
||||||
|
|
||||||
|
@LogMessage(level = WARN)
|
||||||
|
@Message(value = "%s has been deprecated",
|
||||||
|
id = 90000025)
|
||||||
|
void deprecatedDialect(String dialect);
|
||||||
|
|
||||||
|
@LogMessage(level = WARN)
|
||||||
|
@Message(value = "%s has been deprecated; use %s instead",
|
||||||
|
id = 90000025)
|
||||||
|
void deprecatedDialect(String dialect, String replacement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue