[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] em.merge() ignore.
|
On Jueves 21 Abril 2011 06:46:49 Tom Ware escribió:
> If you merge a changed object, you need to commit the transaction before
> you will see the change.
>
> If you are already committing the transaction, please post an example of
> the code you are running.
>
> -Tom
Fortunately I was able to resolve de issue.
This is the method:
/**
* Guarda en la DB un objeto de tipo solicitud.
*/
@Transactional(rollbackFor=ValidationException.class, readOnly=false)
public void save(List<SolicitudTelcel> solicitudesTelcel, String noGuia,
Date fechaEnvio) throws ValidationException {
for (SolicitudTelcel solicitudTelcel : solicitudesTelcel) {
if(noGuia != null && fechaEnvio != null){
EstadoIntermedio estadoIntermedio = new EstadoIntermedio(noGuia,
fechaEnvio);
estadoIntermedio.setSolicitudTelcel(solicitudTelcel);
estadoIntermedioBean.save(estadoIntermedio);
solicitudTelcel.getEstadosIntermedios().add(estadoIntermedio);
}
SolicitudTelcel temp = em.merge(solicitudTelcel);
em.flush(); //if I comment this line, no updates are triggers, and
//the changes arent reflect to de DB.
solicitudTelcelViewBean.createAndSave(temp);
}
}
>
> Christian (VuuRWerK) Seifert wrote:
> > If I understand EntityManager#merge(Object) correctly it just merge
> > the Object with eclipselink but do not any database operation.
> > To persist the changes you have to use EntityManager#persist(Object),
> > thus eclipselink do update the already existing entry in the database.
> >
> > Hope that helps and please correct when I'm wrong ;)
> >
> > -- Christian
> >
> > 2011/4/20 José Arcángel Salazar Delgado
<arcangel.salazar@xxxxxxxxxxxxxxxxxx>:
> >> Hello.
> >>
> >> I'm having some troubles with a estrage behaviour. This is my flow:
> >>
> >> 1.- Get a List of objects of a determinate type.
> >> 2.- modify one atribute of the object.
> >> 3.- make a for each and do em.merge(object).
> >>
> >> Unfortunately the em.merge is ignore (I kwno that because in the logging
> >> of eclipselink I never see and UPDATE statement). If instead I use a
> >> JQPL update query to do the modification, every thing works as
> >> espected.
> >>
> >> My question, what error or problem can affect the em.merge to not work
> >> silently (no exceptions are throws)??
> >>
> >> These methods worked well until I add to String atributes to the object.
> >> _______________________________________________
> >> eclipselink-users mailing list
> >> eclipselink-users@xxxxxxxxxxx
> >> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> >
> > _______________________________________________
> > eclipselink-users mailing list
> > eclipselink-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users