Examples of PObject


Examples of org.apache.openjpa.persistence.datacache.common.apps.PObject

            ? emfWithDataCache : emfWithoutDataCache;
        emf.getConfiguration().setRefreshFromDataCache(refreshFromDataCache);
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
       
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
        em.persist(pc);
        em.getTransaction().commit();
       
        Object oid = pc.getId();
        StoreCache dataCache = emf.getStoreCache();
        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
       
        // Modify the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
        String sql = "UPDATE L2_PObject SET NAME='" + MARKER_DATABASE
        + "' WHERE id=" + oid;
        em.createNativeQuery(sql).executeUpdate();
        em.getTransaction().commit();
       
        assertEquals(useDataCache ? MARKER_DATACACHE : MARKER_CACHE,
                pc.getName());
       
        em.getTransaction().begin();
        if (makeDirtyBeforeRefresh) {
            pc.setName(MARKER_DIRTY_CACHE);
        }
        assertEquals(makeDirtyBeforeRefresh, em.isDirty(pc));

        if (lock != null) {
            ((EntityManagerImpl)em).getFetchPlan().setReadLockMode(lock);
        }
        em.refresh(pc);
       
        assertEquals(expected, pc.getName());
        em.getTransaction().commit();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.PObject

            ? emfWithDataCache : emfWithoutDataCache;
           
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
       
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
        em.persist(pc);
        em.getTransaction().commit();
       
        Object oid = pc.getId();
        StoreCache dataCache = emf.getStoreCache();
        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
       
        // delete the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
        String sql = "DELETE FROM L2_PObject WHERE id="+oid;
        em.createNativeQuery(sql).executeUpdate();
        em.getTransaction().commit();
       
        // the object cache does not know that the record was deleted
        assertTrue(em.contains(pc));
        // nor does the data cache
        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
       
        /**
         * refresh behavior no more depends on current lock. Refresh
         * will always attempt to fetch the instance from database
         * raising EntityNotFoundException.
         *  
         */
        em.getTransaction().begin();
        em.getFetchPlan().setReadLockMode(lock);
        if (dirty)
            pc.setName("Dirty Name");
        try {
            em.refresh(pc);
            if (expectedExceptionType != null) {
                fail("expected " + expectedExceptionType.getSimpleName() +
                        " for PObject:" + oid);
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.PObject

            ? emfWithDataCache : emfWithoutDataCache;
        emf.getConfiguration().setRefreshFromDataCache(refreshFromDataCache);
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
       
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
        em.persist(pc);
        em.getTransaction().commit();
       
        Object oid = pc.getId();
        StoreCache dataCache = emf.getStoreCache();
        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
       
        // Modify the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
        String sql = "UPDATE PObject SET NAME='" + MARKER_DATABASE
        + "' WHERE id=" + oid;
        em.createNativeQuery(sql).executeUpdate();
        em.getTransaction().commit();
       
        assertEquals(useDataCache ? MARKER_DATACACHE : MARKER_CACHE,
                pc.getName());
       
        em.getTransaction().begin();
        if (makeDirtyBeforeRefresh) {
            pc.setName(MARKER_DIRTY_CACHE);
        }
        assertEquals(makeDirtyBeforeRefresh, em.isDirty(pc));

        if (lock != null) {
            ((EntityManagerImpl)em).getFetchPlan().setReadLockMode(lock);
        }
        em.refresh(pc);
       
        assertEquals(expected, pc.getName());
        em.getTransaction().commit();
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.datacache.common.apps.PObject

            ? emfWithDataCache : emfWithoutDataCache;
           
        OpenJPAEntityManagerSPI em = emf.createEntityManager();
       
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setName(useDataCache ? MARKER_DATACACHE : MARKER_CACHE);
        em.persist(pc);
        em.getTransaction().commit();
       
        Object oid = pc.getId();
        StoreCache dataCache = emf.getStoreCache();
        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
       
        // delete the record in the database in a separate transaction using
        // native SQL so that the in-memory instance is not altered
        em.getTransaction().begin();
        String sql = "DELETE FROM PObject WHERE id="+oid;
        em.createNativeQuery(sql).executeUpdate();
        em.getTransaction().commit();
       
        // the object cache does not know that the record was deleted
        assertTrue(em.contains(pc));
        // nor does the data cache
        assertEquals(useDataCache, dataCache.contains(PObject.class, oid));
       
        /**
         * refresh behavior no more depends on current lock. Refresh
         * will always attempt to fetch the instance from database
         * raising EntityNotFoundException.
         *  
         */
        em.getTransaction().begin();
        em.getFetchPlan().setReadLockMode(lock);
        if (dirty)
            pc.setName("Dirty Name");
        try {
            em.refresh(pc);
            if (expectedExceptionType != null) {
                fail("expected " + expectedExceptionType.getSimpleName() +
                        " for PObject:" + oid);
View Full Code Here

Examples of org.apache.openjpa.persistence.exception.PObject

    }
   
    public Object createEntity(EntityManager em) {
        long id = System.nanoTime();
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setId(id);
        em.persist(pc);
        em.getTransaction().commit();
        return id;
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.exception.PObject

    }
   
    public Object createEntity(EntityManager em) {
        long id = System.nanoTime();
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setId(id);
        em.persist(pc);
        em.getTransaction().commit();
        return id;
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.exception.PObject

    }
   
    public Object createEntity(EntityManager em) {
        long id = System.nanoTime();
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setId(id);
        em.persist(pc);
        em.getTransaction().commit();
        return id;
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.exception.PObject

    }
   
    public Object createEntity(EntityManager em) {
        long id = System.nanoTime();
        em.getTransaction().begin();
        PObject pc = new PObject();
        pc.setId(id);
        em.persist(pc);
        em.getTransaction().commit();
        return id;
    }
View Full Code Here

Examples of org.apache.openjpa.slice.PObject

  @Override
  public String distribute(Object pc, List<String> slices, Object context) {
    int N = slices.size();
    for (int i = N; i > 0; i--) {
      PObject p = (PObject)pc;
      if (p.getId()%i == 0) return slices.get(i-1);
    }
    return slices.get(0);
  }
View Full Code Here

Examples of org.jresearch.flexess.core.model.uam.PObject

    boolean objectFound = false;
    final Class<?> currentClass = checkerFlow.getObjectClass();
    final List<Class<?>> classes = getCandidateClasses(currentClass);
    for (final Class<?> candidatClass : classes) {
      try {
        final PObject po = findPObject(model, candidatClass.getName(), object);
        isPermitted = internalCheck(po, roles, operation, checkerFlow);
        objectFound = true;
        break;
      } catch (final PObjectNotFoundException e) {
        // do nothing
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.