-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Subclass properties always trigger update.
PostPosted: Wed May 09, 2007 5:47 am 
Newbie

Joined: Wed May 09, 2007 5:39 am
Posts: 2
Location: Glasgow, Scotland
I think I've stumbled across a bit of problem with the way NHibernate determines when things are dirty.

I have the following mapping file:

<class name="ServiceScheduleSubComponent, Application.BusinessObject" table="ServiceScheduleSubComponents">

<id name="Id" column="Id" access="nosetter.camelcase-underscore" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid"/>
</id>

<discriminator column="Type"/>

<property name="NotApplicable" column="NotApplicable" access="nosetter.camelcase-underscore"/>
<property name="RequiringVerification" column="RequiringVerification" access="nosetter.camelcase-underscore"/>
<property name="Comments" column="Comments" access="nosetter.camelcase-underscore"/>
<property name="Disabled" column="Disabled" access="nosetter.camelcase-underscore"/>

<subclass name="IntegerServiceScheduleSubComponent, Application.BusinessObject" discriminator-value="Integer">
<property name="FailCount" column="FailCount" access="nosetter.camelcase-underscore"/>
</subclass>

<subclass name="BooleanServiceScheduleSubComponent, Application.BusinessObject" discriminator-value="Boolean">
<property name="Failed" column="Failed" access="nosetter.camelcase-underscore"/>
</subclass>

</class>

Now the trouble is that in both my subclasses the fields that are specific to them are Boolean and Int32 values. Unfortunately though, in my database I need to allow both fields to be nullable. That appears to mean that when NHibernate is trying to figure out if the values are dirty it always answers yes.

Any ideas as to how get round this?


Top
 Profile  
 
 Post subject: My stupidity
PostPosted: Wed May 09, 2007 6:47 am 
Newbie

Joined: Wed May 09, 2007 5:39 am
Posts: 2
Location: Glasgow, Scotland
Apologies.

It would appear that the problem I was having was by the "Disabled" property and not the 2 on the subclass. Specifically the database column allowed NULLs and member type was simply System.Boolean. Hence NHibnerate always thought that property was null... doh!

To fix I simply update the column on the database to be NOT NULL.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.