List of usage examples for javax.persistence PersistenceException getMessage
public String getMessage()
From source file:controllers.contact.Contacts.java
/** * Duzenlemek icin acilmis olan kaydi siler * /*from www . j ava 2 s.co m*/ * @param id */ public static Result remove(Integer id) { Result hasProblem = AuthManager.hasProblem(RIGHT_SCOPE, RightLevel.Delete); if (hasProblem != null) return hasProblem; if (id == null) { flash("error", Messages.get("id.is.null")); } else { Contact model = Contact.findById(id); if (model == null) { flash("error", Messages.get("not.found", Messages.get("contact"))); } else { String editingConstraintError = model.checkEditingConstraints(); if (editingConstraintError != null) { flash("error", editingConstraintError); return badRequest(form.render(dataForm.fill(model))); } try { model.delete(); flash("success", Messages.get("deleted", model.name)); } catch (PersistenceException pe) { log.error(pe.getMessage()); flash("error", Messages.get("delete.violation", model.name)); return badRequest(form.render(dataForm.fill(model))); } } } return GO_HOME; }
From source file:controllers.stock.Stocks.java
/** * Duzenlemek icin acilmis olan kaydi siler * //w ww.ja v a 2 s. co m * @param id */ public static Result remove(Integer id) { Result hasProblem = AuthManager.hasProblem(RIGHT_SCOPE, RightLevel.Delete); if (hasProblem != null) return hasProblem; if (id == null) { flash("error", Messages.get("id.is.null")); } else { Stock model = Stock.findById(id); if (model == null) { flash("error", Messages.get("not.found", Messages.get("stock"))); } else { String editingConstraintError = model.checkEditingConstraints(); if (editingConstraintError != null) { flash("error", editingConstraintError); return badRequest(form.render(dataForm.fill(model))); } try { model.delete(); flash("success", Messages.get("deleted", model.name)); } catch (PersistenceException pe) { log.error(pe.getMessage()); flash("error", Messages.get("delete.violation", model.name)); return badRequest(form.render(dataForm.fill(model))); } } } return GO_HOME; }
From source file:cn.buk.hotel.dao.CityDaoImpl.java
@Override public List<City> getAllCity() { List<City> cities = null; try {//from w w w . j a v a 2s . com cities = getEm().createQuery("select o from City o order by o.openApiId").getResultList(); } catch (PersistenceException e) { logger.error(e.getMessage()); } return cities; }
From source file:cn.buk.hotel.dao.CityDaoImpl.java
@Override public List<City> getCityHotelGreaterThan100() { List<City> cities = null; try {/* w w w . j ava2 s .co m*/ //select o from City o where o.openApiId in (select h.cityId from HotelInfo h group by h.cityId having count(h) > 100) cities = getEm().createQuery( "select o from City o where o.openApiId in (select h.cityId from HotelInfo h group by h.cityId having count(h) > 100)") .getResultList(); } catch (PersistenceException e) { logger.error(e.getMessage()); } return cities; }
From source file:es.ucm.fdi.dalgs.academicTerm.repository.AcademicTermRepository.java
public boolean addAcademicTerm(AcademicTerm academicTerm) { try {/*from ww w. ja v a 2s.c om*/ em.persist(academicTerm); return true; } catch (PersistenceException e) { logger.error(e.getMessage()); return false; } catch (DataIntegrityViolationException e) { logger.error(e.getMessage()); return false; } catch (Exception e) { logger.error(e.getMessage()); return false; } }
From source file:es.ucm.fdi.dalgs.degree.repository.DegreeRepository.java
public boolean addDegree(Degree degree) { try {//from w w w.ja v a2 s.co m em.persist(degree); } catch (PersistenceException e) { logger.error(e.getMessage()); return false; } return true; }
From source file:org.osiam.resources.provisioning.SCIMGroupProvisioning.java
@Override public Group getById(String id) { try {//from w ww . ja v a 2s. com return groupConverter.toScim(groupDao.getById(id)); } catch (NoResultException nre) { LOGGER.log(Level.INFO, nre.getMessage(), nre); throw new ResourceNotFoundException(String.format("Group with id '%s' not found", id), nre); } catch (PersistenceException pe) { LOGGER.log(Level.WARNING, pe.getMessage(), pe); throw new ResourceNotFoundException(String.format("Group with id '%s' not found", id), pe); } }
From source file:org.osiam.resources.provisioning.SCIMUserProvisioning.java
@Override public User getById(String id) { try {// w w w . j av a2 s. c o m UserEntity userEntity = userDao.getById(id); User user = userConverter.toScim(userEntity); return getUserWithoutPassword(user); } catch (NoResultException nre) { LOGGER.log(Level.INFO, nre.getMessage(), nre); throw new ResourceNotFoundException(String.format("User with id '%s' not found", id), nre); } catch (PersistenceException pe) { LOGGER.log(Level.WARNING, pe.getMessage(), pe); throw new ResourceNotFoundException(String.format("User with id '%s' not found", id), pe); } }
From source file:com.telefonica.euro_iaas.commons.dao.AbstractBaseDao.java
/** * {@inheritDoc}/*from w ww. j ava2 s . com*/ */ public T update(T entity) { try { entityManager.merge(entity); entityManager.flush(); return entity; } catch (PersistenceException e) { throw new DaoRuntimeException(e.getMessage(), e); } }
From source file:energy.usef.core.repository.MessageRepositoryTest.java
@Test(expected = PersistenceException.class) public void testCleanupNotAllowed() { try {/* w w w. ja v a 2 s . c om*/ repository.cleanup(new LocalDate("2014-11-22")); } catch (PersistenceException e) { Assert.assertEquals("org.hibernate.exception.ConstraintViolationException: could not execute statement", e.getMessage()); throw e; } }