-->
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.  [ 1 post ] 
Author Message
 Post subject: Older schema and column value of 0 means null?
PostPosted: Tue Oct 18, 2005 3:33 pm 
Beginner
Beginner

Joined: Sat Apr 17, 2004 1:11 am
Posts: 36
I have a Component class that can have SubComponents. I'm inheriting an old schema and it appears that a Component that has a ParentId of 0 instead of null means that it has no parent. I get an exception when it tried to load a Component with an Id of 0:

Code:
Unhandled Exception: NHibernate.UnresolvableObjectException: No
row with the given identifier exists: 0, of class: BOM.Component
   at NHibernate.Impl.SessionImpl.InternalLoad(Type clazz, Object id)


All I'm doing is attempting to load a Component that has a ParentId of 0. Is there a way that I'm missing to specify that a value of 0 or whatever is equivalent to null so that it doesn't try to load an object with that Id?

My mapping:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo">
  <class name="BOM.Component, BOM" table="COMPONENTS">
    <id name="_Id" type="Int32" column="ComponentId" access="field">
      <generator class="assigned" />
    </id>
    <many-to-one name="Parent" column="ParentId" class="BOM.Component, BOM" />
    <property name="Description" column="ComponentDescription" type="String" />
    <many-to-one name="TypeCode" column="TypeCode" class="BOM.TypeCode, BOM" />
    <property name="DataTypeValue" column="DataTypeValue" type="Int32" />
    <property name="KeyIndicator" column="KeyInd" type="Int32" />
    <bag name="AssetComponents" inverse="true">
      <key column="ComponentId" />
      <one-to-many class="BOM.AssetComponent, BOM" />
    </bag>
    <bag name="AssetStickyComponents" inverse="true">
      <key column="COMPONENTID" />
      <one-to-many class="BOM.AssetStickyComponent, BOM" />
    </bag>
    <bag name="KeyAssetStickyComponents" inverse="true">
      <key column="KEYCOMPONENTID" />
      <one-to-many class="BOM.AssetStickyComponent, BOM" />
    </bag>
    <bag name="SubComponents" inverse="true" >
      <key column="ParentId"/>
      <one-to-many class="BOM.Component, BOM" />
    </bag>
  </class>
</hibernate-mapping>


Thx...

benster


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

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.