cara mengatasi error "Info: updateException [EclipseLink-7251] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.ValidationException Exception Description: The attribute [] of class [.] is mapped to a primary key column in the database. Updates are not allowed."

 Exception Description: The attribute [] of class [.] is mapped to a primary key column in the database. Updates are not allowed.
Info:    updateException [EclipseLink-7251] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The attribute [] of class [.] is mapped to a primary key column in the database. Updates are not allowed.


Error di atas di sebabkan karena update tidak di ijinkan (ini bug eclipselink), solusinya adalah :

-buka presistence.xml
-tambah kode berikut :
       <property name="eclipselink.weaving.changetracking" value="true"/>
<property name="eclipselink.weaving.lazy" value="true"/>
<property name="eclipselink.weaving.eager" value="true"/>
<property name="eclipselink.weaving.fetchgroups" value="true"/>
<property name="eclipselink.weaving.internal" value="false"/>


lalu cek di entiti manager (em) pakai merge jangan persist
Ex:
em.getTransaction().begin();
  xxx t= new xxx ();
t= em.find(xxx .class, idxxx);
t.setxxxxt(idxxxx);
  em.merge(t);
entr.commit();

pastikan anotation benar :
    @MapsId("idxxxx")
    @JoinColumn(name = "idxxxx")
      @ManyToOne()
    @NotNull()
    private xxxx idxxxx;

Komentar

Postingan Populer