Hi,
ich bekomme immer beim Abfragen des Inventars die Fehlermeldung "No row with the given identifier exists" und denke das ich einen Fehler in meinen Mapping Dateien habe.
Kann mir jmd sagen ob ich da nen Fehler mache? Es scheint an der Composite ID zu liegen wenn ich mich nicht irre?
Es geht um die 2 Klassen Room und Inventarobject und es gibt eine One-To-Many Beziehung von Room zu Inventarobject.
Klassen:
Room:Code:
public class Room : IEntity {
public Room() {
}
public virtual string Building { get; set; }
public virtual string Roomno { get; set; }
public virtual IList<Inventarobject> Inventarobjects { get; set; }
public override bool Equals(object obj)
{
...
}
public override int GetHashCode()
{...}
}
Inventarobject: Code:
public class Inventarobject : IEntity {
public Inventarobject() {
Archives = new List<Archive>();
Tickets = new List<Ticket>();
}
public virtual long Inveturid { get; set; }
public virtual Type Type { get; set; }
public virtual Room Room { get; set; }
public virtual IList<Archive> Archives { get; set; }
public virtual IList<Ticket> Tickets { get; set; }
}
Mappings:
Room:Code:
<class name="Room" table="ROOM" lazy="false" >
<composite-id>
<key-property name="Building" column="BUILDING" />
<key-property name="Roomno" column="ROOMNO" />
</composite-id>
<bag name="Inventarobjects" inverse="true" cascade="save-update">
<key>
<column name="BUILDING"/>
<column name="ROOMNO"/>
</key>
<one-to-many class="Inventarobject" />
</bag>
</class>
Inventarobject:Code:
<class name="Inventarobject" table="INVENTAROBJECT" lazy="false" >
<id name="Inveturid" column="INVETURID" type="long">
<generator class="identity" />
</id>
<many-to-one insert="false" column="MODELL" update="false" lazy="false" name="Type" not-null="true" class="Type">
</many-to-one>
<many-to-one insert="false" update="false" lazy="false" name="Room" not-null="true" class="Room">
<column name="ROOMNO"/>
<column name="BUILDING" />
</many-to-one>
<bag name="Archives" inverse="true" cascade="none">
<key column="INVETURID" />
<one-to-many class="Archive" />
</bag>
<bag name="Tickets" inverse="true" cascade="none">
<key column="INVETURID" />
<one-to-many class="Ticket" />
</bag>
</class>