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: one-to-one does not work in self referencing object
PostPosted: Fri Apr 18, 2008 2:16 pm 
Regular
Regular

Joined: Fri Feb 18, 2005 3:34 am
Posts: 88
Location: Poland/Wrocław
In my self referencing object scenario the one-to-one properties do not get reflected in database (no appropriate columns are there). What's amazing to me - the criteria queries with criteria "IsNull" on such property does not produce errors... I am using NH 1.2. Please help me with this - I have no idea about it. Being honest I am using one-to-one relationship very seldom. Maybe because I've never been satisfied with the way it works (i.e. lazy loading).

Following is the mapping of my scenario:

Code:
   <class name="Task">
      <id name="Id">
         <generator class="native" />
      </id>

      <property name="TaskState" not-null="true" />
      <one-to-one name="Previous" lazy="proxy" />
      <one-to-one name="Next" lazy="proxy" />

      <joined-subclass name="...">
         <key column="`TASK_ID`" />
                        . . .
      </joined-subclass>

      <joined-subclass name="...">
         <key column="`TASK_ID`" />
                        . . .
      </joined-subclass>
   </class>

_________________
Please rate this post if you've found it helpfull
Roland


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 19, 2008 1:59 am 
Regular
Regular

Joined: Fri Feb 18, 2005 3:34 am
Posts: 88
Location: Poland/Wrocław
[For those who might find it usefull]

I think I can answer to myself. Changing from one-to-one relationship to many-to-one provides mea proper scenario implementation. The point is that the key referensing to the same table implements in fact such a scenario. there may be many rows referencing just one particular.

Moreover there is no way to implement one-to-one relashion between two entities without affecting two tables, is there? It would require to manage triggers or other mechanisms during inserts to check the relationship quantity. NH simply offers one-to-one mapping relashion between two entities.

There is a philosophical question, however. How often the one-to-one relationship can be usefull regarding the limitation (or specification). At least for this particular scenario it is not usefull.

_________________
Please rate this post if you've found it helpfull
Roland


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.