Skip to content

Instantly share code, notes, and snippets.

@scottwater
Created February 7, 2010 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottwater/297464 to your computer and use it in GitHub Desktop.
Save scottwater/297464 to your computer and use it in GitHub Desktop.
public class Post
{
public virtual int Id { get; set; }
public virtual string Title { get; set; }
public virtual string Body { get; set; }
public virtual DateTime PubDate { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="..."
namespace="...">
<class name="Post" table="Posts" >
<id name="Id">
<generator class="identity"/>
</id>
<property name="Title" not-null="true" length="256"/>
<property name="Body" not-null="true"/>
<property name="PubDate" not-null="true"/>
<set name="Tags" table="Tags" inverse="true" cascade="all-delete-orphan">
<key column="PostId" />
<one-to-many class="Tag" />
</set>
</class>
</hibernate-mapping>
public class Tag
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual Post Parent { get; set; }
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="..."
namespace="...">
<class name="Tag" table="Tags" >
<id name="Id">
<generator class="identity"/>
</id>
<property name="Name" not-null="true" length="64"/>
<many-to-one name="Parent" column="PostId" not-null="true"/>
<!--
<set name="Posts" table="Posts" >
<key column="Id"></key>
<many-to-many class="Post" column="Id"></many-to-many>
</set>
-->
</class>
</hibernate-mapping>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment