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: Does NHibernate always Update the full Graph on Update?
PostPosted: Wed Aug 26, 2009 11:27 am 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
Hello,

Just stumbled about a little problem:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Continental.SignalList.Domain" namespace="Continental.SignalListManager.Domain">
  <class name="SignalList" table="SL_SIGNALLIST" lazy="false" optimistic-lock="version" >
   <id name="SignalListId" column="ID_SIGNALLIST" type="Decimal">
     <generator class="sequence">
      <param name="sequence">SL_SIGNALLIST_SEQ</param>
     </generator>
   </id>
   <version column="NH_VERSION" name="NhVersion" />
   <property name="Description" type="String" column="DESCRIPTION" />
   <component class="SignalCollection" name="Signals">
     <many-to-one class="SignalList" name="SignalList" column="CollectionSignalList" foreign-key="fk_ColSignalList_SignalList"/>
     <bag name="Signals" table="SL_SIGNAL" lazy="false" cascade="all-delete-orphan" inverse="true">
      <key column="ID_SIGNALLIST" />
      <one-to-many class="Signal" />
     </bag>
   </component>
  </class>
</hibernate-mapping>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Continental.SignalList.Domain" namespace="Continental.SignalListManager.Domain">
  <class name="Signal" table="SL_SIGNAL" lazy="true">
   <id name="SignalId" column="ID_SIGNAL" type="Decimal">
     <generator class="sequence">
      <param name="sequence">SL_SIGNAL_SEQ</param>
     </generator>
   </id>
   <version column="NH_VERSION" name="NhVersion"/>
   <many-to-one class="SignalList" column="ID_SIGNALLIST" name="SignalList"  foreign-key="fk_Signal_SignalList"/>
   <property name="PinNumber" type="String" column="PIN_NUMBER" />
   <property name="ContiTevesName" type="String" column="CONTI_TEVES_NAME" />
  </class>
</hibernate-mapping>


This is the mapping of my SignalList class. It holds another class called SignalCollection implementing the IList<Signal> Interface. It's named "Signals" in this mapping file. This class holds the mechanism to add the Signal to the internal List (also named "Signals") and to update the added signals SignalList.

Something Like

Code:
if(!Signals.Contains(item))
{
  item.SignalList = SignalList;
  Signals.Add(item);
}


If I call update on a detached object where I just changed the Description of a SignalList, it also updates all the Childs in the Signals Collection.
Does NHibernate always update ALL reattached objects? Or can't NHibernate determine if an Object is dirty, because it was detached from a session?
At the moment this is no big problem, because objects are very small. But I think this can get a real issue if NHibernate tries to update thousand of records just because you changed one String.

Thanks for your help :)

Reflection

P.S.: I wouldn't mind either if anybody would have a better solution for the Collection Component :)


Top
 Profile  
 
 Post subject: Re: Does NHibernate always Update the full Graph on Update?
PostPosted: Wed Aug 26, 2009 12:04 pm 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
Also started the thread here:

http://groups.google.de/group/nhusers/b ... 4b2?hl=de#

As I just saw that this forum isn't used anymore.


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.