Examples of createEntityManager()


Examples of javax.persistence.EntityManagerFactory.createEntityManager()

        TestHelper.getEnvironmentProperties() );

    TransactionManager transactionManager = extractJBossTransactionManager( emf );

    transactionManager.begin();
    final EntityManager em = emf.createEntityManager();
    Hero h = new Hero();
    h.setName( "Spartacus" );
    em.persist( h );
    SuperHero sh = new SuperHero();
    sh.setName( "Batman" );
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

    /**
     * Flush search indexes, to be done after a reindex() or reindexAll() operation
     */
    public void flushSearchIndexes() {
        EntityManagerFactory entityManagerFactory = (EntityManagerFactory) applicationContext.getBean("entityManagerFactory");
        FullTextEntityManager fullTextEntityMgr = Search.getFullTextEntityManager(entityManagerFactory.createEntityManager());
        fullTextEntityMgr.flushToIndexes();
    }
}
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

        ds.setDatabaseName("target/test");
        ds.setCreateDatabase("create");
        ic.bind("osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/derbyds)", ds);
        PersonServiceImpl personService = new PersonServiceImpl();
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("personTest", System.getProperties());
        EntityManager em = emf.createEntityManager();
        personService.setEntityManager(em);
        em.getTransaction().begin();
        personService.deleteAll();
        personService.add(new Person("Christian Schneider", "@schneider_chris"));
        em.getTransaction().commit();
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

        ds.setDatabaseName("target/test");
        ds.setCreateDatabase("create");
        ic.bind("osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/derbyds)", ds);
        PersonServiceImpl personService = new PersonServiceImpl();
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("personTest", System.getProperties());
        EntityManager em = emf.createEntityManager();
        personService.setEntityManager(em);
        em.getTransaction().begin();
        personService.deleteAll();
        personService.add(new Person("Christian Schneider", "@schneider_chris"));
        em.getTransaction().commit();
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

  }

  private static void resetDatabaseState() {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("exampleHibernateJPA");
   
    EntityManager em = emf.createEntityManager();
   
    log.info("Creating and persisting entity...");
    EntityTransaction tx = em.getTransaction();
    tx.begin();
   
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

  public void testDatabaseSaveAndRetrieve() {
    log.info("Running testDatabaseSaveAndRetrieve");
   
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("exampleHibernateJPA");
   
    EntityManager em = emf.createEntityManager();
   
    log.info("Creating and persisting entity...");
    EntityTransaction tx = em.getTransaction();
    tx.begin();
   
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

  public void testOverriddenTypeInDialect() throws Exception {
    final EntityManagerFactory emf = Persistence.createEntityManagerFactory( "jpajtastandalone" );

    TransactionManager transactionManager = extractJBossTransactionManager( emf );
    transactionManager.begin();
    final EntityManager em = emf.createEntityManager();
    try {
      Poem poem = new Poem();
      poem.setName( "L'albatros" );
      poem.setPoemSocietyId( UUID.randomUUID() );
      poem.setCreation( new Date() );
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

    Session s = factory.openSession();
    assertThat( s.getClass() ).isEqualTo( OgmSessionImpl.class );
    assertThat( s.getSessionFactory().getClass() ).isEqualTo( OgmSessionFactoryImpl.class );
    s.close();

    EntityManager em = emf.createEntityManager();
    assertThat( em.unwrap( Session.class ) instanceof OgmSession );
    assertThat( em.getDelegate().getClass() ).isEqualTo( OgmSessionImpl.class );

    em.close();
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

    //Persist entities the way you are used to in plain JPA
    try {
      tm.begin();
      logger.infof( "About to store dog and breed" );
      EntityManager em = emf.createEntityManager();
      Breed collie = new Breed();
      collie.setName( "Collie" );
      em.persist( collie );
      Dog dina = new Dog();
      dina.setName( "Dina" );
View Full Code Here

Examples of javax.persistence.EntityManagerFactory.createEntityManager()

      tm.commit();

      //Retrieve your entities the way you are used to in plain JPA
      logger.infof( "About to retrieve dog and breed" );
      tm.begin();
      em = emf.createEntityManager();
      dina = em.find( Dog.class, dinaId );
      logger.infof( "Found dog %s of breed %s", dina.getName(), dina.getBreed().getName() );
      em.flush();
      em.close();
      tm.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.