Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:1.0.2
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Competition.Business2.Forums.Post, Competition.Business2" table="t_forum_posts">
<id name="ID" column="PostID" type="int" unsaved-value="0">
<generator class="native" />
</id>
<property name="AddedDate" not-null="false" />
<many-to-one name="AddedBy" column="AddedBy"/>
<property name="AddedByIP" not-null="false" />
<many-to-one name="Forum" column="ForumID" not-null="false"/>
<many-to-one name="ParentPost" column="ParentPostID" not-null="false"/>
<property name="Title" not-null="false" />
<property name="Body" not-null="false" />
<property name="Approved" not-null="false" />
<property name="Closed" not-null="false" />
<property name="ViewCount" not-null="false" />
<property name="ReplyCount" not-null="false" />
<many-to-one name="LastPostBy" column="LastPostBy" not-null="false"/>
<property name="LastPostDate" not-null="false" />
</class>
</hibernate-mapping>
Good day everyone,
I've been using NHib for a little while now and I've always played around an issue I've been having since the beginning for which I cannot find a solution in the documentation. It is probably in there somewhere and my apologies if it is obvious, but I'm writing to the forum as a last resort.
So, first problem: in the previous mapping I want to make the LastPostBy and ParentPost property optional (namely nullable). The database schema allow for nulls in those fields. How do I do that? I thought that not-null would do the trick, but not. When saving the object I get a 'Value cannot be null' error (and the only null parameter is LastPostBy).
Second question: can a many-to-one parameter can be made to load lazily?
Thanks in advance for enlighting me,
Alain-Daniel