views:

36

answers:

1

Hi all

I have a mapping file

<set name="Friends" table="Friends">
  <key column="UserId"/>
  <many-to-many class="User" column="FriendId"/>
</set>

I would like to specify extra columns for the friend table this creates.

For example Approve (the user must approve the friend request)

Is there a easy way?

And update

    <?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping namespace="MyVerse.Domain" assembly="MyVerse.Domain" xmlns="urn:nhibernate-mapping-2.2">
  <class name="User" table="[User]" lazy="true">
    <id name="Id" type="Guid">
      <generator class="guid" />
    </id>
    <property name="DateCreated" type="DateTime" not-null="true" />
    <property name="Deleted" type="Boolean" not-null="true" />
    <property name="Firstname" type="String" length="100" not-null="true" />
    <property name="Lastname" type="String" length="100" not-null="true" />
    <bag name="Friends" table="[Friend]">
      <key column="UserId"/>
      <many-to-many class="Friend" column="FriendId"/>

    </bag>

  </class>
  <class name="Friend" table="[Friend]" lazy="true">
    <id name="Id" type="Guid">
      <generator class="guid" />
    </id>
    <property name="DateCreated" type="DateTime" not-null="true" />
    <property name="Approved" type="Boolean" not-null="true" />
  </class>
</hibernate-mapping>

Will cause a link to the friend table from the friend table

+1  A: 

If a set has "extra properties", you must convert it into a proper entity.

So, a User doesn't have an ISet<User>; it has an ISet<Friend>.

Diego Mijelshon
But then what would the friend class look like? Users can have Users as friends
jack
Update the post
jack
All that really needs to happy is that the Friend table has to have a Approved boolean column
jack