Skip to content

Commit fd1b81a

Browse files
committed
NH-3722 - Not propagating XML node names configured in mappings
* Ported from HHH-10073 hibernate/hibernate-orm@1376b12
1 parent fba9c79 commit fd1b81a

11 files changed

+6
-95
lines changed

src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs

-11
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ protected void BindClass(IEntityMapping classMapping, PersistentClass model, IDi
3939
model.EntityName = entityName;
4040

4141
BindPocoRepresentation(classMapping, model);
42-
BindXmlRepresentation(classMapping, model);
4342
BindMapRepresentation(classMapping, model);
4443

4544
BindPersistentClassCommonValues(classMapping, model, inheritedMetas);
@@ -128,11 +127,6 @@ private void BindMapRepresentation(IEntityMapping classMapping, PersistentClass
128127
}
129128
}
130129

131-
private void BindXmlRepresentation(IEntityMapping classMapping, PersistentClass entity)
132-
{
133-
entity.NodeName = string.IsNullOrEmpty(classMapping.Node) ? StringHelper.Unqualify(entity.EntityName): classMapping.Node;
134-
}
135-
136130
private void BindPocoRepresentation(IEntityMapping classMapping, PersistentClass entity)
137131
{
138132
string className = classMapping.Name == null
@@ -321,11 +315,6 @@ protected void BindComponent(IComponentMapping componentMapping, Component model
321315
}
322316
}
323317

324-
string nodeName = !string.IsNullOrEmpty(componentMapping.EmbeddedNode)
325-
? componentMapping.EmbeddedNode
326-
: !string.IsNullOrEmpty(componentMapping.Name) ? componentMapping.Name : model.Owner.NodeName;
327-
model.NodeName = nodeName;
328-
329318
// Parent
330319
if (componentMapping.Parent != null && !string.IsNullOrEmpty(componentMapping.Parent.name))
331320
{

src/NHibernate/Mapping/Collection.cs

-27
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public abstract class Collection : IFetchable, IValue, IFilterable
2626

2727
private IKeyValue key;
2828
private IValue element;
29-
private string elementNodeName;
3029
private Table collectionTable;
3130
private string role;
3231
private bool lazy;
@@ -47,7 +46,6 @@ public abstract class Collection : IFetchable, IValue, IFilterable
4746
private string referencedPropertyName;
4847
private string typeName;
4948
private bool embedded = true;
50-
private string nodeName;
5149

5250
private string loaderName;
5351

@@ -397,19 +395,6 @@ public virtual void Validate(IMapping mapping)
397395
}
398396

399397
CheckColumnDuplication();
400-
401-
if (elementNodeName != null && elementNodeName.StartsWith("@"))
402-
{
403-
throw new MappingException(string.Format("element node must not be an attribute: {0}", elementNodeName));
404-
}
405-
if (elementNodeName != null && elementNodeName.Equals("."))
406-
{
407-
throw new MappingException(string.Format("element node must not be the parent: {0}", elementNodeName));
408-
}
409-
if (nodeName != null && nodeName.IndexOf('@') > -1)
410-
{
411-
throw new MappingException(string.Format("collection node must not be an attribute: {0}", elementNodeName));
412-
}
413398
}
414399

415400
public bool[] ColumnInsertability
@@ -566,12 +551,6 @@ public bool IsOptimisticLocked
566551
set { optimisticLocked = value; }
567552
}
568553

569-
public string ElementNodeName
570-
{
571-
get { return elementNodeName; }
572-
set { elementNodeName = value; }
573-
}
574-
575554
public bool Embedded
576555
{
577556
get { return embedded; }
@@ -642,12 +621,6 @@ public bool IsMutable
642621
set { mutable = value; }
643622
}
644623

645-
public string NodeName
646-
{
647-
get { return nodeName; }
648-
set { nodeName = value; }
649-
}
650-
651624
public ISet<string> SynchronizedTables
652625
{
653626
get { return synchronizedTables; }

src/NHibernate/Mapping/Component.cs

-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class Component : SimpleValue, IMetaAttributable
2020
private PersistentClass owner;
2121
private bool dynamic;
2222
private bool isKey;
23-
private string nodeName;
2423
private string roleName;
2524
private Dictionary<EntityMode, string> tuplizerImpls;
2625
private string componentClassName;
@@ -228,12 +227,6 @@ public bool IsKey
228227
set { isKey = value; }
229228
}
230229

231-
public string NodeName
232-
{
233-
get { return nodeName; }
234-
set { nodeName = value; }
235-
}
236-
237230
public string RoleName
238231
{
239232
get { return roleName; }

src/NHibernate/Mapping/IndexedCollection.cs

-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public abstract class IndexedCollection : Collection
1414
public const string DefaultIndexColumnName = "idx";
1515

1616
private SimpleValue index;
17-
private string indexNodeName;
1817

1918
protected IndexedCollection(PersistentClass owner) : base(owner)
2019
{
@@ -36,12 +35,6 @@ public virtual bool IsList
3635
get { return false; }
3736
}
3837

39-
public string IndexNodeName
40-
{
41-
get { return indexNodeName; }
42-
set { indexNodeName = value; }
43-
}
44-
4538
public override void CreatePrimaryKey()
4639
{
4740
if (!IsOneToMany)
@@ -78,10 +71,6 @@ public override void Validate(IMapping mapping)
7871
throw new MappingException(
7972
string.Format("collection index mapping has wrong number of columns: {0} type: {1}", Role, Index.Type.Name));
8073
}
81-
if (indexNodeName != null && !indexNodeName.StartsWith("@"))
82-
{
83-
throw new MappingException("index node must be an attribute: " + indexNodeName);
84-
}
8574
}
8675
}
8776
}

src/NHibernate/Mapping/PersistentClass.cs

-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public abstract class PersistentClass : IFilterable, IMetaAttributable, ISqlCust
2727
private string entityName;
2828
private string className;
2929
private string proxyInterfaceName;
30-
private string nodeName;
3130
private string discriminatorValue;
3231
private bool lazy;
3332
private readonly List<Property> properties = new List<Property>();
@@ -541,12 +540,6 @@ protected virtual internal IEnumerable<ISelectable> DiscriminatorColumnIterator
541540
get { return new CollectionHelper.EmptyEnumerableClass<ISelectable>(); }
542541
}
543542

544-
public string NodeName
545-
{
546-
get { return nodeName; }
547-
set { nodeName = value; }
548-
}
549-
550543
public virtual bool HasSubselectLoadableCollections
551544
{
552545
get { return hasSubselectLoadableCollections; }

src/NHibernate/Mapping/Property.cs

-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class Property : IMetaAttributable
2323
private bool selectable = true;
2424
private string propertyAccessorName;
2525
private bool optional;
26-
private string nodeName;
2726
private IDictionary<string, MetaAttribute> metaAttributes;
2827
private PersistentClass persistentClass;
2928
private bool isOptimisticLocked;
@@ -276,12 +275,6 @@ public bool IsNaturalIdentifier
276275
set { isNaturalIdentifier = value; }
277276
}
278277

279-
public string NodeName
280-
{
281-
get { return nodeName; }
282-
set { nodeName = value; }
283-
}
284-
285278
// both many-to-one and one-to-one are represented as a
286279
// Property. EntityPersister is relying on this value to
287280
// determine "lazy fetch groups" in terms of field-level

src/NHibernate/Tuple/IdentifierProperty.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,18 @@ public class IdentifierProperty : Property
2828
/// </summary>
2929
/// <param name="name">The name of the property representing the identifier within
3030
/// its owning entity.</param>
31-
/// <param name="node">The node name to use for XML-based representation of this
32-
/// property.</param>
3331
/// <param name="type">The Hibernate Type for the identifier property.</param>
3432
/// <param name="embedded">Is this an embedded identifier.</param>
3533
/// <param name="unsavedValue">The value which, if found as the value on the identifier
3634
/// property, represents new (i.e., un-saved) instances of the owning entity.</param>
3735
/// <param name="identifierGenerator">The generator to use for id value generation.</param>
3836
public IdentifierProperty(
3937
String name,
40-
String node,
4138
IType type,
4239
bool embedded,
4340
IdentifierValue unsavedValue,
4441
IIdentifierGenerator identifierGenerator)
45-
: base(name, node, type)
42+
: base(name, type)
4643
{
4744
isVirtual = false;
4845
this.embedded = embedded;
@@ -62,7 +59,7 @@ public IdentifierProperty(
6259
/// <param name="identifierGenerator">The generator to use for id value generation.</param>
6360
/// <param name="hasIdentifierMapper"></param>
6461
public IdentifierProperty(IType type, bool embedded, bool hasIdentifierMapper, IdentifierValue unsavedValue, IIdentifierGenerator identifierGenerator)
65-
: base(null, null, type)
62+
: base(null, type)
6663
{
6764
isVirtual = true;
6865
this.embedded = embedded;

src/NHibernate/Tuple/Property.cs

+1-9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@ namespace NHibernate.Tuple
1010
public abstract class Property
1111
{
1212
private readonly string name;
13-
private readonly string node;
1413
private readonly IType type;
1514

1615
/// <summary>
1716
/// Constructor for Property instances.
1817
/// </summary>
1918
/// <param name="name">The name by which the property can be referenced within its owner.</param>
20-
/// <param name="node">The node name to use for XML-based representation of this property.</param>
2119
/// <param name="type">The Hibernate Type of this property.</param>
22-
protected Property(string name, string node, IType type)
20+
protected Property(string name, IType type)
2321
{
2422
this.name = name;
25-
this.node = node;
2623
this.type = type;
2724
}
2825

@@ -31,11 +28,6 @@ public string Name
3128
get { return name; }
3229
}
3330

34-
public string Node
35-
{
36-
get { return node; }
37-
}
38-
3931
public IType Type
4032
{
4133
get { return type; }

src/NHibernate/Tuple/PropertyFactory.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static IdentifierProperty BuildIdentifierProperty(PersistentClass mappedE
4040
}
4141
else
4242
{
43-
return new IdentifierProperty(property.Name, property.NodeName, type, mappedEntity.HasEmbeddedIdentifier, unsavedValue, generator);
43+
return new IdentifierProperty(property.Name, type, mappedEntity.HasEmbeddedIdentifier, unsavedValue, generator);
4444
}
4545
}
4646

@@ -66,7 +66,6 @@ public static VersionProperty BuildVersionProperty(Mapping.Property property, bo
6666

6767
return new VersionProperty(
6868
property.Name,
69-
property.NodeName,
7069
property.Value.Type,
7170
lazy,
7271
property.IsInsertable,
@@ -104,7 +103,6 @@ public static StandardProperty BuildStandardProperty(Mapping.Property property,
104103

105104
return new StandardProperty(
106105
property.Name,
107-
property.NodeName,
108106
type,
109107
lazyAvailable && property.IsLazy,
110108
property.IsInsertable,

src/NHibernate/Tuple/StandardProperty.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public class StandardProperty : Property
2828
/// </summary>
2929
/// <param name="name">The name by which the property can be referenced within
3030
/// its owner.</param>
31-
/// <param name="node">The node name to use for XML-based representation of this
32-
/// property.</param>
3331
/// <param name="type">The Hibernate Type of this property.</param>
3432
/// <param name="lazy">Should this property be handled lazily?</param>
3533
/// <param name="insertable">Is this property an insertable value?</param>
@@ -43,7 +41,6 @@ public class StandardProperty : Property
4341
/// <param name="fetchMode">Any fetch mode defined for this property </param>
4442
public StandardProperty(
4543
String name,
46-
String node,
4744
IType type,
4845
bool lazy,
4946
bool insertable,
@@ -55,7 +52,7 @@ public StandardProperty(
5552
bool versionable,
5653
CascadeStyle cascadeStyle,
5754
FetchMode? fetchMode)
58-
: base(name, node, type)
55+
: base(name, type)
5956
{
6057
this.lazy = lazy;
6158
this.insertable = insertable;

src/NHibernate/Tuple/VersionProperty.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ public class VersionProperty : StandardProperty
2020
/// </summary>
2121
/// <param name="name">The name by which the property can be referenced within
2222
/// its owner.</param>
23-
/// <param name="node">The node name to use for XML-based representation of this
24-
/// property.</param>
2523
/// <param name="type">The Hibernate Type of this property.</param>
2624
/// <param name="lazy">Should this property be handled lazily?</param>
2725
/// <param name="insertable">Is this property an insertable value?</param>
@@ -37,7 +35,6 @@ public class VersionProperty : StandardProperty
3735
/// instances of the owning entity.</param>
3836
public VersionProperty(
3937
string name,
40-
string node,
4138
IType type,
4239
bool lazy,
4340
bool insertable,
@@ -50,7 +47,7 @@ public VersionProperty(
5047
CascadeStyle cascadeStyle,
5148
VersionValue unsavedValue)
5249
: base(
53-
name, node, type, lazy, insertable, updateable, insertGenerated, updateGenerated, nullable, checkable, versionable,
50+
name, type, lazy, insertable, updateable, insertGenerated, updateGenerated, nullable, checkable, versionable,
5451
cascadeStyle, null)
5552
{
5653
this.unsavedValue = unsavedValue;

0 commit comments

Comments
 (0)