List of usage examples for org.hibernate Session merge
Object merge(Object object);
From source file:ca.usask.gmcte.currimap.action.CharacteristicManager.java
License:Open Source License
public boolean saveCharacteristicDescriptionById(String newDescription, String id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*w ww . ja va 2 s. c o m*/ try { Characteristic c = this.getCharacteristicById(Integer.parseInt(id), session); c.setDescription(newDescription); 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.CharacteristicManager.java
License:Open Source License
public boolean saveCharacteristicTypeNameById(String newName, String id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//from w w w . ja v a2s. com try { CharacteristicType c = this.getCharacteristicTypeById(Integer.parseInt(id), session); c.setName(newName); 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.CharacteristicManager.java
License:Open Source License
public boolean saveCharacteristicTypeValueTypeById(String newValue, String id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//from w w w. j a v a 2 s .c o m try { CharacteristicType c = this.getCharacteristicTypeById(Integer.parseInt(id), session); c.setValueType(newValue); 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.CharacteristicManager.java
License:Open Source License
public boolean saveCharacteristicTypeShortDisplayById(String newName, String id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w ww. jav a 2s .c o m try { CharacteristicType c = this.getCharacteristicTypeById(Integer.parseInt(id), session); c.setShortDisplay(newName); 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.CharacteristicManager.java
License:Open Source License
public boolean saveCharacteristicTypeQuestionById(String newName, String id) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from w ww . j av a 2 s . c om*/ try { CharacteristicType c = this.getCharacteristicTypeById(Integer.parseInt(id), session); c.setQuestionDisplay(newName); 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.CharacteristicManager.java
License:Open Source License
public boolean moveCharacteristic(int id, int charTypeId, String direction) { //when moving up, find the one to be moved (while keeping track of the previous one) and swap display_index values //when moving down, find the one to be moved, swap displayIndex values of it and the next one //when deleting, reduce all links following one to be deleted by 1 boolean done = false; Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w w w . j a va 2 s.c o m try { CharacteristicType ct = (CharacteristicType) session.get(CharacteristicType.class, charTypeId); List<Characteristic> existing = this.getCharacteristicsForType(ct, session); if (direction.equals("up")) { Characteristic prev = null; for (Characteristic ch : existing) { if (ch.getId() == id && prev != null) { int swap = prev.getDisplayIndex(); prev.setDisplayIndex(ch.getDisplayIndex()); ch.setDisplayIndex(swap); session.merge(prev); session.merge(ch); done = true; break; } prev = ch; } } else if (direction.equals("down")) { Characteristic prev = null; for (Characteristic ch : existing) { if (prev != null) { int swap = prev.getDisplayIndex(); prev.setDisplayIndex(ch.getDisplayIndex()); ch.setDisplayIndex(swap); session.merge(prev); session.merge(ch); done = true; break; } if (ch.getId() == id) { prev = ch; } } } else if (direction.equals("delete")) { Characteristic toDelete = null; for (Characteristic ch : existing) { if (toDelete != null) { ch.setDisplayIndex(ch.getDisplayIndex() - 1); session.merge(ch); } if (ch.getId() == id) { toDelete = ch; } } if (toDelete != null) { session.delete(toDelete); done = true; } } session.getTransaction().commit(); return done; } 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 setCommentsForCourseOffering(int id, String comments, String type) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from www . java 2 s . com*/ try { CourseOffering c = (CourseOffering) session.get(CourseOffering.class, id); if (type.equals("teaching_comment")) c.setTeachingComment(comments); else if (type.equals("contribution_comment")) c.setContributionComment(comments); else if (type.equals("outcome_comment")) c.setOutcomeComment(comments); else c.setComments(comments); 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 updateCourseOffering(CourseOffering c, String sectionNumber, String term, String medium) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from ww w.j av a2s .c om*/ try { c.setSectionNumber(sectionNumber.toUpperCase()); c.setTerm(term); c.setMedium(medium); 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 updateLinkCourseOfferingTeachingMethod(int id, int teachingMethod, int howLongId) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from w w w. j av a2 s . c o m*/ try { LinkCourseOfferingTeachingMethod o = (LinkCourseOfferingTeachingMethod) session .get(LinkCourseOfferingTeachingMethod.class, id); TeachingMethod tm = (TeachingMethod) session.get(TeachingMethod.class, teachingMethod); TeachingMethodPortionOption howLong = (TeachingMethodPortionOption) session .get(TeachingMethodPortionOption.class, howLongId); o.setHowLong(howLong); o.setTeachingMethod(tm); session.merge(o); 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 updateLinkCourseOfferingAssessment(int id, int assessmentId, double weight, int whenId, String criterionExists, double criterionLevel, String criterionSubmitted, String criterionCompleted, String[] additionQuestionResponses, String additionalInfo) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from w w w. j a v a 2 s . c o m*/ try { LinkCourseOfferingAssessment o = (LinkCourseOfferingAssessment) session .get(LinkCourseOfferingAssessment.class, id); deleteExistingAdditionalAssessmentOptions(o, session); createNewAdditionalAssessmentOptions(o, additionQuestionResponses, session); AssessmentTimeOption when = (AssessmentTimeOption) session.get(AssessmentTimeOption.class, whenId); Assessment assessment = (Assessment) session.get(Assessment.class, assessmentId); o.setWhen(when); o.setWeight(weight); o.setAdditionalInfo(additionalInfo); o.setCriterionExists(criterionExists); o.setCriterionLevel(criterionLevel); o.setCriterionCompleted(criterionCompleted); o.setCriterionSubmitted(criterionSubmitted); o.setAssessment(assessment); session.merge(o); 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; } }