-->
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 load() problem
PostPosted: Tue Oct 07, 2003 4:04 pm 
Beginner
Beginner

Joined: Fri Sep 12, 2003 12:54 pm
Posts: 20
Hi,

I've got an issue where my child entities aren't getting loaded (but save/update is working).

Here's a quick synopsis of my objects:

Code:
[Cart] --one-to-many--> [LineItem] --one-to-one--> [CartItem]

  [CartItem]  has joined-subclasses [CartCatalogItem] and [CartPunchOutItem].


The one-to-many between Cart and LineItem have cascade="all-delete-orphan" and the one-to-one between LineItem and CartItem have cascade="all".

The save() works just fine, but when I do a load() on Cart, I get the LineItems, but the CartItem in each LineItem is null.

Doen anyone have any ideas what would cause this?


The mappings looks like this:

Code:
   <class
        name="com.foo.Cart"
        table="carts_cart"
        dynamic-update="false"
        dynamic-insert="false"
    >
        <id
            name="id"
            column="cart_id"
            type="string"
            unsaved-value="null"
        >
            <generator class="uuid.hex"/>
        </id>

<SNIP> .. cart properties .. </SNIP>

        <list
            name="lines"
            lazy="false"
            inverse="false"
            cascade="all-delete-orphan"
            table="carts_line_item"
        >
              <key
                  column="cart_id"
              />
              <index
                  column="li_seq"
              />
              <one-to-many class="com.foo.LineItem"/>
        </list>
   
    </class>

==========================================

    <class
        name="com.foo.LineItem"
        table="carts_line_item"
        dynamic-update="false"
        dynamic-insert="false"
    >
        <id
            name="id"
            column="li_id"
            type="long"
            unsaved-value="-1"
        >
            <generator class="seqhilo">
              <param name="sequence">carts_line_ids</param>
              <param name="max_lo">99</param>
            </generator>
        </id>

        <one-to-one
            name="item"
            class="com.foo.CartItem"
            cascade="all"
            outer-join="auto"
            constrained="false"
        />

<SNIP> .. line item properties .. </SNIP>

    </class>

==========================================

    <class
        name="com.foo.CartItem"
        table="carts_item"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="li_id"
            type="long"
            unsaved-value="any"
        >
            <generator class="seqhilo">
              <param name="sequence">carts_item_ids</param>
              <param name="max_lo">99</param>
            </generator>
        </id>

<SNIP> .. item properties .. </SNIP>


        <joined-subclass name="com.foo.CartPunchOutItem" table="carts_po_item">
           <key column="li_id"/>
<SNIP> .. punch-out item properties .. </SNIP>
        </joined-subclass>          
          
        <joined-subclass name="com.foo.CartCatalogItem" table="carts_cat_item">
           <key column="li_id"/>
<SNIP> .. catalog item properties .. </SNIP>
        </joined-subclass>          
          

    </class>




I can see from Hibernate's logging that it is doing a valid query with left-outer-joins to get the CartItem (CartCatalogItem/CartPunchOutItem) data, yet the object isn't populated...

help appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 4:33 pm 
Beginner
Beginner

Joined: Fri Sep 12, 2003 12:54 pm
Posts: 20
Doh... I need to have the CartItem share the same Id as the LineItem...


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.