-->
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: Is <key not-null="true" ... /> available?
PostPosted: Thu Sep 22, 2005 12:19 am 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
I am having a <list> relationship with one-to-many, like this:
Code:
<class name="Vector" table="VECTORS">
      <jcs-cache usage="read-write"/>
      <id name="DataID" column="ID" type="Int64" unsaved-value="0">
            <generator class="sequence">
                <param name="sequence">EQ.APP_SEQ</param>
            </generator>
      </id>
      <property name="Name" column="NAME" type="AnsiString" length="30"  access="field"/>
      <property name="LineColor" column="LINE_COLOUR" type="AnsiString" length="30" access="field"/>
      <property name="LineStyle" column="LINE_STYLE" type="AnsiString" length="30"  access="field"/>
      <property name="PointStyle" column="POINT_STYLE" type="AnsiString" length="30" access="field"/>
      <list name="Algorithms" table="INVOKED_ALGORITHMS" lazy="true" access="field" cascade="all">
         <jcs-cache usage="read-write" />
         <key column="VCTR_ID"/>
         <index column="EXECUTION_ORDER" type="Int32" length="1"/>
         <one-to-many class="InvokedAlgorithm" />
      </list>   
   </class>


The class InvokedAlgorithm is the class mapped to the same table "INVOKED_ALGORITHMS", with a ID column mapped to it's <id>

When removing a child from the list of "Algorithms", NHibernate actually update the left records' column of VCTR_ID & EXECUTION_ORDER to null first, then re-set them back with EXECUTION_ORDER has new value. For the 2 columns in our table is not nullable, this 2-step modifying causes problem in my case.

Why don't NHibernate just update the records with new value without doing null first?

I found a similar FAQ in Hibernate website:
http://www.hibernate.org/116.html#A7

This not-null attrb for <key> seems in Hibernate 3 only? Will it prevent Hibernate to set the column to null first then set it back?

How about <index>? Shall it have a "not-null" also?


Top
 Profile  
 
 Post subject: I really need help for this one.
PostPosted: Thu Sep 22, 2005 12:02 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
The Parent-Child relation ship set in our database is not allow a child with no parent, that means the <key> column cannot be nullable. And I think this is a very common contrain many systems have.

But with this case, the NHibernate always try to break the relationship by setting the parent_id column to null first before deleting. This has driven our DBA crazy, he won't allow to set the column nullable, cause he think it breaks the data integrety. Although I explain him NHibernate handle this two steps in one transaction, it won't be a problem.

But Still, I'd like to have the <key not-null.....> attribute so that NHibernate can know what to do when deleting a child of <list>

Not just deleting, for insert in a <list> relationship, NHibernate update the rows to null and then update to the new index number. Don't you guys think its in-efficient? why not just update in the first shot.


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.