1
package log2;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import log2.model.Company;
import log2.model.Department;
import log2.model.Employee;
import log2.model.Phone;
public class Populate {
public static void main(String[] args) {
try {
InputStream fis_prop = new FileInputStream("versant.properties");
Properties prop = new Properties();
prop.load(fis_prop);
fis_prop.close();
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(prop);
PersistenceManager pm = pmf.getPersistenceManager();
pm.currentTransaction().begin();
Employee hiep = new Employee("Hiep", new Phone("0668196134"),"Resp. projets");
Employee harry = new Employee("Harry", new Phone("0668196134"),"Resp. ressource humain");
Employee ron = new Employee("Ron", new Phone("0668196134"),"Resp. communication");
Company inria = new Company("INRIA");
Department oasis = new Department("OASIS");
Department orion = new Department("ORION");
oasis.setCompany(inria);
orion.setCompany(inria);
inria.getDepartments().add(oasis);
inria.getDepartments().add(orion);
oasis.getEmployees().add(hiep);
oasis.getEmployees().add(harry);
orion.getEmployees().add(ron);
pm.makePersistent(inria);
pm.currentTransaction().commit();
pm.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
package log2;
import log2.model.Contact;
import javax.jdo.*;
import java.util.*;
import java.io.InputStream;
import java.io.IOException;
public class InsertData {