-->
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: Constructing entity relationships with ids vs. refs...
PostPosted: Fri Oct 24, 2008 12:14 pm 
Newbie

Joined: Sat Aug 04, 2007 6:07 pm
Posts: 6
I often find myself constructing "fake" entity objects just to hold the id of the entity so that I can create an dependent entity... i.e.. I often have the id of an object but the object isn't in the session and there's no reason to load it.

e.g. Supposed I already know the customerId but don't have the Customer entity handy... There isn't really a need to read it in from the DB just to create a dependent entity (e.g. Order)

Customer fakeCustomer = new Customer();
fakeCustomer.setId( customerId );
Order order = new Order( fakeCustomer, ... )
saveOrUpdate( order ), etc...

I find myself doing this a lot (especially with web services) and I'm wondering if there isn't some cleaner way in Hibernate to accomplish this. It seems like this comes up often enough that Hib should give you a way to do this explicitly...


thanks,
Pat


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.