How do I allow a record ID to be updated with JPA and EclipseLink?
The following exception is thrown when I try to update the ID:
Caused by: Exception [EclipseLink-7251] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException Exception Description: The attribute [idnotificacaoTipoEnvio] of class [br.com.ko.NotificacaoTipoEnvio] is mapped to a primary key column in the database. Updates are not allowed.
The attribute is mapped as follows:
@Id
@Basic(optional = false)
@NotNull
@Column(name = "idnotificacao_tipo_envio")
private Integer idnotificacaoTipoEnvio;
The method that does the update is as follows:
public void edit(T entity) {
getEntityManager().getTransaction().begin();
getEntityManager().merge(entity);
getEntityManager().getTransaction().commit();
}