-->
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: Do I have to save nested objects?
PostPosted: Wed May 11, 2005 5:26 pm 
Regular
Regular

Joined: Sun Nov 07, 2004 3:39 pm
Posts: 77
I'm sure I shouldn't be trying to do this late at night, and should wait for the clarity of daylight, but anyway...

I'm using Hibernate with Struts in a web application. I have an Order class which contains a Customer object as a property. In my app, I gather the details of the Order on an HTML form, which is then used to populate a form bean. This form bean is then used to construct the Order object which is stored in the database. Now, unless I construct a Customer object and assign it to the Order as part of this process, my order ends up without a customer. But if I do so, I get an error:

org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: testing.om.Customer

But I don't want to save the customer - no changes could have taken place with it, and all I really need is its ID property which Hibernate uses. I don't have or require any cascading between order and customer. This is from the Order mapping:

<many-to-one
name="customer"
class="testing.om.Customer"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="customer_id"
/>

Is there some way I can just use the ID and be done with it? Or do I need to load the existing Customer from the database and use that?


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.