1 25 26 package org.objectweb.speedo.tutorial.appli.basics; 27 28 import java.io.IOException ; 29 30 import javax.jdo.PersistenceManager; 31 import javax.jdo.PersistenceManagerFactory; 32 33 import org.objectweb.speedo.tutorial.pobjects.basics.Address; 34 import org.objectweb.speedo.tutorial.pobjects.basics.Country; 35 import org.objectweb.speedo.tutorial.TutorialHelper; 36 37 40 public class TutorialStep1 { 41 42 private static PersistenceManagerFactory pmf = null; 43 47 public static void makePersistent() { 48 System.out.println("***************makePersistent*****************"); 49 Country france = new Country("fr", "France"); 51 Address address1 = new Address("rue de Mons", "Avignon", france); 52 Address address2 = new Address("impasse St Jacques", "Clermont", france); 53 Address address3 = new Address("rue Laffiteau", "Paris", france); 54 55 PersistenceManager pm = pmf.getPersistenceManager(); 56 pm.currentTransaction().begin(); 58 System.out.println("make persistent the address1 " + address1.toString()); 61 pm.makePersistent(address1); 62 System.out.println("make persistent the address2 " + address2.toString()); 63 pm.makePersistent(address2); 64 System.out.println("make persistent the address3 " + address3.toString()); 65 pm.makePersistent(address3); 66 pm.currentTransaction().commit(); 67 pm.close(); 68 69 } 70 71 public static void main(String [] args){ 72 TutorialHelper th = null; 73 try { 74 th = new TutorialHelper(args[0]); 75 } catch (IOException e) { 76 e.printStackTrace(); 77 System.exit(-1); 78 } 79 TutorialStep1.pmf = th.getPMF(); 80 TutorialStep1.makePersistent(); 81 } 82 83 } 84 | Popular Tags |