-->
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.  [ 5 posts ] 
Author Message
 Post subject: Three tables in a one-to-one chain valid?
PostPosted: Fri Jun 25, 2004 12:24 pm 
Beginner
Beginner

Joined: Mon Nov 03, 2003 11:48 pm
Posts: 29
I have three tables:
parent, child, grandchild. The Parent has a 1to1 to Child. The Child has a 1to1 to Grandchild. So all three tables share the same primary key using Identity generation on the Parent and foreign generation on Child and Grandchild. Is this configuration possible within hibernate. I know it seems silly, but this structure makes sense for the types of data we are dealing with. (Esp for using lazy)
--Angus


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 1:34 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I should work and it make sense. Be sure to understand http://www.hibernate.org/162.html however

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2004 12:06 pm 
Beginner
Beginner

Joined: Mon Nov 03, 2003 11:48 pm
Posts: 29
I have read this page. To get the save and delete to work I have:
parent:
Code:
   <class
        name="org.guidestar.uk.fin.hibernate.FinHeader"
        table="fin_header"
        proxy="org.guidestar.uk.fin.hibernate.FinHeader"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="tarId"
            column="tar_id"
            type="java.lang.Integer"
            unsaved-value="null"
        >
            <generator class="identity">
            </generator>
        </id>

        <one-to-one
            name="finBalSheetAsset"
            class="org.guidestar.uk.fin.hibernate.FinBalSheetAsset"
            cascade="all"
            outer-join="false"
            constrained="false"
        />


Child:
Code:

   <class
        name="org.guidestar.uk.fin.hibernate.FinBalSheetAsset"
        table="fin_bal_sheet_assets"
        proxy="org.guidestar.uk.fin.hibernate.FinBalSheetAsset"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="tarId"
            column="tar_id"
            type="java.lang.Integer"
        >
            <generator class="foreign">
                <param name="property">finHeader</param>
            </generator>
        </id>
        <one-to-one
            name="finHeader"
            class="org.guidestar.uk.fin.hibernate.FinHeader"
            cascade="none"
            outer-join="false"
            constrained="true"
        />



Right now I can do the full select, insert, update, delete.
Are you saying I need to set the constrained on the parent to true as well? When I tried this I get an error:
Code:
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: org.guidestar.uk.fin.hibernate.FinBalSheetAsset.finHeader
   at net.sf.hibernate.impl.SessionImpl.checkNullability(SessionImpl.java:1276)
   at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1244)
   at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1172)
   at net.sf.hibernate.engine.Cascades$1.cascade(Cascades.java:61)
   at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
   at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
   at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:482)
   at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1260)
   at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1172)
   at org.guidestar.database.dm.HibernateDataManager.deleteObj(HibernateDataManager.java:304)


I would love to see a simple example for 1to1, lazy loaded, identy generation on parent, using the parent's key on the child.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2004 12:10 pm 
Beginner
Beginner

Joined: Mon Nov 03, 2003 11:48 pm
Posts: 29
forgot to mention that, yes, I do have the key column set to not-null
--Angus


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 09, 2004 8:47 am 
Newbie

Joined: Mon Jun 07, 2004 9:08 am
Posts: 5
I would also like to see an example of creating a new instance of a class where there is a lazy loaded 1-1 with parent key generation.

Is this even possible?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.