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
|