There sure aren't enough examples of how to use the NHibernate.Mapping.Attributes namespace. I've got a class where I've mapped my composite key and now I'm trying to create a one-to-many relationship to a child class. However, I receive this error:
"(58,8): XML validation error: The element 'set' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'key' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'element, one-to-many, many-to-many, composite-element, many-to-any' in namespace 'urn:nhibernate-mapping-2.2'."
I apologize for pasting the entire class but I know someone will ask to see the code if I don't. Thank You in advance.
This is my Class and I do have a one-to-many mapping:
Code:
[NHibernate.Mapping.Attributes.Class(0, Schema = BizSchema, Table = "HEADER", NameType = typeof(HeaderDAO),
Lazy = true)]
public class HeaderDAO
{
public HeaderDAO()
{
}
private String _HSTAT;
private Decimal _HCONO;
private Decimal _HDVNO;
private Decimal _HSEQ;
private Decimal _HCUST;
private String _HJBNO;
private String _HSJNO;
private Decimal _HDTTK;
private Decimal _HDTBG;
private Decimal _HDTEN;
private String _HDESC;
private Decimal _HDSCD;
private Decimal _HKEY0;
private Decimal _HKEY1;
private Decimal _HKEY2;
private Decimal _HKEY3;
private Decimal _HKEY4;
private Decimal _HKEY5;
private Decimal _HNUM0;
private Decimal _HNUM1;
private Decimal _HNUM2;
private Decimal _HNUM3;
private Decimal _HNUM4;
private Decimal _HNUM5;
private String _HDES0;
private String _HDES1;
private String _HDES2;
private String _HDES3;
private String _HDES4;
private String _HDES5;
private String _HDES6;
private String _HDES7;
private String _HDES8;
private String _HDES9;
private Decimal _HAMT0;
private Decimal _HAMT1;
private Decimal _HAMT2;
private Decimal _HAMT3;
private Decimal _HAMT4;
private Decimal _HAMT5;
private ISet<ProddataDAO> _proddataRecs;
[NHibernate.Mapping.Attributes.CompositeId(0)]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HCONO", Column = "HCONO")]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HDVNO", Column = "HDVNO")]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HCUST", Column = "HCUST")]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HJBNO", Column = "HJBNO")]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HSJNO", Column = "HSJNO")]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HDTTK", Column = "HDTTK")]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HNUM0", Column = "HNUM0")]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HDES2", Column = "HDES2")]
[NHibernate.Mapping.Attributes.KeyProperty(1, Name="HDSCD", Column = "HDSCD")]
[NHibernate.Mapping.Attributes.Property(2)]
public virtual Decimal HCONO
{
get
{
return _HCONO;
}
set
{
_HCONO = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HDVNO
{
get
{
return _HDVNO;
}
set
{
_HDVNO = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HCUST
{
get
{
return _HCUST;
}
set
{
_HCUST = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HJBNO
{
get
{
return _HJBNO.Trim();
}
set
{
_HJBNO = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HSJNO
{
get
{
return _HSJNO.Trim();
}
set
{
_HSJNO = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HDTTK
{
get
{
return _HDTTK;
}
set
{
_HDTTK = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HNUM0
{
get
{
return _HNUM0;
}
set
{
_HNUM0 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES2
{
get
{
return _HDES2.Trim();
}
set
{
_HDES2 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HDSCD
{
get
{
return _HDSCD;
}
set
{
_HDSCD = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HSTAT
{
get
{
return _HSTAT.Trim();
}
set
{
_HSTAT = value;
}
}
[NHibernate.Mapping.Attributes.Property(1)]
public virtual Decimal HSEQ
{
get
{
return _HSEQ;
}
set
{
_HSEQ = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HDTBG
{
get
{
return _HDTBG;
}
set
{
_HDTBG = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HDTEN
{
get
{
return _HDTEN;
}
set
{
_HDTEN = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDESC
{
get
{
return _HDESC.Trim();
}
set
{
_HDESC = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HKEY0
{
get
{
return _HKEY0;
}
set
{
_HKEY0 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HKEY1
{
get
{
return _HKEY1;
}
set
{
_HKEY1 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HKEY2
{
get
{
return _HKEY2;
}
set
{
_HKEY2 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HKEY3
{
get
{
return _HKEY3;
}
set
{
_HKEY3 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HKEY4
{
get
{
return _HKEY4;
}
set
{
_HKEY4 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HKEY5
{
get
{
return _HKEY5;
}
set
{
_HKEY5 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HNUM1
{
get
{
return _HNUM1;
}
set
{
_HNUM1 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HNUM2
{
get
{
return _HNUM2;
}
set
{
_HNUM2 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HNUM3
{
get
{
return _HNUM3;
}
set
{
_HNUM3 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HNUM4
{
get
{
return _HNUM4;
}
set
{
_HNUM4 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HNUM5
{
get
{
return _HNUM5;
}
set
{
_HNUM5 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES0
{
get
{
return _HDES0.Trim();
}
set
{
_HDES0 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES1
{
get
{
return _HDES1.Trim();
}
set
{
_HDES1 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES3
{
get
{
return _HDES3.Trim();
}
set
{
_HDES3 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES4
{
get
{
return _HDES4.Trim();
}
set
{
_HDES4 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES5
{
get
{
return _HDES5.Trim();
}
set
{
_HDES5 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES6
{
get
{
return _HDES6.Trim();
}
set
{
_HDES6 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES7
{
get
{
return _HDES7.Trim();
}
set
{
_HDES7 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES8
{
get
{
return _HDES8.Trim();
}
set
{
_HDES8 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual String HDES9
{
get
{
return _HDES9.Trim();
}
set
{
_HDES9 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HAMT0
{
get
{
return _HAMT0;
}
set
{
_HAMT0 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HAMT1
{
get
{
return _HAMT1;
}
set
{
_HAMT1 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HAMT2
{
get
{
return _HAMT2;
}
set
{
_HAMT2 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HAMT3
{
get
{
return _HAMT3;
}
set
{
_HAMT3 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HAMT4
{
get
{
return _HAMT4;
}
set
{
_HAMT4 = value;
}
}
[NHibernate.Mapping.Attributes.Property]
public virtual Decimal HAMT5
{
get
{
return _HAMT5;
}
set
{
_HAMT5 = value;
}
}
[NHibernate.Mapping.Attributes.Set(0, Name = "ProdDataRecs", Table = "ProddataDAO", Generic = true, Inverse = false)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HCONO", PropertyRef = "PCONO", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HDVNO", PropertyRef = "PDVNO", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HCUST", PropertyRef = "PCUST", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HJBNO", PropertyRef = "PJBNO", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HSJNO", PropertyRef = "PSJNO", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HDTTK", PropertyRef = "PDTTK", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HNUM0", PropertyRef = "PTKNO", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HDES2", PropertyRef = "PWKAR", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.Key(1, Column = "HDSCD", PropertyRef = "PTSID", OnDelete = NHibernate.Mapping.Attributes.OnDelete.NoAction)]
[NHibernate.Mapping.Attributes.OneToMany(2, ClassType = typeof(ProddataDAO) /*, Class = "WTS.Data.DB2.CGC.ProddataDAO, WTSCGCDAL"*/)]
[NHibernate.Mapping.Attributes.Property(3)]
public ISet<ProddataDAO> ProddataRecs
{
get
{
return _proddataRecs;
}
set
{
_proddataRecs = value;
}
}
public override bool Equals(object obj)
{
if (obj == null)
return false;
HeaderDAO h = obj as HeaderDAO;
if (this.HCONO == h.HCONO && this.HDVNO == h.HDVNO && this.HCUST == h.HCUST && this.HDTTK == h.HDTTK &&
this.HDSCD == h.HDSCD && this.HNUM0 == h.HNUM0 && this.HJBNO == h.HJBNO && this.HSJNO == h.HSJNO && this.HDES2 == h.HDES2)
return true;
else
return false;
}
public override int GetHashCode()
{
int hash = 1122;
hash += (null == this.HCONO ? 0 : this.HCONO.GetHashCode());
hash += (null == this.HDVNO ? 0 : this.HDVNO.GetHashCode());
hash += (null == this.HCUST ? 0 : this.HCUST.GetHashCode());
hash += (null == this.HDTTK ? 0 : this.HDTTK.GetHashCode());
hash += (null == this.HJBNO ? 0 : this.HJBNO.GetHashCode());
hash += (null == this.HSJNO ? 0 : this.HSJNO.GetHashCode());
hash += (null == this.HDSCD ? 0 : this.HDSCD.GetHashCode());
hash += (null == this.HNUM0 ? 0 : this.HNUM0.GetHashCode());
hash += (null == this.HDES2 ? 0 : this.HDES2.GetHashCode());
return hash;
}
}