Package javax.jdo

Examples of javax.jdo.PersistenceManager.detachCopy()


    f.setNbOfWheels(3);
    f.setSpeedMax(300);
    pm.currentTransaction().commit();
    try {
      //detach the formula one while it is persistent-dirty: the object must be flushed before being detached
      FormulaOne copyOfF = (FormulaOne) pm.detachCopy(f);
      assertEquals(f.getName(), copyOfF.getName());
      assertEquals(f.getColor(), copyOfF.getColor());
      assertEquals(3, copyOfF.getNbOfWheels());
      assertEquals(f.getType(), copyOfF.getType());
      assertEquals(300, copyOfF.getSpeedMax());
View Full Code Here


      try {
        //Object oid = pm.newObjectIdInstance(Person.class, "" + personId);
        Person p = (Person) pm.getObjectById(personId, false);
        if (p != null) {
          p.getAddress();
          result = (Person) pm.detachCopy(p);
        }
      } catch (Exception e) {
        logger.log(BasicLevel.DEBUG, "Person with Key=" + personId + " not found.");
      } finally {
        pm.close();
View Full Code Here

      try {
        Object oid = pm.newObjectIdInstance(Person.class, "" + personId);
        Person p = (Person) pm.getObjectById(oid, false);
        if (p != null) {
          p.getAddress();
          result = (Person) pm.detachCopy(p);
        }
      } catch (Exception e) {
        logger.log(BasicLevel.DEBUG, "Person with Key=" + personId + " not found.");
      } finally {
        pm.close();
View Full Code Here

   
      //set the fetch group to listeIntervenants
      FetchPlan fp = pm.getFetchPlan();
      fp.clearGroups().addGroup("listeIntervenants");
      //detach the  intervenant
      IntervenantHelper copyOfIntervenant1 = (IntervenantHelper) pm.detachCopy(intervenant1);
      assertNotNull(copyOfIntervenant1);
      assertEquals("Nomep of intervenant1 and its detached copy are not the same.", intervenant1.getNomep(), copyOfIntervenant1.getNomep());
      Collection conv = intervenant1.getConventions();
      Collection copyConv = copyOfIntervenant1.getConventions();
      assertEquals("Size of conventions not the same for intervenant1 and its detached copy.", conv.size(), copyConv.size());
View Full Code Here

    pm.currentTransaction().begin();
    pm.makePersistent(t);
    pm.currentTransaction().commit();
    pm.currentTransaction().begin();
    //detach the team t
    Team copyOfT = (Team) pm.detachCopy(t);
    //commit the tx
    pm.currentTransaction().commit();
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "ATTACH BEGIN");
    try
View Full Code Here

    while(it.hasNext()){
      Player p = (Player) it.next();
      p.setAge(99);
    }
    //detach the team t
    Team copyOfT = (Team) pm.detachCopy(t);
    //commit
    pm.currentTransaction().commit();
    pm.currentTransaction().begin();
    try
      //attach the team
View Full Code Here

    //begin
    pm.currentTransaction().begin();
    //detach the team t
    Team copyOfT = null;
    try {
      copyOfT = (Team) pm.detachCopy(t);
      //  modify the coach
      t.setCoach(new Coach("c31", 10, t));
      Iterator it  = t.getPlayers().iterator();
      //modify the players
      while(it.hasNext()){
View Full Code Here

    pm.currentTransaction().begin();
    pm.makePersistent(t);
    pm.currentTransaction().commit();
    pm.currentTransaction().begin();
    //detach the team t
    Team copyOfT = (Team) pm.detachCopy(t);
    //rollback the tx
    pm.currentTransaction().rollback();
    pm.currentTransaction().begin();
    try
      //attach the "invalid" team
View Full Code Here

    while(it.hasNext()){
      Player p = (Player) it.next();
      p.setAge(99);
    }
    //detach the team t
    Team copyOfT = (Team) pm.detachCopy(t);
    //rollback
    pm.currentTransaction().rollback();
    pm.currentTransaction().begin();
    try
      //attach the team
View Full Code Here

    pm.makePersistent(t);
    pm.currentTransaction().commit();
    //begin
    pm.currentTransaction().begin();
    //detach the team t
    Team copyOfT = (Team) pm.detachCopy(t);
    //modify the coach
    t.getCoach().setExperience(99);
    Iterator it  = t.getPlayers().iterator();
    //modify the players
    while(it.hasNext()){
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.