Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » EclipseLink-7251: is mapped to a primary key column in the database. Updates are not allowed.
EclipseLink-7251: is mapped to a primary key column in the database. Updates are not allowed. [message #990874] Fri, 14 December 2012 10:39 Go to next message
Eclipse UserFriend
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
Re: EclipseLink-7251: is mapped to a primary key column in the database. Updates are not allowed. [message #991502 is a reply to message #990874] Wed, 19 December 2012 09:51 Go to previous message
Eclipse UserFriend
Try copying the EmbClass instance instead of reusing instances as embeddable objects are not meant to be shared. Each reference should have its own independent instance to be used to track changes.
Previous Topic:Weird problem of persist in another transaction
Next Topic:entity extensions in a secondary table
Goto Forum:
  


Current Time: Wed Jul 23 17:50:42 EDT 2025

Powered by FUDForum. Page generated in 0.03425 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top