Пример #1
0
  public Long save(BaseEntity instance) {
    if (instance.getId() == null) {
      em.persist(instance);
    } else {
      instance = em.merge(instance);
      em.flush();
    }

    return instance.getId();
  }
Пример #2
0
 @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);
   }
 }
Пример #3
0
 @Asynchronous
 public void async() {
   FooEntity fe = new FooEntity("ASYNC");
   em.persist(fe);
 }
Пример #4
0
 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);
 }
Пример #6
0
 public void sayHello(Person p) {
   em.persist(p);
   fans = em.createQuery("select p from Person p").getResultList();
 }
Пример #7
0
 @Override
 public Group create(Group group) {
   em.persist(group);
   return group;
 }