Package org.objectweb.speedo.pobjects.fetchgroup

Examples of org.objectweb.speedo.pobjects.fetchgroup.Thesis


   
    University uni1 = new University("Wisconsin");
    University uni2 = new University("Arkansas");
    University uni3 = new University("Tokyo");
   
    Thesis thesis1 = new Thesis(400, author1, 124, "Performance in mmdbms", null, uni1);
    Thesis thesis2 = new Thesis(401, author2, 156, "QoS in mmdbms", thesis1, uni2);
    Thesis thesis3 = new Thesis(402, author3, 113, "Why mmdbms?", thesis2, uni3);
   
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detail").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the thesis\n " + thesis1.toString() + "\n");
    pm.makePersistent(thesis1);
    logger.log(BasicLevel.DEBUG, "make persistent the thesis\n " + thesis2.toString() + "\n");
    pm.makePersistent(thesis2);
    logger.log(BasicLevel.DEBUG, "make persistent the thesis\n " + thesis3.toString() + "\n");
    pm.makePersistent(thesis3);
    pm.currentTransaction().commit();
   
    FetchPlan f = pm.getFetchPlan();
    logger.log(BasicLevel.DEBUG, "FG: " + f.getGroups());
   
    pm.currentTransaction().begin();
    Thesis detachedT3 = (Thesis) pm.detachCopy(thesis3);
    try{
      assertEquals(thesis3.getIsbn(), detachedT3.getIsbn());
      assertEquals(thesis3.getType(), detachedT3.getType());
      assertEquals(thesis3.getPageNb(), detachedT3.getPageNb());
      assertEquals(thesis3.getAuthor().getFirstName(), detachedT3.getAuthor().getFirstName());
      assertEquals(thesis3.getAuthor().getName(), detachedT3.getAuthor().getName());
      assertEquals(thesis3.getTitle(), detachedT3.getTitle());
      assertEquals(thesis3.getUniversity().getName(), detachedT3.getUniversity().getName());
      logger.log(BasicLevel.DEBUG, "Isbn can be accessed: " + detachedT3.getIsbn());
      logger.log(BasicLevel.DEBUG, "Type can be accessed: " + detachedT3.getType());
      logger.log(BasicLevel.DEBUG, "PageNb can be accessed: " + detachedT3.getPageNb());
      logger.log(BasicLevel.DEBUG, "Author can be accessed: " + detachedT3.getAuthor().toString());
      logger.log(BasicLevel.DEBUG, "Title can be accessed: " + detachedT3.getTitle());
      logger.log(BasicLevel.DEBUG, "University can be accessed: " + detachedT3.getUniversity().toString());
      logger.log(BasicLevel.DEBUG, "Reference can be accessed: " );
    }
    catch(Exception e){
      if (pm.currentTransaction().isActive())
        pm.currentTransaction().rollback();
      logger.log(BasicLevel.DEBUG, "Error: " + e);
      fail(e.getMessage());
    }
   
    Thesis detachedT2 = detachedT3.getReference();
    try{
      assertEquals(thesis2.getIsbn(), detachedT2.getIsbn());
      assertEquals(thesis2.getType(), detachedT2.getType());
      assertEquals(thesis2.getPageNb(), detachedT2.getPageNb());
      assertEquals(thesis2.getAuthor().getFirstName(), detachedT2.getAuthor().getFirstName());
      assertEquals(thesis2.getAuthor().getName(), detachedT2.getAuthor().getName());
      assertEquals(thesis2.getTitle(), detachedT2.getTitle());
      assertEquals(thesis2.getUniversity().getName(), detachedT2.getUniversity().getName());
     
      logger.log(BasicLevel.DEBUG, "\tIsbn can be accessed: " + detachedT2.getIsbn());
      logger.log(BasicLevel.DEBUG, "\tType can be accessed: " + detachedT2.getType());
      logger.log(BasicLevel.DEBUG, "\tPageNb can be accessed: " + detachedT2.getPageNb());
      logger.log(BasicLevel.DEBUG, "\tAuthor can be accessed: " + detachedT2.getAuthor().toString());
      logger.log(BasicLevel.DEBUG, "\tTitle can be accessed: " + detachedT2.getTitle());
      logger.log(BasicLevel.DEBUG, "\tUniversity can be accessed: " + detachedT2.getUniversity().toString());
      logger.log(BasicLevel.DEBUG, "\tReference should not be accessed: " + detachedT2.getReference().toString());
    }
    catch(Exception e){
      assertEquals(JDODetachedFieldAccessException.class, e.getClass());
      assertTrue(e.getMessage().indexOf("reference") != -1);
      if (pm.currentTransaction().isActive())
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.fetchgroup.Thesis

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.