Package javax.jdo

Examples of javax.jdo.PersistenceManager.detachCopy()


   
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    pm.makePersistent(c);
    //detach the team while it is persistent-new: the object must be flushed before being detached
    Team copyOfT = (Team) pm.detachCopy(t);
    try {
      assertNotNull(copyOfT);
      assertEquals("Town of team and detached team are not the same", t.getTown(), copyOfT.getTown());
      assertEquals("Coach experience of team and detached team are not the same",t.getCoach().getExperience(), copyOfT.getCoach().getExperience());
      assertEquals("Coach name of team and detached team are not the same",t.getCoach().getName(), copyOfT.getCoach().getName());
View Full Code Here


    pm.currentTransaction().commit();
    //update and detach
    pm.currentTransaction().begin();
    c.setExperience(10);
    //detach the team while it is persistent-dirty: the object must be flushed before being detached
    Team copyOfT = (Team) pm.detachCopy(t);
    pm.currentTransaction().commit();
    try {
      assertEquals(10, copyOfT.getCoach().getExperience());
      logger.log(BasicLevel.DEBUG, copyOfT.toString());
    } catch(Exception e) {
View Full Code Here

    //delete
    pm.currentTransaction().begin();
    pm.deletePersistent(c);
    try {
      //detach the coach c while it is persistent-deleted: an exception must be thrown
      pm.detachCopy(c);
      pm.currentTransaction().commit();
    } catch (Exception e) {

        assertEquals("Wrong exception thrown: " + e.getMessage(),
                JDOUserException.class, e.getClass());
View Full Code Here

    pm.currentTransaction().begin();
    pm.deletePersistent(p);
    try{
      // detach the coach c while it is persistent-deleted:
        // an exception must be thrown
      pm.detachCopy(c);
      pm.currentTransaction().commit();
    } catch (Exception e) {
        assertEquals("Wrong exception thrown: " + e.getMessage(),
                JDOUserException.class, e.getClass());
    } finally {
View Full Code Here

        Team copyOfT = null;
        while (itr.hasNext()) {
          Team team = (Team) itr.next();
          assertEquals("The town should be " + t.getTown(), t.getTown(), team.getTown());
          //detach the team t
          copyOfT = (Team) pm.detachCopy(team);
        }
        query.close(collection);
        extent.closeAll();
      assertNotNull(copyOfT);
      assertEquals("Town of team and detached team are not the same", t.getTown(), copyOfT.getTown());
View Full Code Here

      //make persistent the coach
      pm.currentTransaction().begin();
      pm.makePersistent(c);
      pm.currentTransaction().commit();
      //detach a copy
      Coach copyOfC = (Coach) pm.detachCopy(c);
      //create a team referencing the detached coach
      Team t = new Team("LeMans",null, null);
      t.setCoach(copyOfC);
      //make persistent the team
      pm.currentTransaction().begin();
View Full Code Here

    pm.makePersistent(c);
    pm.makePersistent(f);
    pm.currentTransaction().commit();
    try {
      //detach the car c
      Car copyOfC = (Car) pm.detachCopy(c);
      assertNotNull(copyOfC);
      assertEquals(c.getName(), copyOfC.getName());
      assertEquals(c.getColor(), copyOfC.getColor());
      assertEquals(c.getNbOfWheels(), copyOfC.getNbOfWheels());
      assertEquals(c.getType(), copyOfC.getType());
View Full Code Here

      assertEquals(c.getNbOfWheels(), copyOfC.getNbOfWheels());
      assertEquals(c.getType(), copyOfC.getType());
      //  print the car out
      logger.log(BasicLevel.DEBUG, copyOfC.toString());
      //detach the formula one f
      FormulaOne copyOfF = (FormulaOne) pm.detachCopy(f);
      assertNotNull(copyOfF);
      assertEquals(f.getName(), copyOfF.getName());
      assertEquals(f.getColor(), copyOfF.getColor());
      assertEquals(f.getNbOfWheels(), copyOfF.getNbOfWheels());
      assertEquals(f.getType(), copyOfF.getType());
View Full Code Here

    logger.log(BasicLevel.DEBUG, "*************testDetachNonPersistentInherited*****************");
    FormulaOne f = new FormulaOne("sauber", 4, "blue", 274);
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    //    detach the formula one f while it is not persistent
    FormulaOne copyOfF = (FormulaOne) pm.detachCopy(f);
    assertTrue(((JDOPersistentObjectItf) f).jdoIsPersistent());
    pm.currentTransaction().commit();
    try {
      assertNotNull(copyOfF);
      assertEquals(f.getName(), copyOfF.getName());
View Full Code Here

    //delete
    pm.currentTransaction().begin();
    pm.deletePersistent(f);
    try{
      //detach the coach c while it is persistent-deleted: an exception must be thrown
      pm.detachCopy(f);
    } catch(Exception e){
        assertEquals("Wrong exception thrown: ",JDOUserException.class, e.getClass());
    } finally {
      if (pm.currentTransaction().isActive())
        pm.currentTransaction().rollback();
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.