Package javax.persistence

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


  }

  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

  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

  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

    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

    //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

      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

    final EntityManagerFactory emf = Persistence.createEntityManagerFactory( "jpajtastandalone", 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

    final EntityManagerFactory emf = Persistence.createEntityManagerFactory( "jpajtastandalone",
        TestHelper.getEnvironmentProperties() );
    TransactionManager tm = extractJBossTransactionManager( emf );

    tm.begin();
    final EntityManager em = emf.createEntityManager();
    CommunityMember member = new CommunityMember( "Davide" );
    em.persist( member );

    Employee employee = new Employee( "Alex", "EMPLOYER" );
    em.persist( employee );
View Full Code Here

   public EntityManager create(Bean<EntityManager> bean, CreationalContext<EntityManager> arg0)
   {
      try
      {
         EntityManagerFactory emf = getEntityManagerFactory();
         EntityManager entityManager = emf.createEntityManager();
         entityManager = getPersistenceProvider(entityManager).proxyEntityManager(entityManager);
         PersistenceContexts persistenceContexts = null;
         try
         {
            persistenceContexts = getPersistenceContexts();
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.