omnifaces / omnipersistence

Utilities for JPA, JDBC and DataSources
Other
31 stars 12 forks source link

The attribute [id] of class [xy] is mapped to a primary key column in the database. Updates are not allowed #30

Closed proincode closed 4 years ago

proincode commented 4 years ago

Performing a delete on an entity, fires following exception:

The attribute [id] of class [] is mapped to a primary key column in the database. Updates are not allowed.

public void delete(E entity) { if (entity.getClass().isAnnotationPresent(NonDeletable.class)) { throw new NonDeletableEntityException(entity); } else { this.getEntityManager().remove(this.manage(entity)); entity.setId((Comparable)null); } }

The exception is thrown at entity.setId((Comparable)null);

BalusC commented 4 years ago

This is a bug in EclipseLink. You should actually pass an unmanaged instance into that method.