public Long save(BaseEntity instance) { if (instance.getId() == null) { em.persist(instance); } else { instance = em.merge(instance); em.flush(); } return instance.getId(); }
@PreDestroy public void destroy() { System.out.println("In SingletonBean::destroy()"); try { javax.transaction.TransactionSynchronizationRegistry r = (javax.transaction.TransactionSynchronizationRegistry) new InitialContext().lookup("java:comp/TransactionSynchronizationRegistry"); if (r.getTransactionStatus() != javax.transaction.Status.STATUS_ACTIVE) { throw new IllegalStateException( "Transaction status is not STATUS_ACTIVE: " + r.getTransactionStatus()); } FooEntity fe = new FooEntity("FOO"); em.persist(fe); } catch (Exception e) { throw new EJBException(e); } }
@Asynchronous public void async() { FooEntity fe = new FooEntity("ASYNC"); em.persist(fe); }
public <T> void persist(T t) { entityManager.persist(t); }
/** * Método que sirve para insertar registros a la base de datos * * @param espaciofísico, parametro enviado al metodo con tipo de dato: EspacioFísico */ public void insertar(EspacioFísico espaciofísico) { entityManager.persist(espaciofísico); }
public void sayHello(Person p) { em.persist(p); fans = em.createQuery("select p from Person p").getResultList(); }
@Override public Group create(Group group) { em.persist(group); return group; }