Package org.apache.openjpa.persistence

Examples of org.apache.openjpa.persistence.FetchPlan


   
    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


    /**
     * Same as above but the root compnay instance is detached.
     */
    public void testDetachedRelationTraversalWithCompanyAsRoot() {
        OpenJPAEntityManager pm = getPM();
        FetchPlan plan = pm.getFetchPlan();
        pm.getFetchPlan().setMaxFetchDepth(2);
        plan.addFetchGroup("company.departments");
        plan.addFetchGroup("company.address");
        plan.addFetchGroup("department.employees");
        plan.addFetchGroup("person.address");
        plan.addFetchGroup("address.country");

        PCCompany company1 =
            (PCCompany) pm.find(PCCompany.class, _rootCompanyId);

        PCCompany company = (PCCompany) pm.detach(company1);
View Full Code Here

    em.getTransaction().commit();
  }

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

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

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

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

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

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

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

     * The fetch depth is kept infinite, so what would be fetched is essentially
     * controlled by the fetch groups.
     */
    public void testRelationTraversal() {
        OpenJPAEntityManager pm = getPM();
        FetchPlan plan = pm.getFetchPlan();
        pm.getFetchPlan().setMaxFetchDepth(-1);
        plan.addFetchGroup("employee.department");
        plan.addFetchGroup("department.company");
        plan.addFetchGroup("company.address");
        plan.addFetchGroup("address.country");

        Iterator employees = pm.createExtent(PCEmployee.class, true).iterator();
        while (employees.hasNext()) {
            PCEmployee emp = (PCEmployee) employees.next();

View Full Code Here

     * The fetch depth is kept infinite, so what would be fetched is essentially
     * controlled by the fetch groups.
     */
    public void testRelationTraversalTruncated() {
        OpenJPAEntityManager pm = getPM();
        FetchPlan plan = pm.getFetchPlan();
        pm.getFetchPlan().setMaxFetchDepth(-1);
        plan.addFetchGroup("employee.department");
        plan.addFetchGroup("department.company");
        plan.addFetchGroup("company.address");

        Iterator employees = pm.createExtent(PCEmployee.class, true).iterator();
        while (employees.hasNext()) {
            PCEmployee emp = (PCEmployee) employees.next();

View Full Code Here

     * Hence the company's address->country should be loaded but not the
     * employee's.
     */
    public void testRelationTraversalWithCompanyAsRoot() {
        OpenJPAEntityManager pm = getPM();
        FetchPlan plan = pm.getFetchPlan();

        plan.setMaxFetchDepth(2);
        plan.addFetchGroup("company.departments");
        plan.addFetchGroup("company.address");
        plan.addFetchGroup("department.employees");
        plan.addFetchGroup("person.address");
        plan.addFetchGroup("address.country");

        PCCompany company =
            (PCCompany) pm.find(PCCompany.class, _rootCompanyId);
        Set departments = (Set) PCCompany.reflect(company, "departments");
        assertNotNull("department is null", departments);
View Full Code Here

    /**
     * Same as above but the root compnay instance is detached.
     */
    public void testDetachedRelationTraversalWithCompanyAsRoot() {
        OpenJPAEntityManager pm = getPM();
        FetchPlan plan = pm.getFetchPlan();
        pm.getFetchPlan().setMaxFetchDepth(2);
        plan.addFetchGroup("company.departments");
        plan.addFetchGroup("company.address");
        plan.addFetchGroup("department.employees");
        plan.addFetchGroup("person.address");
        plan.addFetchGroup("address.country");

        PCCompany company1 =
            (PCCompany) pm.find(PCCompany.class, _rootCompanyId);

        PCCompany company = (PCCompany) pm.detachCopy(company1);
View Full Code Here

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

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

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

    assertEquals("b1", b.getText());
  }
 
  public void testFetchBySubClassFieldNameB() {
    OpenJPAEntityManager em = emf.createEntityManager();
    FetchPlan fp = em.getFetchPlan();
        fp.setExtendedPathLookup(true);
    fp.clearFetchGroups();
    fp.clearFields();
    fp.addField(FetchA.class.getName() + ".b");
    fp.addField(FetchB.class.getName() + ".text");

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

    FetchB  b = a.getB();
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.