Package javax.persistence

Examples of javax.persistence.EntityManager.find()


      loadedBridge = em.find( Bridge.class, 2L );
      assertThat( loadedBridge ).isNotNull();
      assertThat( loadedBridge.getEngineers() ).onProperty( "name" ).containsOnly( "Bob the constructor", "Biff the destructor" );
      em.remove( loadedBridge );
      assertThat( em.find( Bridge.class, 2L ) ).isNull();

    }
    finally {
      commitOrRollback( operationSuccessful );
    }
View Full Code Here


    @Inject
    Provider<EntityManager> entitiyManagerProvider;

    public World get(int id) {
        EntityManager entityManager = entitiyManagerProvider.get();
        return entityManager.find(World.class, id);
    }

    public void put(World world) {
        EntityManager entityManager = entitiyManagerProvider.get();
        entityManager.persist(world);
View Full Code Here

  @Test
  public void testNoNodeIsLeftBehindWhenDeletingRelationships() throws Exception {
    getTransactionManager().begin();
    EntityManager em = getFactory().createEntityManager();
    MultiAddressAccount multiAddressAccount = em.find( MultiAddressAccount.class, account.getLogin() );
    multiAddressAccount.getAddresses().clear();
    commitOrRollback( true );
    em.close();

    assertNumberOfNodes( 1 );
View Full Code Here

      getTransactionManager().commit();
      em.clear();

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

      getTransactionManager().commit();
    }
    finally {
View Full Code Here

      em.close();
    }
    {
      getTransactionManager().begin();
      final EntityManager em = getFactory().createEntityManager();
      EntityWithConstraints entity1 = em.find( EntityWithConstraints.class, "id_1" );
      EntityWithConstraints entity2 = em.find( EntityWithConstraints.class, "id_2" );
      assertThat( entity1.getUniqueColumn() ).isEqualTo( entity2.getUniqueColumn() );
      getTransactionManager().commit();
      em.close();
    }
View Full Code Here

    }
    {
      getTransactionManager().begin();
      final EntityManager em = getFactory().createEntityManager();
      EntityWithConstraints entity1 = em.find( EntityWithConstraints.class, "id_1" );
      EntityWithConstraints entity2 = em.find( EntityWithConstraints.class, "id_2" );
      assertThat( entity1.getUniqueColumn() ).isEqualTo( entity2.getUniqueColumn() );
      getTransactionManager().commit();
      em.close();
    }
  }
View Full Code Here

    transactionManager.commit();

    em.clear();

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

        em.getTransaction().rollback();

        assertThat( getNumberOfEntities( em ) ).isEqualTo( 1 );

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

        em.getTransaction().begin();
        poem = em.find( Poem.class, poem.getId() );
        assertThat( poem ).isNotNull();
        assertThat( poem.getName() ).isEqualTo( "L'albatros" );
        em.remove( poem );
        poem2 = em.find( Poem.class, poem2.getId() );
        assertThat( poem2 ).isNull();
        em.getTransaction().commit();

      }
      finally {
View Full Code Here

    getTransactionManager().commit();

    em.clear();

    getTransactionManager().begin();
    poem = em.find( Poem.class, poem.getId() );
    assertThat( poem ).isNotNull();
    assertThat( poem.getName() ).isEqualTo( "L'albatros" );
    em.remove( poem );
    getTransactionManager().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.