List of usage examples for org.springframework.orm.hibernate5 SessionFactoryUtils convertHibernateAccessException
public static DataAccessException convertHibernateAccessException(HibernateException ex)
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
public void removeUser(User user) { try {// w w w. j a v a 2s .c o m // TODO: should probably let db take care of this with // cacade constaint deleteAllPasswordRecoveries(user); getSession().delete(user); getSession().flush(); } catch (HibernateException e) { getSession().clear(); throw SessionFactoryUtils.convertHibernateAccessException(e); } }
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
public User updateUser(User user) { try {// w w w . ja v a 2 s . c om // 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
public void createPasswordRecovery(PasswordRecovery passwordRecovery) { try {// w ww . j a va 2 s. c o m getSession().save(passwordRecovery); getSession().flush(); } catch (HibernateException e) { getSession().clear(); throw SessionFactoryUtils.convertHibernateAccessException(e); } }
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
public PasswordRecovery getPasswordRecovery(String key) { try {// w w w . j av a 2 s .co m Query hibQuery = getSession().getNamedQuery("passwordRecovery.byKey").setParameter("key", key); hibQuery.setCacheable(true); return (PasswordRecovery) hibQuery.uniqueResult(); } catch (HibernateException e) { getSession().clear(); throw SessionFactoryUtils.convertHibernateAccessException(e); } }
From source file:org.unitedinternet.cosmo.dao.hibernate.UserDaoImpl.java
public void deletePasswordRecovery(PasswordRecovery passwordRecovery) { try {/*from w ww . jav a 2 s. c o m*/ getSession().delete(passwordRecovery); getSession().flush(); } catch (HibernateException e) { getSession().clear(); throw SessionFactoryUtils.convertHibernateAccessException(e); } }