I'm newbie with Nhibernate. Hope I can find the answer here. This is my class:
public class PaymentAudit : EntityBase<int>, IAggregateRoot
{
public PaymentAudit() { }
public System.Guid PaymentStateId { get; set; }
public System.DateTime DateStamp { get; set; }
public Payment Trn { get; set; }
public PaymentSaga PaymentSaga { get; set; }
public ProcessState ProcessState { get; set; }
public PublishState PublishState { get; set; }
public System.Nullable<short> ChgCount { get; set; }
public string UserName { get; set; }
protected override void Validate()
{
}
}
This is my mapping:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Praweda.Interface.Framework.Model.Payment"
assembly="Praweda.Interface.Framework.Model">
<class name="PaymentAudit" table="PaymentAudit" lazy="false" >
<composite-id>
<key-property name="PaymentStateId" column="PaymentStateId" />
<key-property name="DateStamp" column="DateStamp" />
<key-property name="ProcessState" column="ProcessState" />
</composite-id>
<id name="PaymentState">
<generator class="identity" />
<column name="PaymentStateId" sql-type="uniqueidentifier" not-null="true" />
</id>
<id name="ProcessState">
<generator class="identity" />
<column name="ProcessState" sql-type="varchar" not-null="true" />
</id>
<id name="DateStamp">
<generator class="identity" />
<column name="DateStamp" sql-type="datetime" not-null="true" />
</id>
<many-to-one insert="false" update="false" lazy="false" name="PaymentStateId">
<column name="PaymentStateId" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<property name="PaymentStateId">
<column name="PaymentStateId" sql-type="uniqueidentifier" not-null="true" />
</property>
<many-to-one insert="false" update="false" lazy="false" name="ProcessState">
<column name="ProcessState" sql-type="varchar" not-null="true" />
</many-to-one>
<property name="ProcessState">
<column name="ProcessState" sql-type="varchar" not-null="true" />
</property>
<many-to-one insert="false" update="false" lazy="false" name="PublishState">
<column name="PublishState" sql-type="varchar" not-null="false" />
</many-to-one>
<property name="PublishState">
<column name="PublishState" sql-type="varchar" not-null="false" />
</property>
<many-to-one insert="false" update="false" lazy="false" name="Trn">
<column name="Trn" sql-type="varchar" not-null="false" />
</many-to-one>
<property name="Trn">
<column name="Trn" sql-type="varchar" not-null="false" />
</property>
<property name="ChgCount">
<column name="ChgCount" sql-type="smallint" not-null="false" />
</property>
<property name="UserName">
<column name="UserName" sql-type="nvarchar" not-null="false" />
</property>
</class>
</hibernate-mapping>
When I'm trying to add the repository assembly in session factory, here's the code
Configuration config = new Configuration();
config.AddAssembly("MyProject.Nhibernate.Repository");
log4net.Config.XmlConfigurator.Configure();
config.Configure();
_sessionFactory = config.BuildSessionFactory();
give me error : The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'id' in namespace 'urn:nhibernate-mapping-2.2'.
Thanks!