-->
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: parent-children list without inverse="true"
PostPosted: Wed Feb 02, 2005 7:33 am 
Newbie

Joined: Fri Dec 10, 2004 9:28 am
Posts: 2
I'm trying to do this :

Code:
<class name="SpecBench.CoreData.Category">
    <id name="id" type="long" access="field" unsaved-value="-1">
        <generator class="native"/>
    </id>
    <many-to-one name="parentCategory" class="SpecBench.CoreData.Category" column="parent_id"/>
    <list name="subCategories">
        <key column="parent_id"/>
        <index column="list_ndx"/>
        <one-to-many class="SpecBench.CoreData.Category"/>
    </list>
    <property name="name" column="name" type="string"/>
    <property name="description" column="description" type="string"/>
</class>

so basically, I want a category to know two things :
    - it's parent Category
    - it's sub-Categories
This is a bit different from the usual examples where the parent and children are separeted entities. Please note that I don't use the "inverse" attribute. That is, I can live without it. However, I do really need the order of the list to be persisted. So the relationship I have is clearly bidirectional, but not "inversed".

The code I use to create a few categories works fine : categories do get created and the parent-children relationships are made. Unfortunately, the index of the list (list_ndx) is not set by hibernate and this results in "null index column for collection" exception stuff.

I've checked http://www.hibernate.org/193.html but it seems to concern only people using the "inverse" attribute to improve handling of bidirectional relationships.

Where am I wrong ?

stF

Hibernate version: 2.1.8
Using Postgres 7


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 3:44 pm 
Newbie

Joined: Thu Jan 06, 2005 4:41 pm
Posts: 8
Hi.

Same problem here with Hibernate 2.1.7c and SQL Server 2000. Here's my mappings:

Code:
<hibernate-mapping package="com.invidex.videolinx.common.persistence.dto.request">

   <class name="UserRequestChangeDTO" table="User_Request_Change">

      <cache usage="read-write"/>

      <id name="id">
         <generator class="native"/>
      </id>

      <property name="status" column="status_id" not-null="true"/>

      <many-to-one name="parentUserRequest" column="user_request_id" cascade="none" not-null="true"/>

      <list name="innerChangeComments" table="User_Request_Change_Info" inverse="false" cascade="all-delete-orphan">
         <cache usage="read-write"/>
         <key column="user_request_change_id"/>
         <index column="sequence_number"/>
         <one-to-many class="UserRequestChangeCommentDTO"/>
      </list>

   </class>

</hibernate-mapping>

<hibernate-mapping package="com.invidex.videolinx.common.persistence.dto.request">

   <class name="UserRequestChangeCommentDTO" table="User_Request_Change_Info">

      <cache usage="read-write"/>

      <id name="id">
         <generator class="native"/>
      </id>

      <property name="description" column="description" not-null="true"/>
      <property name="createdBy" column="created_by" not-null="true"/>
      <property name="createdDate" column="creation_date" not-null="true"/>

   </class>

</hibernate-mapping>

And then I get this error:

[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Cannot insert the value NULL into column 'sequence_number', table 'User_Request_Change_Info'; column does not allow nulls. INSERT fails.


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.