Hibernate, alter identifier/primary key

Posted by Schildmeijer on Stack Overflow See other posts from Stack Overflow or by Schildmeijer
Published on 2009-04-09T14:20:40Z Indexed on 2010/03/28 20:43 UTC
Read the original article Hit count: 216

Filed under:

I receive the following exception when Im trying to alter my @ID in an @Entity.

identifier of an instance of com.google.search.pagerank.ItemEntity was altered from 1 to 2.

I know that im altering the primary key in my table. Im using JPA-annotations.

I solved this by using this single HQL query: update Table set name=:newName where name=:oldName

instead of using the more oo approach:

beginTransaction();
T e = session.load(...);
e.setName(newName);
session.saveOrUdate(e);
commit();

Any idea what the diff is?

© Stack Overflow or respective owner

Related posts about hibernate