@Override protected Object process(EntityManager em, Object... params) throws ClassNotFoundException { // TODO Auto-generated method stub DAO<User> udao = new DAO<User>(User.class, em); User u = udao.singleResultQueryRead(User.class, "User.getById", params[0]); return u.getCreatedCourses(); }
@Override protected Object process(EntityManager em, Map<String, Object> params) throws Exception { // TODO Auto-generated method stub String userID = (String) params.get("userID"); DAO<User> udao = new DAO<User>(User.class, em); User user = null; user = udao.singleResultRead(userID, User.class); return user; }
@Override protected Object process(EntityManager em, Object... params) throws ClassNotFoundException { // TODO Auto-generated method stub DAO<Experiment> edao = new DAO<Experiment>(Experiment.class, em); Experiment e = edao.singleResultQueryRead(Experiment.class, "Experiment.getById", params[0]); DAO<Course> cdao = new DAO<Course>(Course.class, em); Course course = cdao.singleResultQueryRead(Course.class, "Course.getById", params[1]); course.removeExperiment(e); cdao.update(course); return null; }
@Before public void setUp() throws ClassNotFoundException { EntityManagerFactory emf = EntityManagerFactoryCreator.getInstance().getEntityManagerFactory(); EntityManager em = emf.createEntityManager(); DAO<User> udao = new DAO<User>(User.class, em); User u = new User(); u.setId("2011052407"); u.setClassification("11se"); u.setUserType(UserType.STUDENT); User u1 = new User(); u1.setId("2011052406"); u1.setClassification("11se"); u1.setUserType(UserType.STUDENT); User u2 = new User(); u2.setId("2011052405"); u2.setClassification("11se"); u2.setUserType(UserType.STUDENT); User u3 = new User(); u3.setId("2011052404"); u3.setClassification("10se"); u3.setUserType(UserType.STUDENT); User u4 = new User(); u4.setId("2011052403"); u4.setClassification("10se"); u4.setUserType(UserType.STUDENT); User u5 = new User(); u5.setId("2011052402"); u5.setClassification("10se"); u5.setUserType(UserType.STUDENT); User u6 = new User(); u6.setId("2011052401"); u6.setClassification("dq"); u6.setUserType(UserType.PROFESSOR); em.getTransaction().begin(); udao.create(u); udao.create(u1); udao.create(u2); udao.create(u3); udao.create(u4); udao.create(u5); udao.create(u6); Course c1 = new Course(); Course c2 = new Course(); u6.createCourse(c1); u6.createCourse(c2); udao.update(u6); em.getTransaction().commit(); }
@Override protected Object process(EntityManager em, Object... params) throws ClassNotFoundException { // TODO Auto-generated method stub DAO<Course> cdao = new DAO<Course>(Course.class, em); return cdao.multiResultQueryRead(Course.class, "Course.getOpen", params[0]); }