Package org.apache.openjpa.persistence

Examples of org.apache.openjpa.persistence.FetchPlan


    assertEquals("b1", b.getText());
  }

  public void testFetchBySubClassFieldNameA() {
    OpenJPAEntityManager em = emf.createEntityManager();
    FetchPlan fp = em.getFetchPlan();
        fp.setExtendedPathLookup(true);
    fp.clearFetchGroups();
    fp.clearFields();
    fp.addField(FetchA.class.getName() + ".b");
    fp.addField(FetchA.class.getName() + ".text");

    FetchA a = (FetchA) em.createQuery(JPQL).getSingleResult();
    em.close();

    FetchB  b = a.getB();
View Full Code Here


    assertNull(b.getText());
  }
 
  public void testFetchBySuperClassFieldName() {
    OpenJPAEntityManager em = emf.createEntityManager();
    FetchPlan fp = em.getFetchPlan();
        fp.setExtendedPathLookup(true);
    fp.clearFetchGroups();
    fp.clearFields();
    fp.addField(FetchA.class.getName() + ".b");
    fp.addField(FetchBase.class.getName() + ".text");

    FetchA a = (FetchA) em.createQuery(JPQL).getSingleResult();
    em.close();

    FetchB  b = a.getB();
View Full Code Here

        checkObject(pm, o1, true, true, true, true, false, false);
    }

    public void testFetchGroupConfiguration() {
        OpenJPAEntityManager pm = getPM();
        FetchPlan fetch = pm.getFetchPlan();

        checkGroups(pm, new String[0]);

        fetch.addFetchGroup("foo");
        checkGroups(pm, new String[]{ "foo" });

        fetch.addFetchGroup("bar");
        fetch.addFetchGroup("baz");
        checkGroups(pm, new String[]{ "foo", "bar", "baz" });

        fetch.addFetchGroup("a");
        fetch.addFetchGroup("b");
        fetch.addFetchGroup("c");
        fetch.addFetchGroup("d");
        checkGroups(pm, new String[]
            { "foo", "bar", "baz", "a", "b", "c", "d" });

        fetch.removeFetchGroup("bar");
        checkGroups(pm, new String[]{ "foo", "baz", "a", "b", "c", "d" });

        fetch.removeFetchGroup("baz");
        fetch.removeFetchGroup("c");
        checkGroups(pm, new String[]{ "foo", "a", "b", "d" });

        fetch.clearFetchGroups().addFetchGroup(FetchPlan.GROUP_DEFAULT);
        checkGroups(pm, new String[0]);
    }
View Full Code Here

        em.clear();
       
        // Select root (state 1)
        Query query = em.createQuery("select s from State s where s.name=:name");
        FetchPlan fetch = OpenJPAPersistence.cast(query).getFetchPlan();
        fetch.setMaxFetchDepth(15);
        fetch.addField(State.class, "incomingTransitions");
        fetch.addField(State.class, "outgoingTransitions");
        fetch.addField(Transition.class, "toState");
        fetch.addField(Transition.class, "fromState");
        State qs1 = (State) query.setParameter("name", "s1").getSingleResult();

        em.close(); // will not load anything anymore

        byte[][] actualTransitionMatrix = new byte[5][5];
View Full Code Here

   
    private void stringCollectionByIdTest(boolean empty) {
        Object oid = insertStringCollection((empty) ? 1 : 0);
       
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
        FetchPlan fetch = (FetchPlan) pm.getFetchPlan();
        fetch.addField(EagerOuterJoinPC.class, "stringCollection");
        EagerOuterJoinPC pc = (EagerOuterJoinPC) pm.getObjectId(oid);
        assertEquals("1", pc.getName());
        if (empty)
            assertEquals(pc.getStringCollection().toString(),
                    0, pc.getStringCollection().size());
View Full Code Here

   
    private void stringCollectionByQueryTest(int empty) {
        insertStringCollection(empty);
       
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
        FetchPlan fetch = (FetchPlan) pm.getFetchPlan();
        fetch.addField(EagerOuterJoinPC.class, "stringCollection");
        fetch.setFetchBatchSize(-1);
        OpenJPAQuery q = pm.createNativeQuery("",EagerOuterJoinPC.class);
       
        //FIXME jthomas
        //q.setOrdering("name ascending");
        Collection results = (Collection) q.getResultList();
View Full Code Here

    public void testStringListById() {
        Object oid = insertStringList();
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
       
       
        FetchPlan fetch = (FetchPlan) pm.getFetchPlan();
        fetch.addField(EagerOuterJoinPC.class, "stringList");
        EagerOuterJoinPC pc = (EagerOuterJoinPC) pm.getObjectId(oid);
        assertEquals("1", pc.getName());
        assertEquals(2, pc.getStringList().size());
        assertEquals("1.1", pc.getStringList().get(0));
        assertEquals("1.2", pc.getStringList().get(1));
View Full Code Here

   
    public void testStringListByQuery() {
        insertStringList();
       
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
        FetchPlan fetch = (FetchPlan) pm.getFetchPlan();
        fetch.addField(EagerOuterJoinPC.class, "stringList");
        fetch.setFetchBatchSize(-1);
        OpenJPAQuery q = pm.createNativeQuery("",EagerOuterJoinPC.class);
        //FIXME jthomas
        //q.setOrdering("name ascending");
        Collection results = (Collection) q.getResultList();
       
View Full Code Here

   
    private void oneManyCollectionByIdTest(boolean empty) {
        Object oid = insertOneManyCollection((empty) ? 1 : 0);
       
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
        FetchPlan fetch = (FetchPlan) pm.getFetchPlan();
        fetch.addField(EagerOuterJoinPC.class, "oneManyCollection");
        EagerOuterJoinPC pc = (EagerOuterJoinPC) pm.getObjectId(oid);
        assertEquals("1", pc.getName());
        if (empty)
            assertEquals(0, pc.getOneManyCollection().size());
        else
View Full Code Here

   
    private void oneManyCollectionByQueryTest(int empty) {
        insertOneManyCollection(empty);
       
        OpenJPAEntityManager pm =(OpenJPAEntityManager)currentEntityManager();
        FetchPlan fetch = (FetchPlan) pm.getFetchPlan();
        fetch.addField(EagerOuterJoinPC.class, "oneManyCollection");
        fetch.setFetchBatchSize(-1);
        OpenJPAQuery q = pm.createNativeQuery("",EagerOuterJoinPC.class);
        //FIXME jthomas
        //q.setOrdering("name ascending");
        Collection results = (Collection) q.getResultList();
       
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.FetchPlan

Copyright © 2018 www.massapicom. 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.