[EclipseLink]XX is mapped to a primary key column in the database. Updates are not allowed.

Myth丶恋晨 2024-04-06 11:46 161阅读 0赞

问题

  1. Caused by: Exception [EclipseLink-7251] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
  2. Exception Description: The attribute [xxx] of class [xxx] is mapped to a primary key column in the database. Updates are not allowed.
  3. at org.eclipse.persistence.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2548)
  4. at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:1257)
  5. at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildRowForUpdateWithChangeSet(ObjectBuilder.java:1768)

发生场景

在使用Eclipse Link插入数据时, 如果对主键字段(比如ID)进行了setter 方法, 则会报上述错误。
这里的实战场景是从旧系统通过Eclipse Link 将数据进行Migrate , 具体场景可以参考:

发表评论

表情:
评论列表 (有 0 条评论,161人围观)

还没有评论,来说两句吧...

相关阅读