Package javax.persistence

Examples of javax.persistence.EntityManager.detach()


      cq.orderBy(order);
    }

    List<EventSource> eventSources = em.createQuery(cq).getResultList();
    for (EventSource source : eventSources) {
      em.detach(source);
    }
    return eventSources;
  }

  public EventSource find(String uri) {
View Full Code Here


    if (list != null) {
      if (list.size() == 0) {
        return null;
      } else if (list.size() == 1) {
        EventSource source = list.get(0);
        em.detach(source);
        return source;
      } else {
        throw new RuntimeException("One result was expected, got " + list.size());
      }
    }
View Full Code Here

        assertTrue(data.size() > 0);
       
        // Cycle through all PCs, verifying detach state
        for (int i = 0; i < size; i++) {
            Object entity = data.get(i);
            em.detach(entity);
            for (int j = 0; j < size; j++ ) {
                if (j == i) {
                    // Base entity should always be detached
                    assertFalse(em.contains(entity));
                } else {
View Full Code Here

  {
    EntityManager em = getPersistenceContext(false);
    //The detatched manager auto-detaches everything, so only
    //detach from a "real" entity manager
    if(em != detachedManager)
      em.detach(arg0);
  }

  public <T> T find(Class<T> arg0, Object arg1, Map<String, Object> arg2)
  {
    EntityManager em = getPersistenceContext(false);
View Full Code Here

      separateTx.begin();
      UserAccount user = separateTxEm.find(UserAccount.class, userId);
      separateTxEm.flush();
      Assert.assertTrue("entity is part of separate em", separateTxEm.contains(user));
      separateTx.commit();
      separateTxEm.detach(user);
      Assert.assertFalse("entity is no longer part of separate em", separateTxEm.contains(user));
      Assert.assertFalse("entity is not part of main em", em.contains(user));
      user.setLastName("Hendrix");
      UserAccount mergedUser = repo.merge(user);
      em.flush();
View Full Code Here

  public void detach(Object entity)
  {
    EntityManager em = getCurrent();
   
    if (em != null) {
      em.detach(entity);
      return;
    }
   
    em = createEntityManager();
   
View Full Code Here

    }
   
    em = createEntityManager();
   
    try {
      em.detach(entity);
    } finally {
      freeEntityManager(em);
    }
  }
View Full Code Here

      separateTx.begin();
      UserAccount user = separateTxEm.find(UserAccount.class, userId);
      separateTxEm.flush();
      Assert.assertTrue("entity is part of separate em", separateTxEm.contains(user));
      separateTx.commit();
      separateTxEm.detach(user);
      Assert.assertFalse("entity is no longer part of separate em", separateTxEm.contains(user));
      Assert.assertFalse("entity is not part of main em", em.contains(user));
      user.setLastName("Hendrix");
      UserAccount mergedUser = repo.merge(user);
      em.flush();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.