Yes, You can't update 2 entities that are not related by a parent (@Parent) - child relationship in a single transaction else GAE creates them in 2 separate entity groups and then throws an exception because a transaction can't update objects in more than 1 entity group.
See parag Entity Groups in http://code.google.com/appengine/docs/java/datastore/transactions.html regards didier On Feb 26, 8:49 pm, lisandrodc <[email protected]> wrote: > Hi ! I have an error at update an object: > > public void agregarGrupoConUsuario(Usuario usuario,Long idGrupo) { > > EntityTransaction et= em.getTransaction(); > try { > et.begin(); > ControladorGrupoTorneo cGT = new > ControladorGrupoTorneo(); > GrupoTorneo grTorneo = > cGT.devolverGrupoTorneo(idGrupo); > usuario.agregarGrupoTorneo(grTorneo); > em.merge(usuario); > et.commit(); > //the exception at commit; > System.out.println("persistioUsuarioConGrupo"); > } finally { > > The error is: > > Caused by: java.lang.IllegalArgumentException: can't operate on > multiple entity groups in a single transaction. found both Element { > type: "GrupoTorneo" > id: 3} > > and Element { > type: "Usuario" > id: 11 > > } > > Class Usuario: > > @Entity > public class Usuario { > @Id > @GeneratedValue(strategy = GenerationType.IDENTITY) > private Key id; > > private String nombreUsuario; > > private String nombre; > > private String apellido; > > private String telefono; > > private String password; > > private String mail; > > private String imagen; > > private String ciudad; > > private String pais; > @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE, > CascadeType.REFRESH, CascadeType.MERGE}) > private List<RegFechaUsuario> listRegFechaUsuario; > @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE, > CascadeType.REFRESH, CascadeType.MERGE}) > private List<GrupoTorneo> gruposTorneo; > /** > .... > > Class GrupoTorneo: > > @Entity > public class GrupoTorneo { > @Id > @GeneratedValue(strategy = GenerationType.IDENTITY) > private Key id; > > private String nombre; > > private String descripcion; > > private Date fechaCreacion; > > private Long idTorneo; > > private Long idUsuarioCreador; > > private String nombreUsuarioCreador; > > private Long idGrupo; > ... > ... > > Solution? > > Regards -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
