HHH-13226 Log a warning in case of inconsistent configuration properties
This commit is contained in:
parent
d18b38c504
commit
ee63e49011
|
@ -1866,4 +1866,9 @@ public interface CoreMessageLogger extends BasicLogger {
|
|||
@LogMessage(level = WARN)
|
||||
@Message(value = "A class should not be annotated with both @Inheritance and @MappedSuperclass. @Inheritance will be ignored for: %s.", id = 503)
|
||||
void unsupportedMappedSuperclassWithEntityInheritance(String entityName);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(value = "Multiple configuration properties defined to create schema. Choose at most one among 'javax.persistence.create-database-schemas', 'hibernate.hbm2ddl.create_namespaces', 'hibernate.hbm2dll.create_namespaces' (this last being deprecated).", id = 504)
|
||||
void multipleSchemaCreationSettingsDefined();
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ import org.hibernate.boot.model.relational.Namespace;
|
|||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.resource.transaction.spi.DdlTransactionIsolator;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
@ -39,7 +41,8 @@ import org.jboss.logging.Logger;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class Helper {
|
||||
private static final Logger log = Logger.getLogger( Helper.class );
|
||||
|
||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( Helper.class );
|
||||
|
||||
public static ScriptSourceInput interpretScriptSourceSetting(
|
||||
Object scriptSourceSetting,
|
||||
|
@ -103,6 +106,20 @@ public class Helper {
|
|||
}
|
||||
|
||||
public static boolean interpretNamespaceHandling(Map configurationValues) {
|
||||
//Print a warning if multiple conflicting properties are being set:
|
||||
int count = 0;
|
||||
if ( configurationValues.containsKey( AvailableSettings.HBM2DDL_CREATE_SCHEMAS ) ) {
|
||||
count++;
|
||||
}
|
||||
if ( configurationValues.containsKey( AvailableSettings.HBM2DDL_CREATE_NAMESPACES ) ) {
|
||||
count++;
|
||||
}
|
||||
if ( configurationValues.containsKey( AvailableSettings.HBM2DLL_CREATE_NAMESPACES ) ) {
|
||||
count++;
|
||||
}
|
||||
if ( count > 1 ) {
|
||||
log.multipleSchemaCreationSettingsDefined();
|
||||
}
|
||||
// prefer the JPA setting...
|
||||
return ConfigurationHelper.getBoolean(
|
||||
AvailableSettings.HBM2DDL_CREATE_SCHEMAS,
|
||||
|
|
Loading…
Reference in New Issue