HHH-10115 - HHH90000003: Use of DOM4J entity-mode is considered deprecated
(cherry picked from commit 91cd767d20
)
This commit is contained in:
parent
c5b1cf94f3
commit
6ce9d6848d
|
@ -1884,7 +1884,7 @@ public class ModelBinder {
|
||||||
attribute
|
attribute
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( StringHelper.isNotEmpty( embeddedSource.getName() ) ) {
|
if ( StringHelper.isNotEmpty( embeddedSource.getXmlNodeName() ) ) {
|
||||||
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
|
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2437,7 +2437,7 @@ public class ModelBinder {
|
||||||
Property property) {
|
Property property) {
|
||||||
property.setName( propertySource.getName() );
|
property.setName( propertySource.getName() );
|
||||||
|
|
||||||
if ( StringHelper.isNotEmpty( propertySource.getName() ) ) {
|
if ( StringHelper.isNotEmpty( propertySource.getXmlNodeName() ) ) {
|
||||||
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
|
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.internal.log;
|
package org.hibernate.internal.log;
|
||||||
|
|
||||||
|
import org.jboss.logging.BasicLogger;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
import org.jboss.logging.annotations.LogMessage;
|
import org.jboss.logging.annotations.LogMessage;
|
||||||
import org.jboss.logging.annotations.Message;
|
import org.jboss.logging.annotations.Message;
|
||||||
|
@ -22,7 +23,7 @@ import static org.jboss.logging.Logger.Level.WARN;
|
||||||
*/
|
*/
|
||||||
@MessageLogger( projectCode = "HHH" )
|
@MessageLogger( projectCode = "HHH" )
|
||||||
@ValidIdRange( min = 90000001, max = 90001000 )
|
@ValidIdRange( min = 90000001, max = 90001000 )
|
||||||
public interface DeprecationLogger {
|
public interface DeprecationLogger extends BasicLogger {
|
||||||
public static final DeprecationLogger DEPRECATION_LOGGER = Logger.getMessageLogger(
|
public static final DeprecationLogger DEPRECATION_LOGGER = Logger.getMessageLogger(
|
||||||
DeprecationLogger.class,
|
DeprecationLogger.class,
|
||||||
"org.hibernate.orm.deprecation"
|
"org.hibernate.orm.deprecation"
|
||||||
|
|
|
@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
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" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
~ 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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
-->
|
||||||
|
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping" package="org.hibernate.test.entitymode.dom4j">
|
||||||
|
<class name="Car" table="Car">
|
||||||
|
<cache usage="nonstrict-read-write" region="org.hibernate.test.entitymode.dom4j.Car"/>
|
||||||
|
<id name="id" column="id" type="java.lang.Long">
|
||||||
|
<generator class="native">
|
||||||
|
<param name="sequence">cat_id_sequence</param>
|
||||||
|
</generator>
|
||||||
|
</id>
|
||||||
|
<property name="quantity" type="java.lang.Long">
|
||||||
|
<column name="quantity" />
|
||||||
|
</property>
|
||||||
|
<component name="component" class="Component">
|
||||||
|
<property name="something"/>
|
||||||
|
<property name="somethingElse"/>
|
||||||
|
</component>
|
||||||
|
</class>
|
||||||
|
</hibernate-mapping>
|
|
@ -8,8 +8,6 @@ package org.hibernate.testing.logger;
|
||||||
|
|
||||||
import org.jboss.logging.Logger.Level;
|
import org.jboss.logging.Logger.Level;
|
||||||
|
|
||||||
interface LogListener {
|
public interface LogListener {
|
||||||
|
|
||||||
void loggedEvent(Level level, String renderedMessage, Throwable thrown);
|
void loggedEvent(Level level, String renderedMessage, Throwable thrown);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue