1 9 10 package addressbook; 11 12 import addressbook.Address; 13 import java.util.ArrayList ; 14 import java.util.Collection ; 15 import java.util.List ; 16 import javax.persistence.EntityManager; 17 import javax.persistence.EntityManagerFactory; 18 import javax.persistence.EntityTransaction; 19 20 24 public class DBHelper { 25 26 27 private DBHelper() { 28 } 29 30 private static Collection <Person> createPersons() { 31 Collection <Person> retVal = new ArrayList <Person>(5); 32 Person p = new Person(); 33 p.setName("Tomas"); 34 p.setSurname("Novak"); 35 Address a = new Address(); 36 a.setCity("Brno"); 37 a.setCountry("Czech Republic"); 38 a.setStreet("Za Skolou 15"); 39 p.setAddress(a); 40 retVal.add(p); 41 42 p = new Person(); 43 p.setName("Petr"); 44 p.setSurname("Hanzelka"); 45 a = new Address(); 46 a.setCity("Prague"); 47 a.setCountry("Czech Republic"); 48 a.setStreet("Delostrelecka 8"); 49 p.setAddress(a); 50 retVal.add(p); 51 52 p = new Person(); 53 p.setName("Jan"); 54 p.setSurname("Koudelka"); 55 a = new Address(); 56 a.setCity("Trnava"); 57 a.setCountry("Slovak Republic"); 58 a.setStreet("Slovakova 3"); 59 p.setAddress(a); 60 retVal.add(p); 61 62 p = new Person(); 63 p.setAddress(a); 64 p.setName("Petr"); 65 p.setSurname("Novak"); 66 a = new Address(); 67 a.setCity("Prague"); 68 a.setCountry("Czech Republic"); 69 a.setStreet("Za Skolou 15"); 70 retVal.add(p); 71 72 p = new Person(); 73 p.setName("Alexandr"); 74 p.setSurname("Nikiticenko"); 75 a = new Address(); 76 a.setCity("Moscow"); 77 a.setCountry("Russia"); 78 a.setStreet("Main Street 17e"); 79 p.setAddress(a); 80 retVal.add(p); 81 return retVal; 82 } 83 } 84 | Popular Tags |