1

So I'm trying to update an object called Alumno, this is the class:

 public class Alumno extends Persona {

 private Alumno alumno;


 private List<String> telefonos;


 private List<Asignatura> asignaturas;

And this is class "Asignatura"

public class Asignatura {

 private String alias;


 private String nombre;


 private Long curso;


 private Profesor profesor;


 private List<Alumno> alumnos;

And when I try to update an object "Alumno" I get this error:

[ObjectDB 2.8.1] javax.jdo.JDOUserException Object 'Modelo.Asignatura.Asignatura#'PGL'' belongs to another EntityManager [Asignatura:'PGL'] (error 634)

Any idea on how to solve this? Thank you very much.

David Díaz
  • 89
  • 4
  • 15

1 Answers1

0

This error message indicates mixing entity objects of different EntityManager instances.

Every EntityManager instance represents a separate connection to the database with a separate and isolated "persistence context", which is the set of objects in memory that represent entity objects in the database.

If you retrieve an entity object in one EntityManager you are not allowed to link it to entity objects in another EntityManager instance (e.g. using references from another entity object of another EntityManager).

ObjectDB
  • 1,312
  • 8
  • 9
  • Thank you for the answer. So I can't persist an object with a list of objects from another entity? – David Díaz Feb 01 '20 at 11:56
  • I fixed that. Now I get this error when I try to update the object "Alumno" with a new list of "Asignatura" Attempt to reuse an existing primary key value (Modelo.Asignatura.Asignatura:'ETS') (error 642) – David Díaz Feb 01 '20 at 15:58
  • So please accept the answer (mark it as accepted and vote for it) and create a new post for the new question. – ObjectDB Feb 01 '20 at 17:03