Hi, at first i'm really new to ORM, nhibernate and FHN. i look into this stuff for a few days now. i have an existing database with 4 tables:
so i tried first to get the Auswahl and RefAuswahlFilter to work.
here are my DomainObjects: pls let me know when i can do this better
[Serializable]
public class Auswahl
{
public Auswahl()
{
this.RefFilters = new List<RefAuswahlFilter>();
}
public virtual IList<RefAuswahlFilter> RefFilters { get; set; }
//...rest of the Properties
[Serializable]
public class RefAuswahlFilter
{
public virtual Auswahl Auswahl { get; set; }
public virtual long Filterrank { get; set; }
public virtual string Filter { get; set; }
here are my mappings:
public class AuswahlMap : ClassMap<Auswahl>
{
public AuswahlMap()
{
Table("AUSWAHL");
Id(x => x.Id)
.GeneratedBy.Sequence("SEQ_AUSWAHL");
Map(x => x.Programm);
Map(x => x.Variante);
Map(x => x.Returnkey);
Map(x => x.Beschreibung);
HasMany<RefAuswahlFilter>(x => x.RefFilters);
}
}
public class RefAuswahlFilterMap : ClassMap<RefAuswahlFilter>
{
public RefAuswahlFilterMap()
{
Table("REFAUSWAHLFILTER");
CompositeId()
.KeyReference(x => x.Auswahl,"IDAUSWAHL")
.KeyProperty(x => x.Filterrank,"FILTERANK");
Map(x => x.Filter);
}
}
if i run my app i got a list with all my Auswahl rows.
var l = session.CreateCriteria(typeof(Auswahl)).List<Auswahl>();
but when i look into an item to get the RefFilters the debugger show the following error:
innerException {"ORA-00904: \"REFFILTERS0\".\"AUSWAHL_ID\": ungültiger Bezeichner\n"}
could not initialize a collection: [ORMTest.DomainModel.Auswahl.RefFilters#1097][SQL: SELECT reffilters0_.Auswahl_id as Auswahl4_1_, reffilters0_.IDAUSWAHL as IDAUSWAHL1_, reffilters0_.FILTERANK as FILTERANK1_, reffilters0_.IDAUSWAHL as IDAUSWAHL3_0_, reffilters0_.FILTERANK as FILTERANK3_0_, reffilters0_.Filter as Filter3_0_ FROM REFAUSWAHLFILTER reffilters0_ WHERE reffilters0_.Auswahl_id=?]
so i think something on my mapping is wrong, but i really dont get it.
thx.