I'm learning NHibernate and hoping you guys could help me a bit about Tag Cloud design and solutions.
I have 3 tables which are "News", "Tags" and "News_Tags" with Many-To-Many relationship and the "News_Tags" is the link table.
Options:
cascade="all", cascade="all-delete-orphan" If I delete one of the news records, the it will delete all my news records which have the same tags.
cascade="save-update" It works with save and update, but if I try to delete news it will give the error: deleted object would be re-saved by cascade (remove deleted object from associations)
Here is my mappings:
Tags:
<class name="Tag" table="Tags" lazy="false">
<id name="TagID">
<generator class="identity" />
</id>
<property name="TagName" type="String"></property>
<property name="DateCreated" type="DateTime"></property>
<!--inverse="true" has been defined in the "News mapping"-->
<set name="NewsList" table="New_Tags" lazy="false" cascade="all">
<key column="TagID" />
<many-to-many class="New" column="NewID" />
</set>
</class>
News:
<class name="New" table="News" lazy="false">
<id name="NewID">
<generator class="identity" />
</id>
<property name="Title" type="String"></property>
<property name="Description" type="String"></property>
<set name="TagsList" table="New_Tags" lazy="false" inverse="true" cascade="all">
<key column="NewID" />
<many-to-many class="Tag" column="TagID" />
</set>
</class>
Can anyone provide some solutions for this? @Lck mentioned I could do this manually, can anyone provide some code sample for me? Thank you very much.