HHH-7860 : Log a warning when embed-xml attribute is used in mappings

This commit is contained in:
Gail Badner 2012-12-12 16:06:03 -08:00
parent dc3283f50a
commit 2883cb85c3
2 changed files with 34 additions and 1 deletions

View File

@ -1404,6 +1404,12 @@ public final class HbmBinder {
if ( nodeName == null ) nodeName = node.attributeValue( "name" ); if ( nodeName == null ) nodeName = node.attributeValue( "name" );
collection.setNodeName( nodeName ); collection.setNodeName( nodeName );
String embed = node.attributeValue( "embed-xml" ); String embed = node.attributeValue( "embed-xml" );
// sometimes embed is set to the default value when not specified in the mapping,
// so can't seem to determine if an attribute was explicitly set;
// log a warning if embed has a value different from the default.
if ( !StringHelper.isEmpty( embed ) && !"true".equals( embed ) ) {
LOG.embedXmlAttributesNoLongerSupported();
}
collection.setEmbedded( embed==null || "true".equals(embed) ); collection.setEmbedded( embed==null || "true".equals(embed) );
@ -1627,6 +1633,12 @@ public final class HbmBinder {
manyToOne.setReferencedEntityName( getEntityName( node, mappings ) ); manyToOne.setReferencedEntityName( getEntityName( node, mappings ) );
String embed = node.attributeValue( "embed-xml" ); String embed = node.attributeValue( "embed-xml" );
// sometimes embed is set to the default value when not specified in the mapping,
// so can't seem to determine if an attribute was explicitly set;
// log a warning if embed has a value different from the default.
if ( !StringHelper.isEmpty( embed ) && !"true".equals( embed ) ) {
LOG.embedXmlAttributesNoLongerSupported();
}
manyToOne.setEmbedded( embed == null || "true".equals( embed ) ); manyToOne.setEmbedded( embed == null || "true".equals( embed ) );
String notFound = node.attributeValue( "not-found" ); String notFound = node.attributeValue( "not-found" );
@ -1702,7 +1714,14 @@ public final class HbmBinder {
initOuterJoinFetchSetting( node, oneToOne ); initOuterJoinFetchSetting( node, oneToOne );
initLaziness( node, oneToOne, mappings, true ); initLaziness( node, oneToOne, mappings, true );
oneToOne.setEmbedded( "true".equals( node.attributeValue( "embed-xml" ) ) ); String embed = node.attributeValue( "embed-xml" );
// sometimes embed is set to the default value when not specified in the mapping,
// so can't seem to determine if an attribute was explicitly set;
// log a warning if embed has a value different from the default.
if ( !StringHelper.isEmpty( embed ) && !"true".equals( embed ) ) {
LOG.embedXmlAttributesNoLongerSupported();
}
oneToOne.setEmbedded( "true".equals( embed ) );
Attribute fkNode = node.attribute( "foreign-key" ); Attribute fkNode = node.attribute( "foreign-key" );
if ( fkNode != null ) oneToOne.setForeignKeyName( fkNode.getValue() ); if ( fkNode != null ) oneToOne.setForeignKeyName( fkNode.getValue() );
@ -1730,6 +1749,12 @@ public final class HbmBinder {
oneToMany.setReferencedEntityName( getEntityName( node, mappings ) ); oneToMany.setReferencedEntityName( getEntityName( node, mappings ) );
String embed = node.attributeValue( "embed-xml" ); String embed = node.attributeValue( "embed-xml" );
// sometimes embed is set to the default value when not specified in the mapping,
// so can't seem to determine if an attribute was explicitly set;
// log a warning if embed has a value different from the default.
if ( !StringHelper.isEmpty( embed ) && !"true".equals( embed ) ) {
LOG.embedXmlAttributesNoLongerSupported();
}
oneToMany.setEmbedded( embed == null || "true".equals( embed ) ); oneToMany.setEmbedded( embed == null || "true".equals( embed ) );
String notFound = node.attributeValue( "not-found" ); String notFound = node.attributeValue( "not-found" );

View File

@ -1601,4 +1601,12 @@ public interface CoreMessageLogger extends BasicLogger {
) )
void aliasSpecificLockingWithFollowOnLocking(LockMode lockMode); void aliasSpecificLockingWithFollowOnLocking(LockMode lockMode);
@LogMessage(level = WARN)
@Message(
value = "embed-xml attributes were intended to be used for DOM4J entity mode. Since that entity mode has been " +
"removed, embed-xml attributes are no longer supported and should be removed from mappings.",
id = 446
)
void embedXmlAttributesNoLongerSupported();
} }