[EclipseLink]XX is mapped to a primary key column in the database. Updates are not allowed.
问题:
Caused by: Exception [EclipseLink-7251] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The attribute [xxx] of class [xxx] is mapped to a primary key column in the database. Updates are not allowed.
at org.eclipse.persistence.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2548)
at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:1257)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildRowForUpdateWithChangeSet(ObjectBuilder.java:1768)
发生场景:
在使用Eclipse Link插入数据时, 如果对主键字段(比如ID)进行了setter 方法, 则会报上述错误。
这里的实战场景是从旧系统通过Eclipse Link 将数据进行Migrate , 具体场景可以参考:
还没有评论,来说两句吧...