public Course CourseSave(Integer programmeId, String courseCode, String courseName, String creator, Date create_date) {
s = sessionFactory.openSession();
Transaction t = null;
Programme pro = new Programme();
UserList u = new UserList();
try {
t = s.beginTransaction();
pro.setProgrammeId(programmeId);
u.setEmailId(creator);
Course CourseModel = new Course();
CourseModel.setCourseCode(courseCode);
CourseModel.setCourseName(courseName);
CourseModel.setProgramme(pro);
CourseModel.setCoursCreator(u);
CourseModel.setCourceCreatorDate(create_date);
s.save(CourseModel);
t.commit();
return CourseModel;
} catch (Throwable ex) {
//Log the Exception
t.rollback();
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
} finally {
s.close();
sessionFactory.close();
}
}
s = sessionFactory.openSession();
Transaction t = null;
Programme pro = new Programme();
UserList u = new UserList();
try {
t = s.beginTransaction();
pro.setProgrammeId(programmeId);
u.setEmailId(creator);
Course CourseModel = new Course();
CourseModel.setCourseCode(courseCode);
CourseModel.setCourseName(courseName);
CourseModel.setProgramme(pro);
CourseModel.setCoursCreator(u);
CourseModel.setCourceCreatorDate(create_date);
s.save(CourseModel);
t.commit();
return CourseModel;
} catch (Throwable ex) {
//Log the Exception
t.rollback();
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
} finally {
s.close();
sessionFactory.close();
}
}