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.
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
).