Example usage for javax.persistence EntityManager flush

List of usage examples for javax.persistence EntityManager flush

Introduction

In this page you can find the example usage for javax.persistence EntityManager flush.

Prototype

public void flush();

Source Link

Document

Synchronize the persistence context to the underlying database.

Usage

From source file:uk.co.threeonefour.ifictionary.web.user.dao.JpaUserDao.java

@Transactional
@Override
public void remove(String id) {

    EntityManager em = entityManager;
    em.remove(get(id));
    em.flush();
}

From source file:com.gerenciaProyecto.DaoImple.UsuarioDaoImpl.java

@Override
@Transactional//  w ww .j  av  a  2  s  . c  om
public void modificar(Usuario usuario) {
    EntityManager em = getEntityManager();
    try {
        em.merge(usuario);
        em.flush();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.gerenciaProyecto.DaoImple.UsuarioDaoImpl.java

@Override
@Transactional//from  w  ww.  ja v  a  2s  .c  o m
public void crear(Usuario usuario) {
    EntityManager em = getEntityManager();
    try {
        em.persist(usuario);
        em.flush();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.gerenciaProyecto.DaoImple.ProductoDaoImpl.java

@Override
@Transactional/* w  w w  .j  a  va2  s. co m*/
public void modificar(Producto producto) {
    EntityManager em = getEntityManager();
    try {
        em.merge(producto);
        em.flush();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:org.spring.data.gemfire.app.dao.provider.JpaUserDao.java

@Transactional
public User save(final User user) {
    EntityManager localEntityManager = prepare(this.entityManager);
    localEntityManager.persist(user);//from  w  ww  .  j  a  v  a 2  s.  c o  m
    localEntityManager.flush();
    return user;
}

From source file:com.gerenciaProyecto.DaoImple.ProductoDaoImpl.java

@Override
@Transactional/*  w ww  .  ja  v  a  2 s.co  m*/
public void crear(Producto producto) {
    EntityManager em = getEntityManager();
    try {
        //            producto.set

        em.persist(producto);
        em.flush();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.nuxeo.ecm.core.persistence.PersistenceProvider.java

protected void doCommit(EntityManager em) {
    try {/*from  w w  w .java 2  s.  c o  m*/
        em.flush();
    } catch (TransactionRequiredException e) {
        // ignore
    }
    EntityTransaction et = getTransaction(em);
    if (et == null || !et.isActive()) {
        return;
    }
    et.commit();
}

From source file:org.nuxeo.ecm.core.persistence.PersistenceProvider.java

protected void doRollback(EntityManager em) {
    try {/*w w  w  .j av a2  s  . co  m*/
        em.flush();
    } catch (TransactionRequiredException e) {
        // ignore
    }
    EntityTransaction et = getTransaction(em);
    if (et == null || !et.isActive()) {
        return;
    }
    et.rollback();
}

From source file:org.opennaas.core.security.persistence.SecurityRepository.java

public void close() {
    EntityManager entityManager = getEntityManager();
    if (entityManager != null) {
        log.debug("Closing entity manager: " + entityManager);
        entityManager.flush();
        entityManager.close();/*from  w  w w .  j av a 2  s. c o m*/
        setEntityManager(null);
    }
}

From source file:org.spc.ofp.tubs.domain.purseseine.TripRepository.java

public void save(final PurseSeineTrip trip) {
    final EntityManager mgr = emf.createEntityManager();
    final EntityTransaction xa = mgr.getTransaction();
    try {//  w ww . j a  va2  s.  c o  m
        xa.begin();
        mgr.persist(trip);
        mgr.flush();
        xa.commit();
        mgr.refresh(trip);
    } catch (Exception ex) {
        if (xa.isActive()) {
            xa.rollback();
        }
    } finally {
        mgr.close();
    }
}