1 25 26 package org.objectweb.speedo.tutorial.appli.mapping; 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.mapping.Department; 34 import org.objectweb.speedo.tutorial.pobjects.mapping.Employee; 35 import org.objectweb.speedo.tutorial.pobjects.mapping.Manager; 36 import org.objectweb.speedo.tutorial.pobjects.mapping.Project; 37 import org.objectweb.speedo.tutorial.TutorialHelper; 38 39 42 public class TutorialStep3 { 43 44 private static PersistenceManagerFactory pmf = null; 45 46 50 public static void mapping() { 51 System.out.println( "***************Mapping*****************"); 52 Department department = new Department("Sales"); 54 Manager manager = new Manager("Young Emy", department); 56 department.setManager(manager); 58 Employee employee1 = new Employee("Truffaz Brad", manager); 60 Employee employee2 = new Employee("Serio Laura", manager); 61 Employee employee3 = new Employee("Burley Keith", manager); 62 Employee employee4 = new Employee("Stern Jan", manager); 63 64 Project project1 = new Project("Iris"); 66 Project project2 = new Project("Platine"); 67 68 employee1.addProject(project1); 70 employee2.addProject(project1); 71 employee3.addProject(project1); 72 73 employee1.addProject(project2); 74 employee4.addProject(project2); 75 76 PersistenceManager pm = pmf.getPersistenceManager(); 77 pm.currentTransaction().begin(); 79 System.out.println( "make persistent the project1 " + project1.toString()); 82 pm.makePersistent(project1); 83 System.out.println( "make persistent the project2 " + project2.toString()); 84 pm.makePersistent(project2); 85 pm.currentTransaction().commit(); 86 pm.close(); 87 88 } 89 90 public static void main(String [] args){ 91 TutorialHelper th = null; 92 try { 93 th = new TutorialHelper(args[0]); 94 } catch (IOException e) { 95 e.printStackTrace(); 96 System.exit(-1); 97 } 98 TutorialStep3.pmf = th.getPMF(); 99 TutorialStep3.mapping(); 100 } 101 102 } 103 | Popular Tags |