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

This commit is contained in:
Gail Badner 2012-12-12 15:14:38 -08:00
parent 1782a9dc84
commit c6ef23a51c
2 changed files with 34 additions and 1 deletions

View File

@ -1403,6 +1403,12 @@ public final class HbmBinder {
if ( nodeName == null ) nodeName = node.attributeValue( "name" );
collection.setNodeName( nodeName );
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) );
@ -1626,6 +1632,12 @@ public final class HbmBinder {
manyToOne.setReferencedEntityName( getEntityName( node, mappings ) );
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 ) );
String notFound = node.attributeValue( "not-found" );
@ -1701,7 +1713,14 @@ public final class HbmBinder {
initOuterJoinFetchSetting( node, oneToOne );
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" );
if ( fkNode != null ) oneToOne.setForeignKeyName( fkNode.getValue() );
@ -1729,6 +1748,12 @@ public final class HbmBinder {
oneToMany.setReferencedEntityName( getEntityName( node, mappings ) );
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 ) );
String notFound = node.attributeValue( "not-found" );

View File

@ -1601,4 +1601,12 @@ public interface CoreMessageLogger extends BasicLogger {
)
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();
}