EclipseLink-7251: is mapped to a primary key column in the database. Updates are not allowed. [message #990874] |
Fri, 14 December 2012 10:39  |
Eclipse User |
|
|
|
Hi,
I have the following Entity:
public class A extends Base {
private EmbClass abcEmbClass;
@Embedded
@AttributeOverrides({ @AttributeOverride(name = "EmbClass", column = @Column(name = "ABCEMBCLASS")) })
public EmbClass getAbcEmbClass() {
return abcEmbClass;
}
}
@MappedSuperclass
public abstract class Base {
private EmbClass embClass;
@EmbeddedId
public EmbClass getEmbClass () {
if (embClass== null) {
embClass= new EmbClass();
}
return embClass;
}
}
So far so good.
Now the implementation does the following:
public A update(AVo aVo) {
A _a = aEm.find(A.class, aVo.getEmbClass());
_a.setAbcEmbClass(aVo.getAbcEmbClass)
aEm.merge(_a);
return _a;
}
The primary key EmbClass is not changed at all, only a foreign key, so why happens the following error:
Exception Description: The attribute [embClass] of class [EmbClass ] is mapped to a primary key column in the database. Updates are not allowed.
[java] at org.eclipse.persistence.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2458)
[java] at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:1214)
How can I fix this problem?
best regards,
Igor
|
|
|
|
Powered by
FUDForum. Page generated in 0.03425 seconds