Package javax.persistence

Examples of javax.persistence.EntityManagerFactory.createEntityManager()


      assertEquals(cs.size(), 2);
      assertTrue(cs.contains(obj1.getKey()));
      assertTrue(cs.contains(obj1.getKey()));

      EntityManagerFactory emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
      EntityManager em = emf.createEntityManager();

      assertEquals(em.find(obj1.getValue().getClass(), obj1.getKey()), obj1.getValue());
      assertEquals(em.find(obj2.getValue().getClass(), obj2.getKey()), obj2.getValue());

      em.close();
View Full Code Here


    public Object read(ObjectInputStream is) throws IOException, ClassNotFoundException {
        String canonicalName = is.readUTF();
        Object id = is.readObject();
        EntityManagerFactory emf = (EntityManagerFactory) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY);
        EntityManager em = emf.createEntityManager();
        return em.find(Class.forName(canonicalName), id);
    }

    public byte[] marshal(Context context,
                          ObjectOutputStream os,
View Full Code Here

                                                    ClassNotFoundException {
        DroolsObjectInputStream is = new DroolsObjectInputStream( new ByteArrayInputStream( object ), classloader );
        String canonicalName = is.readUTF();
        Object id = is.readObject();
        EntityManagerFactory emf = (EntityManagerFactory) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY);
        EntityManager em = emf.createEntityManager();
        return em.find(Class.forName(canonicalName), id);
    }
   
    public Context createContext() {
        // no need for context
View Full Code Here

        ScheduledJob sj2 = new ScheduledJob( handle,
                                             new MockJob(),
                                             new MockJobContext( "xxx" ),
                                             new MockTrigger( new Date( 1000 ) ) );

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist( sj1 );
        em.getTransaction().commit();
        em.close();
View Full Code Here

        em.getTransaction().begin();
        em.persist( sj1 );
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();

        sj1 = em.find( ScheduledJob.class,
                       sj1.getId() );

        assertEquals( sj2.getId(),
View Full Code Here

        gsd1.setServiceInterfaceWhitePages.class );
        gsd1.addAddress( "socket" ).setObject( new InetSocketAddress( "127.0.0.1",
                                                                      8010 ) );
        gsd1.addAddress( "p1" ).setObject( "v1" );

        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist( gsd1 );
        em.getTransaction().commit();
        em.close();
View Full Code Here

        gsd2.setServiceInterface( WhitePages.class );
        gsd2.addAddress( "socket" ).setObject( new InetSocketAddress( "127.0.0.1",
                                                                      8000 ) );
        gsd2.addAddress( "p2" ).setObject( "v2" );

        em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist( gsd2 );
        em.getTransaction().commit();
        em.close();
View Full Code Here

        em.getTransaction().begin();
        em.persist( gsd2 );
        em.getTransaction().commit();
        em.close();

        em = emf.createEntityManager();
        GridServiceDescription<WhitePages> gsd1r = em.find( GridServiceDescriptionImpl.class,
                                                WhitePages.class.getName() );
        assertNotNull( gsd1r );
        assertEquals( gsd1,
                      gsd1r );
View Full Code Here

     * on the entity managers, look at current Transaction, if exist call joinTransaction();
     */
    private EntityManager getPersistenceContext(String unitName)
    {
        EntityManagerFactory emf = getPersistenceUnit(unitName);       
        EntityManager em = emf.createEntityManager();
       
        return em;
    }
   
    public void clear()
View Full Code Here


                EntityManager entityManager = entityManagerRegistry.getInheritedEntityManager(entityManagerFactory);
                if (entityManager == null) {
                    if (properties != null) {
                        entityManager = entityManagerFactory.createEntityManager(properties);
                    } else {
                        entityManager = entityManagerFactory.createEntityManager();
                    }
                }
                entityManagers.put(entityManagerFactory, entityManager);
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.