-->
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.  [ 1 post ] 
Author Message
 Post subject: Lazy Exception.. foreign key doesn't exist
PostPosted: Fri Mar 25, 2005 8:44 pm 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
I have a table structure like so:



Code:

   Order{

       - orderid
       - Set orderitems
       - ...

   }

with:  <set
            name="orderItems"
            lazy="true"
            inverse="true"
            > ...

-------------------------------

   OrderItem{

       - orderitemid
       - Set orderitems
       - ...

   }


with: <many-to-one
            name="item"
            class="Item"
            not-null="false"
            >
            <column name="SKU"/>
        </many-to-one>


-------------------------


   Item{

       - sku (PK)
       - Set orderitems
       - ...

   }

with:  <id
            name="sku"
            type="java.lang.String"
            column="SKU"
            >
            <generator class="assigned"/>
        </id>







When accessing the orderitems collection I get this:

net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection Caused by: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: ABC123


I have read the documentation and tried 'foreign-key' etc without any success. How can I make it 'ok' for the object to not to exist in the Item table? Or do I have to change it back to just using a String reference to SKU and then do a lookup on the ItemDao for the actually object.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.