List of usage examples for org.hibernate FlushMode MANUAL
FlushMode MANUAL
To view the source code for org.hibernate FlushMode MANUAL.
Click Source Link
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
License:Apache License
public User updateUser(User user) { try {//from w ww . java 2s . co m // prevent auto flushing when querying for existing users getSession().setFlushMode(FlushMode.MANUAL); User findUser = findUserByUsernameOrEmailIgnoreCaseAndId(getBaseModelObject(user).getId(), user.getUsername(), user.getEmail()); if (findUser != null) { if (findUser.getEmail().equals(user.getEmail())) { throw new DuplicateEmailException(user.getEmail()); } else { throw new DuplicateUsernameException(user.getUsername()); } } user.updateTimestamp(); getSession().update(user); getSession().flush(); return user; } catch (HibernateException e) { getSession().clear(); throw SessionFactoryUtils.convertHibernateAccessException(e); } catch (ConstraintViolationException cve) { logConstraintViolationException(cve); throw cve; } }
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
License:Apache License
private User findUserByUsernameIgnoreCase(String username) { Session session = getSession();// w ww . ja va2 s . c om Query hibQuery = session.getNamedQuery("user.byUsername.ignorecase").setParameter("username", username); hibQuery.setCacheable(true); hibQuery.setFlushMode(FlushMode.MANUAL); List users = hibQuery.list(); if (users.size() > 0) { return (User) users.get(0); } else { return null; } }
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
License:Apache License
private User findUserByUsernameOrEmailIgnoreCaseAndId(Long userId, String username, String email) { Session session = getSession();/*from ww w. j av a 2 s .c o m*/ Query hibQuery = session.getNamedQuery("user.byUsernameOrEmail.ignorecase.ingoreId") .setParameter("username", username).setParameter("email", email).setParameter("userid", userId); hibQuery.setCacheable(true); hibQuery.setFlushMode(FlushMode.MANUAL); List users = hibQuery.list(); if (users.size() > 0) { return (User) users.get(0); } else { return null; } }
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
License:Apache License
private User findUserByEmail(String email) { Session session = getSession();/* www .j a va2 s.c o m*/ Query hibQuery = session.getNamedQuery("user.byEmail").setParameter("email", email); hibQuery.setCacheable(true); hibQuery.setFlushMode(FlushMode.MANUAL); List users = hibQuery.list(); if (users.size() > 0) { return (User) users.get(0); } else { return null; } }
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
License:Apache License
private User findUserByEmailIgnoreCase(String email) { Session session = getSession();/* ww w . jav a2 s.c om*/ Query hibQuery = session.getNamedQuery("user.byEmail.ignorecase").setParameter("email", email); hibQuery.setCacheable(true); hibQuery.setFlushMode(FlushMode.MANUAL); List users = hibQuery.list(); if (users.size() > 0) { return (User) users.get(0); } else { return null; } }
From source file:org.unitime.banner.dataexchange.BannerCourseOfferingImport.java
License:Apache License
private ItypeDesc findItypeFromBannerReference(String bannerReference) { return ((ItypeDesc) getHibSession().createQuery("from ItypeDesc i where i.sis_ref = :bannerRef") .setString("bannerRef", bannerReference).setCacheable(true).setFlushMode(FlushMode.MANUAL) .uniqueResult());//www. j a va 2 s . co m }
From source file:org.unitime.banner.model.BannerConfig.java
License:Apache License
public static BannerConfig findBannerConfigForInstrOffrConfigAndCourseOffering( InstrOfferingConfig instrOfferingConfig, CourseOffering courseOffering, Session hibSession) { return ((BannerConfig) hibSession .createQuery(/* www. j a va 2 s.co m*/ "select bc from BannerConfig bc where bc.bannerCourse.courseOfferingId = :courseOfferingId " + " and bc.instrOfferingConfigId = :configId") .setLong("configId", instrOfferingConfig.getUniqueId().longValue()) .setLong("courseOfferingId", courseOffering.getUniqueId().longValue()) .setFlushMode(FlushMode.MANUAL).setCacheable(false).uniqueResult()); }
From source file:org.unitime.banner.model.BannerConfig.java
License:Apache License
@SuppressWarnings("unchecked") public static List<BannerConfig> findBannerConfigsForInstrOfferingConfig( InstrOfferingConfig instrOfferingConfig, Session hibSession) { return ((List<BannerConfig>) hibSession .createQuery("select bc from BannerConfig bc where bc.instrOfferingConfigId = :configId") .setLong("configId", instrOfferingConfig.getUniqueId().longValue()).setFlushMode(FlushMode.MANUAL) .setCacheable(false).list()); }
From source file:org.unitime.banner.model.BannerCourse.java
License:Apache License
public static BannerCourse findBannerCourseForCourseOffering(Long courseOfferingId, Session hibSession) { return ((BannerCourse) hibSession .createQuery("from BannerCourse bc where bc.courseOfferingId=:courseOfferingId)") .setLong("courseOfferingId", courseOfferingId.longValue()).setFlushMode(FlushMode.MANUAL) .setCacheable(false).uniqueResult()); }
From source file:org.unitime.banner.model.BannerCourse.java
License:Apache License
@SuppressWarnings("unchecked") public static List<BannerCourse> findBannerCoursesForCourseOffering(Long courseOfferingId, Session hibSession) { return ((List<BannerCourse>) hibSession .createQuery("from BannerCourse bc where bc.courseOfferingId=:courseOfferingId)") .setLong("courseOfferingId", courseOfferingId.longValue()).setFlushMode(FlushMode.MANUAL) .setCacheable(false).list()); }