Package org.objectweb.speedo.pobjects.detach

Examples of org.objectweb.speedo.pobjects.detach.Person


   * Test the detach method
   */
  public void testDetachManyTimes() {
    try {
      long personId = createPersonLong();
      Person detached1 = getPersonById(personId);
      logger.log(BasicLevel.DEBUG, "detached1 address: " + detached1.getAddress().getType());
      Person detached2 = getPersonById(personId);
      logger.log(BasicLevel.DEBUG, "detached2 address: " + detached2.getAddress().getType());
      assertEquals(detached1.getId(), detached2.getId());
      assertEquals(detached1.getAddress().getType(), detached2.getAddress().getType());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here


    }
  /*----------------- PRIVATE METHODS----------------------------*/
  private Object createPerson(){
    logger.log(BasicLevel.DEBUG, "***************createPerson Object*****************");
    Address address = new Address("mail");
    Person person = new Person(address);
    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      pm.currentTransaction().begin();
      pm.makePersistent(person);
      pm.currentTransaction().commit();
View Full Code Here

  }
 
  private long createPersonLong(){
    logger.log(BasicLevel.DEBUG, "***************createPersonLong*****************");
    Address address = new Address("mail");
    Person person = new Person(address);
    PersistenceManager pm = pmf.getPersistenceManager();
    try {
      pm.currentTransaction().begin();
      pm.makePersistent(person);
      pm.currentTransaction().commit();
      return person.getId();
    } catch (Exception e) {
      fail(e.getMessage());
      return -1;
    } finally {
      pm.close();
View Full Code Here

    }
  }
 
  private Person getPersonById(Object personId) {
    logger.log(BasicLevel.DEBUG, "***************getPersonById*****************");
      Person result = null;
      PersistenceManager pm = pmf.getPersistenceManager();
      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 {
View Full Code Here

      return result;
   }
 
  private Person getPersonById(long personId) {
    logger.log(BasicLevel.DEBUG, "***************getPersonById*****************");
      Person result = null;
      PersistenceManager pm = pmf.getPersistenceManager();
      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 {
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.detach.Person

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.