Fragment from domain classes:
Code:
namespace IDS.Domain
{
// base class
public class EventFact
{
public DateTime Time;
}
// one of parent classes
public class TrafficFact : EventFact
{
public Int32 Id;
public Process Process;
public LocalPort LocalPort;
public RemotePort RemotePort;
public RemoteAddress RemoteAddress;
public Int32 BytesSent;
public Int32 BytesReceived;
public ProtocolType ProtocolType;
public Computer Computer;
public User User;
}
}
Part of mappings:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="IDS.Domain" assembly="IDSDomain">
<class lazy="false" mutable="false" name="TrafficFact" table="Traffic_Facts">
<id access="field" name="Id" column="idFact" unsaved-value="0">
<generator class="identity" />
</id>
<property access="field" name="Time" column="tmTransfer" not-null="true"/>
<many-to-one access="field" class="Process" name="Process" column="idProcess" not-null="true"/>
<many-to-one access="field" class="LocalPort" name="LocalPort" column="idLocalPort" not-null="true"/>
<many-to-one access="field" class="RemotePort" name="RemotePort" column="idRemotePort" not-null="true"/>
<many-to-one access="field" class="RemoteAddress" name="RemoteAddress" column="idRemoteAddress" not-null="true"/>
<property access="field" name="BytesSent" column="bytesSent" not-null="true"/>
<property access="field" name="BytesReceived" column="bytesReceived" not-null="true"/>
<many-to-one access="field" class="ProtocolType" name="ProtocolType" column="idProtocolType" not-null="true"/>
<many-to-one access="field" class="Computer" name="Computer" column="idComputer" not-null="true"/>
<many-to-one access="field" class="User" name="User" column="idUser" not-null="true"/>
</class>
</hibernate-mapping>
You can see that table-per-concrete class inheritance mapping is used.
Fisrt query succeeded, second one returned an exception:
"in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [FROM EventFact]"
Code:
ICriteria crit = project.Session.CreateCriteria(typeof(EventFact));
crit.List();
IQuery query = project.Session.CreateQuery("FROM EventFact");
uery.List();
sergey wrote:
You have an error on line 33 of your application!
Seriously, it should work but how can we know why it doesn't? Give us details.