Examples of detachCopy()


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

Examples of javax.jdo.PersistenceManager.detachCopy()

    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

Examples of javax.jdo.PersistenceManager.detachCopy()

    //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

Examples of javax.jdo.PersistenceManager.detachCopy()

    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

Examples of javax.jdo.PersistenceManager.detachCopy()

        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

Examples of javax.jdo.PersistenceManager.detachCopy()

      //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

Examples of javax.jdo.PersistenceManager.detachCopy()

    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

Examples of org.apache.openjpa.persistence.OpenJPAEntityManager.detachCopy()

        assertTrue(em.contains(e20));
        assertFalse(em.isDetached(e20));
        verifySerializable(e20, true, false);
       
        // Test new detachCopy() method added in 2.0.0
        Entity20 e20copy = em.detachCopy(e20);
        if (log.isTraceEnabled())
            log.trace("** TestDetachCopy20() - after detachCopy");
        // verify e20 is same as above
        assertTrue(em.contains(e20));
        assertFalse(em.isDetached(e20));
View Full Code Here

Examples of org.datanucleus.state.StateManager.detachCopy()

            if (sm == null)
            {
                throw new NucleusUserException(LOCALISER.msg("010007", getApiAdapter().getIdForObject(thePC)));
            }

            return sm.detachCopy(state);
        }
        finally
        {
            clr.unsetPrimary();
        }
View Full Code Here

Examples of org.jpox.sco.SCO.detachCopy()

                }
                SCO sco = (SCO)value;

                if (copy)
                {
                    return sco.detachCopy(state);
                }

                if (sco instanceof Collection)
                {
                    // Detach all PC elements of the collection
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.