List of usage examples for org.hibernate Session get
Object get(String entityName, Serializable id);
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public LinkCourseOfferingAssessment getLinkAssessmentById(int id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w ww. jav a 2 s. c om LinkCourseOfferingAssessment c = null; try { c = (LinkCourseOfferingAssessment) session.get(LinkCourseOfferingAssessment.class, id); session.getTransaction().commit(); } catch (Exception e) { HibernateUtil.logException(logger, e); } return c; }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public LinkCourseOfferingTeachingMethod getLinkTeachingMethodById(int id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w ww . j a v a2 s .c o m LinkCourseOfferingTeachingMethod c = null; try { c = (LinkCourseOfferingTeachingMethod) session.get(LinkCourseOfferingTeachingMethod.class, id); session.getTransaction().commit(); } catch (Exception e) { HibernateUtil.logException(logger, e); } return c; }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean saveTimeItTook(int courseOfferingId, int timeItTookId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*ww w .j a va 2 s.com*/ try { CourseOffering c = (CourseOffering) session.get(CourseOffering.class, courseOfferingId); TimeItTook time = (TimeItTook) session.get(TimeItTook.class, timeItTookId); c.setTimeItTook(time); session.merge(c); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean deleteTeachingMethod(int courseOfferingId, int teachingMethodId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from w w w . ja va2s . c o m*/ try { CourseOffering c = (CourseOffering) session.get(CourseOffering.class, courseOfferingId); TeachingMethod tm = (TeachingMethod) session.get(TeachingMethod.class, teachingMethodId); LinkCourseOfferingTeachingMethod link = this.getLinkTeachingMethodByData(c, tm, session); session.delete(link); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean addTeachingMethod(int courseOfferingId, int teachingMethodId, int howLongId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/* ww w . j a va 2s. c o m*/ try { CourseOffering c = (CourseOffering) session.get(CourseOffering.class, courseOfferingId); TeachingMethod tm = (TeachingMethod) session.get(TeachingMethod.class, teachingMethodId); TeachingMethodPortionOption howLong = (TeachingMethodPortionOption) session .get(TeachingMethodPortionOption.class, howLongId); LinkCourseOfferingTeachingMethod link = this.getLinkTeachingMethodByData(c, tm, session); if (link == null) { link = new LinkCourseOfferingTeachingMethod(); link.setCourseOffering(c); link.setHowLong(howLong); link.setTeachingMethod(tm); session.save(link); } else { link.setHowLong(howLong); session.merge(link); } session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean deleteAssessment(int linkId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//from www . j a va 2 s . com try { @SuppressWarnings("unchecked") List<LinkCourseAssessmentFeedbackOption> exitsingOptions = session.createQuery( "FROM LinkCourseAssessmentFeedbackOption WHERE linkCourseOfferingAssessment.id = :linkId") .setParameter("linkId", linkId).list(); for (LinkCourseAssessmentFeedbackOption toDelete : exitsingOptions) { session.delete(toDelete); } LinkCourseOfferingAssessment link = (LinkCourseOfferingAssessment) session .get(LinkCourseOfferingAssessment.class, linkId); session.delete(link); session.getTransaction().commit(); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public LinkCourseOfferingAssessment getLinkCourseOfferingAssessmentById(int id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/* w ww . j a va 2s . com*/ LinkCourseOfferingAssessment toReturn = null; try { toReturn = (LinkCourseOfferingAssessment) session.get(LinkCourseOfferingAssessment.class, id); session.getTransaction().commit(); } catch (Exception e) { HibernateUtil.logException(logger, e); } return toReturn; }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public Assessment getAssessmentById(int id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from w w w .ja v a2 s. c o m*/ Assessment toReturn = null; try { toReturn = (Assessment) session.get(Assessment.class, id); session.getTransaction().commit(); } catch (Exception e) { HibernateUtil.logException(logger, e); } return toReturn; }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public AssessmentGroup getAssessmentGroupById(int id, Session session) { return (AssessmentGroup) session.get(AssessmentGroup.class, id); }
From source file:ca.usask.gmcte.currimap.action.CourseManager.java
License:Open Source License
public boolean saveAssessmentMethodName(int id, String newName) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//from w w w . j a v a 2 s . co m try { Assessment o = (Assessment) session.get(Assessment.class, id); o.setName(newName); session.merge(o); return true; } catch (Exception e) { HibernateUtil.logException(logger, e); try { session.getTransaction().rollback(); } catch (Exception e2) { logger.error("Unable to roll back!", e2); } return false; } }