Hi,
This should be a simple problem, but it's driving me crazy. I have a parent class with a one-to-one unidirectional association to another class. Primary keys are the same, but are assigned, so I need to set them manually in each class.
mapping in the parent class is:
<one-to one
name="child"
class="xxx.xxx.child"
cascade="all"
outer-join="auto"
</>
There is no association mapping in the child since it's unidirectional.
My problem is that when starting out both parent and child are transient. I set the child in the parent, and do a session save. Looking at the SQL, hibernate is doing an insert on the parent object, but it does an update on the child object. Since the child object is transient too, there is nothing to update and the child class isn't persisted; the SQL needs to be an insert, not an update.
Anyone have any idea how to make this work via a cascade (don't want to save each one separately).
|