I am using version 1.2.0.
Here is the hbm.xml file ...
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Core" assembly="Core" >
<class name="TestEntity" table="TestEntity">
<id name="Id">
<column name="TestEntityId" not-null="true" />
<generator class="guid.comb" />
</id>
<property name="Name">
<column name="Name" not-null="true" />
</property>
<property name="CreatedBy">
<column name="CreatedBy" not-null="true" />
</property>
<property name="CreatedOn">
<column name="CreatedOn" not-null="true" />
</property>
<property name="ModifiedBy">
<column name="ModifiedBy" not-null="false" />
</property>
<property name="ModifiedOn">
<column name="ModifiedOn" not-null="false" />
</property>
</class>
</hibernate-mapping>
Here is the interface ...
Code:
namespace Core
{
public interface IPersistenceMetaData
{
string CreatedBy { get; set; }
DateTime CreatedOn { get; set; }
string ModifiedBy { get; set; }
DateTime? ModifiedOn { get; set; }
}
}
Here is the abstract base class ...
Code:
namespace Core
{
public abstract class EntityBase : IPersistenceMetaData
{
private Guid id;
private string createdBy;
private DateTime createdOn;
private string modifiedBy;
private DateTime? modifiedOn;
public virtual Guid Id
{
get { return this.id; }
set { this.id = value; }
}
#region IPersistenceMetaData Members
string IPersistenceMetaData.CreatedBy
{
get { return this.createdBy; }
set { this.createdBy = value; }
}
DateTime IPersistenceMetaData.CreatedOn
{
get { return this.createdOn; }
set { this.createdOn = value; }
}
string IPersistenceMetaData.ModifiedBy
{
get { return this.modifiedBy; }
set { this.modifiedBy = value; }
}
DateTime? IPersistenceMetaData.ModifiedOn
{
get { return this.modifiedOn; }
set { this.modifiedOn = value; }
}
#endregion
}
}
Here is the test entity class ...
Code:
namespace Core
{
public class TestEntity : EntityBase
{
private string name;
public TestEntity()
{
}
public TestEntity(string name)
{
this.name = name;
}
public virtual string Name
{
get { return this.name; }
set { this.name = value; }
}
}
}