Package org.objectweb.speedo.tutorial.pobjects.basics

Examples of org.objectweb.speedo.tutorial.pobjects.basics.Address


   */
  public static void makePersistent() {
    System.out.println("***************makePersistent*****************");
    //create a country and 3 addresses
    Country france = new Country("fr", "France");
    Address address1 = new Address("rue de Mons", "Avignon", france);
    Address address2 = new Address("impasse St Jacques", "Clermont", france);
    Address address3 = new Address("rue Laffiteau", "Paris", france);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    //store the graph defined above in the datastore
    pm.currentTransaction().begin();
    //make persistent the 3 addresses:
    // all the references reachable from these objects will be made persistent
    System.out.println("make persistent the address1 " + address1.toString());
        pm.makePersistent(address1);
        System.out.println("make persistent the address2 " + address2.toString());
        pm.makePersistent(address2);
        System.out.println("make persistent the address3 " + address3.toString());
        pm.makePersistent(address3);
        pm.currentTransaction().commit();
        pm.close();
   
  }
View Full Code Here


   * @return the id of the object created
   */
  public static Object createAddress(PersistenceManager pm){
    //create a country and an address
    Country uk = new Country("uk", "United Kingdom");
    Address address = new Address("Sharrow Street", "Sheffield", uk);
    //make persistent
    //all the references reachable from this object will be made persistent
    pm.currentTransaction().begin();
    System.out.println( "make persistent the address " + address.toString());
        pm.makePersistent(address);
        //get the object id
        Object id = pm.getObjectId(address);
        pm.currentTransaction().commit();
        return id;
View Full Code Here

   * Update a persistent object
   */
  public static void updateAddress(PersistenceManager pm, Object id){
    pm.currentTransaction().begin();
        //get the object using its id
    Address address = (Address) pm.getObjectById(id, true);
        System.out.println( "update the address " + address.toString());
        //update
        address.setCity("New York");
        pm.currentTransaction().commit();
  }
View Full Code Here

   * Delete a persistent object
   */
  public static void deleteAddress(PersistenceManager pm, Object id){
    pm.currentTransaction().begin();
        //get the object using its id
    Address address = (Address) pm.getObjectById(id, true);
        System.out.println( "delete the address " + address.toString());
        //delete
        pm.deletePersistent(address);
        pm.currentTransaction().commit();
  }
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.tutorial.pobjects.basics.Address

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.