diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index 856a28da67..267afe5d05 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -1884,7 +1884,7 @@ public class ModelBinder { attribute ); - if ( StringHelper.isNotEmpty( embeddedSource.getName() ) ) { + if ( StringHelper.isNotEmpty( embeddedSource.getXmlNodeName() ) ) { DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport(); } @@ -2437,7 +2437,7 @@ public class ModelBinder { Property property) { property.setName( propertySource.getName() ); - if ( StringHelper.isNotEmpty( propertySource.getName() ) ) { + if ( StringHelper.isNotEmpty( propertySource.getXmlNodeName() ) ) { DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport(); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java index debdbf353b..32cb4826f1 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java @@ -6,6 +6,7 @@ */ package org.hibernate.internal.log; +import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; import org.jboss.logging.annotations.LogMessage; import org.jboss.logging.annotations.Message; @@ -22,7 +23,7 @@ import static org.jboss.logging.Logger.Level.WARN; */ @MessageLogger( projectCode = "HHH" ) @ValidIdRange( min = 90000001, max = 90001000 ) -public interface DeprecationLogger { +public interface DeprecationLogger extends BasicLogger { public static final DeprecationLogger DEPRECATION_LOGGER = Logger.getMessageLogger( DeprecationLogger.class, "org.hibernate.orm.deprecation" diff --git a/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/Car.java b/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/Car.java new file mode 100644 index 0000000000..5e250e67ed --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/Car.java @@ -0,0 +1,41 @@ +/* + * 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 . + */ +package org.hibernate.test.entitymode.dom4j; + +/** + * @author Carsten Hammer + * @author Steve Ebersole + */ +public class Car { + protected Long id; + protected Long quantity; + protected Component component; + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getQuantity() { + return quantity; + } + + public void setQuantity(Long quantity) { + this.quantity = quantity; + } + + public Component getComponent() { + return component; + } + + public void setComponent(Component component) { + this.component = component; + } +} \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/Component.java b/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/Component.java new file mode 100644 index 0000000000..34f85ca9b7 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/Component.java @@ -0,0 +1,31 @@ +/* + * 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 . + */ +package org.hibernate.test.entitymode.dom4j; + +/** + * @author Steve Ebersole + */ +public class Component { + private String something; + private String somethingElse; + + public String getSomething() { + return something; + } + + public void setSomething(String something) { + this.something = something; + } + + public String getSomethingElse() { + return somethingElse; + } + + public void setSomethingElse(String somethingElse) { + this.somethingElse = somethingElse; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/DeprecationLoggingTest.java b/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/DeprecationLoggingTest.java new file mode 100644 index 0000000000..dfe51dd742 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/DeprecationLoggingTest.java @@ -0,0 +1,34 @@ +/* + * 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 . + */ +package org.hibernate.test.entitymode.dom4j; + +import org.hibernate.boot.MetadataSources; +import org.hibernate.internal.log.DeprecationLogger; + +import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.hibernate.testing.logger.LoggerInspectionRule; +import org.junit.Rule; +import org.junit.Test; + +/** + * Tests that {@code hbm.xml} mappings that do not specify dom4j entity-mode information + * do not trigger deprecation logging + * + * @author Steve Ebersole + */ +public class DeprecationLoggingTest extends BaseUnitTestCase { + @Rule + public LoggerInspectionRule logInspection = new LoggerInspectionRule( DeprecationLogger.DEPRECATION_LOGGER ); + + @Test + public void basicTest() { + logInspection.registerListener( LogListenerImpl.INSTANCE ); + + new MetadataSources().addResource( "org/hibernate/test/entitymode/dom4j/Car.hbm.xml" ) + .buildMetadata(); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/LogListenerImpl.java b/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/LogListenerImpl.java new file mode 100644 index 0000000000..761d2d66f4 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/entitymode/dom4j/LogListenerImpl.java @@ -0,0 +1,28 @@ +/* + * 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 . + */ +package org.hibernate.test.entitymode.dom4j; + +import org.hibernate.testing.logger.LogListener; + +import org.jboss.logging.Logger; + +/** + * @author Steve Ebersole + */ +public class LogListenerImpl implements LogListener { + /** + * Singleton access + */ + public static final LogListenerImpl INSTANCE = new LogListenerImpl(); + + @Override + public void loggedEvent(Logger.Level level, String renderedMessage, Throwable thrown) { + if ( renderedMessage != null && renderedMessage.startsWith( "HHH90000003: " ) ) { + throw new AssertionError( "Deprecation message was triggered" ); + } + } +} diff --git a/hibernate-core/src/test/resources/org/hibernate/test/entitymode/dom4j/Car.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/test/entitymode/dom4j/Car.hbm.xml new file mode 100644 index 0000000000..d47a28c1ff --- /dev/null +++ b/hibernate-core/src/test/resources/org/hibernate/test/entitymode/dom4j/Car.hbm.xml @@ -0,0 +1,24 @@ + + + + + + + + cat_id_sequence + + + + + + + + + + + \ No newline at end of file diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/logger/LogListener.java b/hibernate-testing/src/main/java/org/hibernate/testing/logger/LogListener.java index 494d828256..40f4e39d53 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/logger/LogListener.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/logger/LogListener.java @@ -8,8 +8,6 @@ package org.hibernate.testing.logger; import org.jboss.logging.Logger.Level; -interface LogListener { - +public interface LogListener { void loggedEvent(Level level, String renderedMessage, Throwable thrown); - }