I am using Reverse Engineering (reveng.xml file) in order to generate my hbm.xml files, but I need to set the 'unsaved-value' property for an id. Does anyone know how? It doesn't seem to be covered in the
manual.
Maybe someone could also explain why I need the
unsaved-value in my case? A Flex client sends a newly created domain object to the server. This domain object contains a Set of other domain objects. As I am using the Spring/Flex integration framework, the Flex object arrives at the server, and the Spring/Flex framework converts the Flex
int (that is used for the primary key) into a Java
Integer. As it is a Flex
int, the resultant Java
Integer has a value of
0, this is true of all the domain objects. I save the parent object, which works fine (even though it has an
Integer value of 0, and does not use the
unsaved-value parameter in the mapping file). However, when the
cascade tries to save the domain objects in the Set, it fails with a Spring
UnexpectedRollbackException. Hibernate runs an SQL
insert statement for the parent, but then tries to run an
update for the child objects (which as they haven't been saved yet, causes the exception). What is the likely cause of this behavior?