Package javax.persistence

Examples of javax.persistence.EntityManager.clear()


    EntityManager em = getPersistenceContext(arg2 != LockModeType.NONE);
    try {
      return em.find(arg0, arg1, arg2);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }

  /**
   * @throws TransactionRequiredException if lock mode is not NONE
View Full Code Here


    EntityManager em = getPersistenceContext(arg2 != LockModeType.NONE);
    try {
      return em.find(arg0, arg1, arg2, arg3);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }

  public CriteriaBuilder getCriteriaBuilder()
  {
View Full Code Here

    EntityManager em = getPersistenceContext(false);
    try {
      em.setProperty(arg0, arg1);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }

  public <T> T unwrap(Class<T> arg0)
  {
View Full Code Here

    EntityManager em = getPersistenceContext(false);
    try {
      return em.unwrap(arg0);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }
}
View Full Code Here

                    entityManager = entityManagerFactory.createEntityManager();
                }
                // Let's clear the entity manager session to ensure we don't have any data left from previous transaction used by this thread
                // Any caching of data should be handled through the second level cache and not by caching it between two transaction in the
                // entity manager.
                entityManager.clear();
                entityManager.getTransaction().begin();
                ENTITY_MANAGER_CACHE.set(entityManager);
            }

            @Override
View Full Code Here

      link(osoby[i], projekt1);
    for (int i=0; i<MEMBER_COUNT_PROJEKT2; i++)
      link(osoby[osoby.length-i-1], projekt2);
       
    em.getTransaction().commit();
    em.clear();
  }

  public void tearDown() throws Exception {
    super.tearDown();
  }
View Full Code Here

 
  public void testQueryWithUnmanagedPersistentInstanceAsParameter() {
    EntityManager em = emf.createEntityManager();
    Projekt projekt1 = em.find(Projekt.class, ID_PROJEKT1);
    Projekt projekt2 = em.find(Projekt.class, ID_PROJEKT2);
    em.clear();
    assertFalse(em.contains(projekt1));
    assertFalse(em.contains(projekt2));
   
    queryWithParameter(em, projekt1, projekt2);
  }
View Full Code Here

        em.merge(o);
        batchSize++;

        if (batchSize >= config.getBatchSize()) {
          em.flush();
          em.clear();
          batchSize = 0;
        }

        o = marshaller.objectFromObjectStream(ois);
      }
View Full Code Here

    yellowSubmarine.setCommander( beetles );
    yellowSubmarine.setName( "Yellow" );
    yellowSubmarine.setSize( 13 );
    em.persist( yellowSubmarine );
    em.flush();
    em.clear();
    yellowSubmarine = em.find( Submarine.class, yellowSubmarine.getId() );
    yellowSubmarine.setSize( 3 );
    try {
      em.flush();
      fail("Event not wired");
View Full Code Here

    c.setName( "Kitty" );
    c.setDateOfBirth( new Date( 90, 11, 15 ) );
    em.getTransaction().begin();
    em.persist( c );
    em.getTransaction().commit();
    em.clear();
    em.getTransaction().begin();
    c = em.find( Cat.class, c.getId() );
    assertFalse( c.getAge() == 0 );
    c.setName( "Tomcat" ); //update this entity
    em.getTransaction().commit();
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.