jasmina wrote:
Hi,
I have a table with primary key as integer and auto generated
When I try to save into this table, by using getHibernateTenplate.save.... method,
the errro thrown is
One or more records you are trying to insert or update is already present in the database table.
This is kind of wierd becasue the primary key is auto generated and I am passing a null value while saving it. I have also tried to send -1 instead of null.
Still no luck.
Thanks
Jasmina
What generator-class are you using to generate the id? Posting your mapping-file would help us very musch because we wouldn't have to guess at your configuration.
My guess is that you're using generator="increment" which works fine in a singletreaded environment but will surely fail when running a multithreaded application (because increment isn't threadsafe). You'll have to use something like hilo, native, sequence,.... instead.