views:

71

answers:

2

Hi. A have this mapping:

mapping.HasManyToMany(x => x.SubVersions).ParentKeyColumn("ParentId").ChildKeyColumn("SubVersionId").Table( "VersionLinks");

This will create a table VersionLinks with 2 columns(ParentId,SubVersionId). Is it possible to have in this table another column (ex. CreateDate) that will be filled automaticly (DateTiem.Now) without creating a new entity VersionLink with fields Parent, SubVersion, Date?

+1  A: 

You could try to create the new CreateDate column manually with a default getdate() value, but I'd just create a new entity for VersionLink and convert the many-to-many to many-to-ones

Mauricio Scheffer
A: 

For auto updating the date property, take a look at using the IPreUpdateEventListener.

As for the mapping table, I'm pretty sure you're stuck with having to create a composite-element. I had a similar issue where I wanted to add sort and weight columns. I ended up with the following mapping:

<bag
  name="criteria"
  access="field"
  table="assessment_criterion_map"
  fetch="subselect"
  cascade="save-update">
  <key column="assessment_id"/>
  <composite-element class="WeightedCriterion">
    <parent name="assessment"/>
    <many-to-one
      class="Criterion"
      name="criterion"
      access="field"
      column="criterion_id"
      cascade="save-update"
      fetch="join"/>
    <property name="Weight"/>
    <property name="SortOrder" column="sort_order"/>
  </composite-element>
</bag>
Michael Valenty