Package javax.persistence

Examples of javax.persistence.EntityManager.clear()


                                    .getSingleResult();
                } catch (Exception ex) {} finally {
                    assert d == null;
                }

                em.clear();

                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 8l)
                                .getSingleResult();
View Full Code Here


                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 8l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 0;

                em.clear();

                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 9l)
                                .getSingleResult();
View Full Code Here

                newDoc.setParent(d);

                em.persist(newDoc);
                em.flush();

                em.clear();
                WikiDocument doc = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", newDoc.getId())
                                .getSingleResult();
                assert doc.getName().equals("Four");
View Full Code Here

  public void clear()
  {
    EntityManager em = getCurrent();

    if(em != null)
      em.clear();
  }

  /**
   * Clears the manager.
   */
 
View Full Code Here

    }
    finally {
      commitOrRollback( operationSuccessful );
    }

    em.clear();
    getTransactionManager().begin();
    operationSuccessful = false;
    try {
      Bridge news = em.find( Bridge.class, 1L );
      assertThat( news ).isNotNull();
View Full Code Here

    }
    finally {
      commitOrRollback( operationSuccessful );
    }

    em.clear();
    getTransactionManager().begin();
    operationSuccessful = false;

    try {
      Bridge loadedBridge = em.find( Bridge.class, 3L );
View Full Code Here

      operationSuccessful = true;
    }
    finally {
      commitOrRollback( operationSuccessful );
    }
    em.clear();
    em.close();
  }

  @Test
  public void testMapping() throws Exception {
View Full Code Here

      goldFishBar.getDoorMen().add( new DoorMan( "Dwain" ) );

      // when
      em.persist( goldFishBar );
      getTransactionManager().commit();
      em.clear();

      // then
      getTransactionManager().begin();
      Bar barLoaded = em.find( Bar.class, goldFishBar.getId() );
      assertThat( barLoaded.getDoorMen() ).onProperty( "name" ).containsOnly( "Bruce", "Dwain" );
View Full Code Here

    Poem poem = new Poem();
    poem.setName( "L'albatros" );
    em.persist( poem );
    transactionManager.commit();

    em.clear();

    transactionManager.begin();
    poem = em.find( Poem.class, poem.getId() );
    assertThat( poem ).isNotNull();
    assertThat( poem.getName() ).isEqualTo( "L'albatros" );
View Full Code Here

        Poem poem = new Poem();
        poem.setName( "L'albatros" );
        em.persist( poem );
        em.getTransaction().commit();

        em.clear();

        em.getTransaction().begin();
        Poem poem2 = new Poem();
        poem2.setName( "Wazaaaaa" );
        em.persist( poem2 );
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.