Hi,
This is my first post here so go easy on me!
I found this discussion very helpful as I had exactly the same problem.
My unique identifier is a string, it is assigned and I don't want it to be generated any other way.
I found a solution in the
Hibernate Users FAQ.
saveOrUpdate(), or cascade save, executes UPDATE instead of INSERT!
There are two reasons why this could occur:
The <id> element does not specify the correct unsaved-valueYou are using an assigned identifier or a composite identifier
In the first case, you should simply specify the correct unsaved-value.
In the second case, you have several choices. In Hibernate 2.1 either:
specify unsaved-value for the <version> or <timestamp> propertyimplement Interceptor.isUnsaved() and Interceptor.onSave(), as described in chapter 16 of the reference documentation
So for the above example a simple solution would be to add a timestamp element after the <id> section of the mapping file.
E.g.
Granted, this would add an additional column in the database table but at least it would now work with assigned generators.
HTH
Mark
[ February 16, 2005: Message edited by: Mr McLaren ]