Package javax.persistence

Examples of javax.persistence.EntityManager.find()


        em.persist(person);
        em.persist(entity);
        em.getTransaction().commit();
        em.clear();

        MedicalHistory4 persistedEntity = em.find(MedicalHistory4.class, id);
        StateManagerImpl smi = ((StateManagerImpl) ((PersistenceCapable) persistedEntity).pcGetStateManager());
        Object oid = smi.getObjectId();

        assertEquals(oid, JPAFacadeHelper.toOpenJPAObjectId(cmd, id));
    }
View Full Code Here


    em = getFactory().createEntityManager();
    int nbr_of_reads = 100000;
    start = System.nanoTime();
    for ( int i = 0; i < nbr_of_reads; i++ ) {
      int primaryKey = rand.nextInt( nbrOfBlogEntries - 1 ) + 1; // start from 1
      BlogEntry blogEntry = em.find( BlogEntry.class, Long.valueOf( primaryKey ) );
      assertThat( blogEntry.getContent() ).isNotEmpty();
      assertThat( blogEntry.getId() ).isEqualTo( primaryKey );
      assertThat( blogEntry.getAuthor() ).isNotNull();
      assertThat( blogEntry.getAuthor().getFname() ).isNotEmpty();
      assertThat( blogEntry.getBlog().getTitle() ).isNotEmpty();
View Full Code Here

    }
    for ( int i = 0; i < blogReads; i++ ) {
      getTransactionManager().begin();
      em.joinTransaction();
      int primaryKey = randId( nbrOfAuthors );
      Blog blog = em.find( Blog.class, primaryKey );

      assertThat( blog.getTitle() ).isNotEmpty();
      assertThat( blog.getId() ).isEqualTo( primaryKey );
      assertThat( blog.getEntries() ).isNotNull();
      if ( blog.getEntries().size() < ( nbrOfBlogEntries / nbrOfAuthors ) / 10 ) {
View Full Code Here

    em = getFactory().createEntityManager();
    int nbr_of_reads = 100000;
    start = System.nanoTime();
    for ( int i = 0; i < nbr_of_reads; i++ ) {
      int primaryKey = rand.nextInt( nbrOfBlogEntries - 1 ) + 1; // start from 1
      BlogEntry blog = em.find( BlogEntry.class, Long.valueOf( primaryKey ) );
      assertThat( blog.getContent() ).isNotEmpty();
      assertThat( blog.getId() ).isEqualTo( primaryKey );
      assertThat( blog.getAuthor() ).isNotNull();
      assertThat( blog.getAuthor().getFname() ).isNotEmpty();
    }
View Full Code Here

    em = getFactory().createEntityManager();
    int nbr_of_reads = 100000;
    start = System.nanoTime();
    for ( int i = 0; i < nbr_of_reads; i++ ) {
      int primaryKey = rand.nextInt( authors - 1 ) + 1; // start from 1
      Author author = em.find( Author.class, primaryKey );
      if ( author == null ) {
        System.out.printf( "Cannot find author %s, %sth loop\n", primaryKey, i );
      }
      else {
        assertThat( author.getBio() ).isNotEmpty();
View Full Code Here

    }
    em.clear();
    getTransactionManager().begin();
    operationSuccessful = false;
    try {
      News news = em.find( News.class, newsOgmID );
      assertThat( news ).isNotNull();
      assertThat( news.getContent() ).isEqualTo( contentOGM );
      assertThat( news.getNewsId().getAuthor() ).isEqualTo( author );
      assertThat( news.getNewsId().getTitle() ).isEqualTo( titleOGM );
      assertThat( news.getLabels().size() ).isEqualTo( newsOgmLabels.size() );
View Full Code Here

      assertThat( news.getContent() ).isEqualTo( contentOGM );
      assertThat( news.getNewsId().getAuthor() ).isEqualTo( author );
      assertThat( news.getNewsId().getTitle() ).isEqualTo( titleOGM );
      assertThat( news.getLabels().size() ).isEqualTo( newsOgmLabels.size() );
      em.remove( news );
      assertThat( em.find( News.class, newsOgmID ) ).isNull();

      em.clear();
      news = em.find( News.class, newsAboutJugID );
      assertThat( news ).isNotNull();
      assertThat( news.getContent() ).isEqualTo( contentAboutJUG );
View Full Code Here

      assertThat( news.getLabels().size() ).isEqualTo( newsOgmLabels.size() );
      em.remove( news );
      assertThat( em.find( News.class, newsOgmID ) ).isNull();

      em.clear();
      news = em.find( News.class, newsAboutJugID );
      assertThat( news ).isNotNull();
      assertThat( news.getContent() ).isEqualTo( contentAboutJUG );
      assertThat( news.getNewsId().getAuthor() ).isEqualTo( author );
      assertThat( news.getNewsId().getTitle() ).isEqualTo( titleAboutJUG );
      assertThat( news.getLabels().size() ).isEqualTo( newsAboutJugLabels.size() );
View Full Code Here

      assertThat( news.getContent() ).isEqualTo( contentAboutJUG );
      assertThat( news.getNewsId().getAuthor() ).isEqualTo( author );
      assertThat( news.getNewsId().getTitle() ).isEqualTo( titleAboutJUG );
      assertThat( news.getLabels().size() ).isEqualTo( newsAboutJugLabels.size() );
      em.remove( news );
      assertThat( em.find( News.class, newsAboutJugID ) ).isNull();

      em.clear();
      news = em.find( News.class, newsCountJugID );
      assertThat( news ).isNotNull();
      assertThat( news.getContent() ).isEqualTo( contentCountJUG );
View Full Code Here

      assertThat( news.getLabels().size() ).isEqualTo( newsAboutJugLabels.size() );
      em.remove( news );
      assertThat( em.find( News.class, newsAboutJugID ) ).isNull();

      em.clear();
      news = em.find( News.class, newsCountJugID );
      assertThat( news ).isNotNull();
      assertThat( news.getContent() ).isEqualTo( contentCountJUG );
      assertThat( news.getNewsId().getAuthor() ).isEqualTo( author );
      assertThat( news.getNewsId().getTitle() ).isEqualTo( titleCountJUG );
      assertThat( news.getLabels().size() ).isEqualTo( newsCountJugLabels.size() );
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.