pk « Field « JPA Q&A





1. Cannot Update PK field    forum.hibernate.org

Dear Sir/Madom, I have a table in which has one column as the pk. For some very special case, the pk need to change. However, when I create a session and call save(Object object, Serializable id), it throw an Exception as following. 17:33:40,447 ERROR [STDERR] net.sf.hibernate.HibernateException: identifier of an instance of com.primecreation.cxn.system.bean.HomeNetwork altered from 4 to 5 at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2141 ) at ...

2. Single field table, PK/FK and SerializationException    forum.hibernate.org

Looking for some help with the exception I'm receiving (net.sf.hibernate.type.SerializationException: could not deserialize) for a joiner table that consists of a single column that serves as the primary key and also foreign-key. The mapper file is attached below. Any suggestions or insight is greatly appreciated. Thanks, -Russ-

3. many-to-one relationship to non-PK field    forum.hibernate.org

Newbie Joined: Thu Sep 23, 2004 4:11 am Posts: 12 Location: Gold Coast, Australia Hibernate version: 2.1.6 I'm trying to declare a foreign key relationship between two entities where the type is java.lang.String and the related entity field is not a primary key but is a unique field. If I attempt the same thing, but relating to a primary key field ...

4. Updating the PK field of a table.    forum.hibernate.org

I am afraid this is not possible. Because id field is the identifier of your entity. If there is a change in the identifier field then it semantically means that the entity is different from the previous one. You wont be able to do an update of the primary key field of an existing row. But what you can do is ...