Thank you.
I've managed to get it to work, I think the problem was two-fold.
My Value Object had identifier values which were declared as primitive type int instead of Integer, this would mean that hibernate found an id for those objects and so woudl expect them to exist, null (not set) tells hibernate that the object is a new one! - although obvisouly this isn't relevent to the Order objects.
Also in my DAO I was using session.saveOrUpdate(object) (is this what you were refering to?) changing that to session.save(object) allows the Order and any status added to the Order object before saving are then saved.
Is the fact that the orderID field is assigned in my business code the reason that the saveOrUpdate method is not working? (again hibernate cannot determine if the object is new or should already exist)
---
A slight aside that I've been pondering about at the same time (perhaps athis should be a separate post?) is the degree to which the associations should be mapped..
A rather contrived scenario, esspecially in this case, but if all our orders were related in some way via a relation table, e.g:
If we expanded out mapping to populate relations in a List<Order> on each Order this would mean that in retrieving one Order record I may end up retrieving all it's related Orders, along with all those related Order's Orders etc.
In retrieving the Order I'm interested in it seems reasonable to retrive all it's related Orders, but not necessarily all the distently related orders, the danger being that I may end up retrieving a significant portion on the Database depending on how many relations were made.
Is there any guidence on what to do here? I see the posibility of a few options:
1) Not map relations, instead provide a different was to access them, although this may mean to obtain an Order and all it's related orders two queries are required.
2) Provide a different mapping, one might return all the related orders the other might exclude related Orders, this would result in either a different Object type, or partially populated objects returned to the business and presentaion tiers.
3) Perhaps Hibernate offers some support for this - I would hope it's a common
pattern with a common solution.
4) Perhaps the datamodel is over complicating things, although I have little influence on the design of that.
[ November 21, 2008: Message edited by: Rich Peate ]