4
How do I allow updating the ID of a record 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 like this:
public void edit(T entity) {
getEntityManager().getTransaction().begin();
getEntityManager().merge(entity);
getEntityManager().getTransaction().commit();
}
Could inform the case that gave error, I mean the construction of the object that was edited through the method
edit
.– Wakim