I'm using Java with JPA and I have a festival entity and another festival edition. A festival can have many editions. The question that when I release an edition, after doing em.persist, I have to do
res.getFestival().getFestivalEdicions().add(res);
em.merge(res.getFestival());
Is there any way to make jpa aware of the changes and update?
The full method of the create is:
@Override
@MethodName(name = MethodsNameAgam.FESTIVALEDICION_ADD)
public FestivalEdicion create(FestivalEdicionTran tran) throws Exception {
assign(tran, Op.CREATE);
validate(tran, Op.CREATE);
FestivalEdicion res = tran.build(Op.CREATE);
if (tran.getPortada() != null && tran.getPortada().isSet()) {
Contenido portada = contenidoCont.create(tran.getPortada());
res.setPortada(portada);
}
em.persist(res);
//AGREGAR A LA LSITA DE EDCIONES DEL FESTIVAL, LA EDICIONE CREADA
res.getFestival().getFestivalEdicions().add(res);
em.merge(res.getFestival());
return res;
}