Hi,
I'm not sure if this will help, but maybe you could try to test your code in a simple program, like this:
Session s=//get Hibernate session
Criteria c=s.createCriteria(Object.class);
//pk is whatever the key is for your table, 'key' is a valid key
c.add(Expression.eq("pk",key));
Object object=c.list().iterator().next();
object.setWhatever(...);//update something
s.update(object);
s.flush();
If this simple code works, it could be that you're closing Hibernate session somewhere in your original code, and then you re-open it, so the object reference is not in session (primary key will not help you then), so Hibernate thinks it's an insert.
HTH,
Bratek
|