Skip to content

Commit

Permalink
HHH-10073 Not propagating XML node names configured in mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmorling authored and sebersole committed Sep 1, 2015
1 parent 6f215a9 commit 1376b12
Show file tree
Hide file tree
Showing 19 changed files with 12 additions and 168 deletions.
Expand Up @@ -434,7 +434,6 @@ else if ( entitySource.isLazy() ) {

if ( StringHelper.isNotEmpty( entitySource.getXmlNodeName() ) ) {
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
entityDescriptor.setNodeName( entitySource.getXmlNodeName() );
}

entityDescriptor.setDynamicInsert( entitySource.isDynamicInsert() );
Expand Down Expand Up @@ -918,7 +917,6 @@ private void bindNonAggregatedCompositeEntityIdentifier(
rootEntityDescriptor.setIdentifierMapper(mapper);
Property property = new Property();
property.setName( PropertyPath.IDENTIFIER_MAPPER_PROPERTY );
property.setNodeName( "id" );
property.setUpdateable( false );
property.setInsertable( false );
property.setValue( mapper );
Expand Down Expand Up @@ -1886,9 +1884,9 @@ public String getPropertyAccessorName() {
attribute
);

final String xmlNodeName = determineXmlNodeName( embeddedSource, componentBinding.getOwner().getNodeName() );
componentBinding.setNodeName( xmlNodeName );
attribute.setNodeName( xmlNodeName );
if ( StringHelper.isNotEmpty( embeddedSource.getName() ) ) {
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
}

return attribute;
}
Expand Down Expand Up @@ -2438,7 +2436,10 @@ private void bindProperty(
AttributeSource propertySource,
Property property) {
property.setName( propertySource.getName() );
property.setNodeName( determineXmlNodeName( propertySource, null ) );

if ( StringHelper.isNotEmpty( propertySource.getName() ) ) {
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
}

property.setPropertyAccessorName(
StringHelper.isNotEmpty( propertySource.getPropertyAccessorName() )
Expand Down Expand Up @@ -2538,21 +2539,6 @@ private void bindProperty(
}
}

private String determineXmlNodeName(AttributeSource propertySource, String fallbackXmlNodeName) {
String nodeName = propertySource.getXmlNodeName();
if ( StringHelper.isNotEmpty( nodeName ) ) {
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
}
else {
nodeName = propertySource.getName();
}
if ( nodeName == null ) {
nodeName = fallbackXmlNodeName;
}

return nodeName;
}

private void bindComponent(
MappingDocument sourceDocument,
EmbeddableSource embeddableSource,
Expand Down Expand Up @@ -2662,13 +2648,6 @@ else if ( componentBinding.getOwner().hasPojoRepresentation() ) {
if ( StringHelper.isNotEmpty( nodeName ) ) {
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
}
else {
nodeName = propertyName;
}
if ( nodeName == null ) {
nodeName = componentBinding.getOwner().getNodeName();
}
componentBinding.setNodeName( nodeName );

// todo : anything else to pass along?
bindAllCompositeAttributes(
Expand Down Expand Up @@ -3986,7 +3965,6 @@ public MetadataBuildingContext getBuildingContext() {

collectionBinding.setIndex( indexBinding );
collectionBinding.setBaseIndex( indexSource.getBase() );
collectionBinding.setIndexNodeName( indexSource.getXmlNodeName() );
}

private void bindMapKey(
Expand Down Expand Up @@ -4027,7 +4005,6 @@ public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
);

collectionBinding.setIndex( value );
collectionBinding.setIndexNodeName( mapKeySource.getXmlNodeName() );
}
else if ( pluralAttributeSource.getIndexSource() instanceof PluralAttributeMapKeySourceEmbedded ) {
final PluralAttributeMapKeySourceEmbedded mapKeySource =
Expand Down
Expand Up @@ -1036,7 +1036,6 @@ private static boolean mapAsIdClass(

Property property = new Property();
property.setName( PropertyPath.IDENTIFIER_MAPPER_PROPERTY );
property.setNodeName( "id" );
property.setUpdateable( false );
property.setInsertable( false );
property.setValue( mapper );
Expand Down Expand Up @@ -2672,7 +2671,6 @@ public static Component createComponent(
else {
comp.setComponentClassName( inferredData.getClassOrElementName() );
}
comp.setNodeName( inferredData.getPropertyName() );
return comp;
}

Expand Down
Expand Up @@ -88,7 +88,6 @@ public static Property shallowCopy(Property property) {
clone.setInsertable( property.isInsertable() );
clone.setLazy( property.isLazy() );
clone.setName( property.getName() );
clone.setNodeName( property.getNodeName() );
clone.setNaturalIdentifier( property.isNaturalIdentifier() );
clone.setOptimisticLocked( property.isOptimisticLocked() );
clone.setOptional( property.isOptional() );
Expand Down Expand Up @@ -266,7 +265,6 @@ public static void createSyntheticPropertyReference(
new Component( context.getMetadataCollector(), (PersistentClass) columnOwner ) :
new Component( context.getMetadataCollector(), (Join) columnOwner );
embeddedComp.setEmbedded( true );
embeddedComp.setNodeName( syntheticPropertyName );
embeddedComp.setComponentClassName( embeddedComp.getOwner().getClassName() );
for (Property property : properties) {
Property clone = BinderHelper.shallowCopy( property );
Expand All @@ -278,7 +276,6 @@ public static void createSyntheticPropertyReference(
}
synthProp = new SyntheticProperty();
synthProp.setName( syntheticPropertyName );
synthProp.setNodeName( syntheticPropertyName );
synthProp.setPersistentClass( ownerEntity );
synthProp.setUpdateable( false );
synthProp.setInsertable( false );
Expand Down
Expand Up @@ -94,7 +94,6 @@ public void doSecondPass(Map persistentClasses) throws MappingException {
else {
Property property = new Property();
property.setName( referencedProperty.getName() );
property.setNodeName( referencedProperty.getNodeName() );
//FIXME set optional?
//property.setOptional( property.isOptional() );
property.setPersistentClass( component.getOwner() );
Expand Down
Expand Up @@ -385,7 +385,6 @@ public void bind() {
String role = StringHelper.qualify( propertyHolder.getPath(), propertyName );
LOG.debugf( "Collection role: %s", role );
collection.setRole( role );
collection.setNodeName( propertyName );
collection.setMappedByProperty( mappedBy );

if ( property.isAnnotationPresent( MapKeyColumn.class )
Expand Down
Expand Up @@ -233,7 +233,6 @@ public void setInsertableDiscriminator(boolean insertableDiscriminator) {
public void bindEntity() {
persistentClass.setAbstract( annotatedClass.isAbstract() );
persistentClass.setClassName( annotatedClass.getName() );
persistentClass.setNodeName( name );
persistentClass.setJpaEntityName(name);
//persistentClass.setDynamic(false); //no longer needed with the Entity name refactoring?
persistentClass.setEntityName( annotatedClass.getName() );
Expand Down
Expand Up @@ -352,8 +352,6 @@ else if ( element instanceof DependantValue ) {
Iterator properties = component.getPropertyIterator();
Component indexComponent = new Component( getBuildingContext().getMetadataCollector(), collection );
indexComponent.setComponentClassName( component.getComponentClassName() );
//TODO I don't know if this is appropriate
indexComponent.setNodeName( "index" );
while ( properties.hasNext() ) {
Property current = (Property) properties.next();
Property newProperty = new Property();
Expand All @@ -363,7 +361,6 @@ else if ( element instanceof DependantValue ) {
newProperty.setUpdateable( false );
newProperty.setMetaAttributes( current.getMetaAttributes() );
newProperty.setName( current.getName() );
newProperty.setNodeName( current.getNodeName() );
newProperty.setNaturalIdentifier( false );
//newProperty.setOptimisticLocked( false );
newProperty.setOptional( false );
Expand Down
Expand Up @@ -260,7 +260,6 @@ public Property makeProperty() {
LOG.debugf( "Building property %s", name );
Property prop = new Property();
prop.setName( name );
prop.setNodeName( name );
prop.setValue( value );
prop.setLazy( lazy );
prop.setCascade( cascade );
Expand Down
28 changes: 0 additions & 28 deletions hibernate-core/src/main/java/org/hibernate/mapping/Collection.java
Expand Up @@ -54,8 +54,6 @@ public abstract class Collection implements Fetchable, Value, Filterable {
private String manyToManyWhere;
private String manyToManyOrderBy;
private String referencedPropertyName;
private String nodeName;
private String elementNodeName;
private String mappedByProperty;
private boolean sorted;
private Comparator comparator;
Expand Down Expand Up @@ -319,16 +317,6 @@ public void validate(Mapping mapping) throws MappingException {
}

checkColumnDuplication();

if ( elementNodeName != null && elementNodeName.startsWith( "@" ) ) {
throw new MappingException( "element node must not be an attribute: " + elementNodeName );
}
if ( elementNodeName != null && elementNodeName.equals( "." ) ) {
throw new MappingException( "element node must not be the parent: " + elementNodeName );
}
if ( nodeName != null && nodeName.indexOf( '@' ) > -1 ) {
throw new MappingException( "collection node must not be an attribute: " + elementNodeName );
}
}

private void checkColumnDuplication(java.util.Set distinctColumns, Iterator columns)
Expand Down Expand Up @@ -645,22 +633,6 @@ public boolean[] getColumnUpdateability() {
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
}

public String getNodeName() {
return nodeName;
}

public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}

public String getElementNodeName() {
return elementNodeName;
}

public void setElementNodeName(String elementNodeName) {
this.elementNodeName = elementNodeName;
}

public boolean isSubselectLoadable() {
return subselectLoadable;
}
Expand Down
Expand Up @@ -45,7 +45,6 @@ public class Component extends SimpleValue implements MetaAttributable {
private PersistentClass owner;
private boolean dynamic;
private Map metaAttributes;
private String nodeName;
private boolean isKey;
private String roleName;

Expand Down Expand Up @@ -229,14 +228,6 @@ public boolean[] getColumnUpdateability() {
return result;
}

public String getNodeName() {
return nodeName;
}

public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}

public boolean isKey() {
return isKey;
}
Expand Down
Expand Up @@ -22,7 +22,6 @@ public abstract class IndexedCollection extends Collection {
public static final String DEFAULT_INDEX_COLUMN_NAME = "idx";

private Value index;
private String indexNodeName;

public IndexedCollection(MetadataImplementor metadata, PersistentClass owner) {
super( metadata, owner );
Expand Down Expand Up @@ -84,22 +83,9 @@ public void validate(Mapping mapping) throws MappingException {
getIndex().getType().getName()
);
}
if ( indexNodeName!=null && !indexNodeName.startsWith("@") ) {
throw new MappingException("index node must be an attribute: " + indexNodeName );
}
}

public boolean isList() {
return false;
}

public String getIndexNodeName() {
return indexNodeName;
}

public void setIndexNodeName(String indexNodeName) {
this.indexNodeName = indexNodeName;
}


}
Expand Up @@ -51,7 +51,6 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl
private String proxyInterfaceName;
private transient Class proxyInterface;

private String nodeName;
private String jpaEntityName;

private String discriminatorValue;
Expand Down Expand Up @@ -815,14 +814,6 @@ protected void checkColumnDuplication() {

public abstract Object accept(PersistentClassVisitor mv);

public String getNodeName() {
return nodeName;
}

public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}

public String getJpaEntityName() {
return jpaEntityName;
}
Expand All @@ -835,10 +826,6 @@ public boolean hasPojoRepresentation() {
return getClassName() != null;
}

public boolean hasDom4jRepresentation() {
return getNodeName() != null;
}

public boolean hasSubselectLoadableCollections() {
return hasSubselectLoadableCollections;
}
Expand Down
Expand Up @@ -44,7 +44,6 @@ public class Property implements Serializable, MetaAttributable {
private String propertyAccessorName;
private boolean lazy;
private boolean optional;
private String nodeName;
private java.util.Map metaAttributes;
private PersistentClass persistentClass;
private boolean naturalIdentifier;
Expand Down Expand Up @@ -291,14 +290,6 @@ public void setSelectable(boolean selectable) {
this.selectable = selectable;
}

public String getNodeName() {
return nodeName;
}

public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}

public String getAccessorPropertyName( EntityMode mode ) {
return getName();
}
Expand Down

0 comments on commit 1376b12

Please sign in to comment.