List of usage examples for org.springframework.dao DataIntegrityViolationException printStackTrace
public void printStackTrace()
From source file:android.apn.androidpn.server.service.impl.UserServiceImpl.java
public User saveUser(User user) throws UserExistsException { try {//from w w w. j av a2s . co m return userDao.saveUser(user); } catch (DataIntegrityViolationException e) { e.printStackTrace(); log.warn(e.getMessage()); throw new UserExistsException("User '" + user.getUsername() + "' already exists!"); } catch (EntityExistsException e) { // needed for JPA e.printStackTrace(); log.warn(e.getMessage()); throw new UserExistsException("User '" + user.getUsername() + "' already exists!"); } }
From source file:com.yilv.service.impl.UserServiceImpl.java
@Transactional(readOnly = false) public User saveUser(User user) throws UserExistsException { try {//from w w w . j av a 2 s . c o m return userDao.saveUser(user); } catch (DataIntegrityViolationException e) { e.printStackTrace(); log.warn(e.getMessage()); throw new UserExistsException("User '" + user.getUsername() + "' already exists!"); } catch (EntityExistsException e) { // needed for JPA e.printStackTrace(); log.warn(e.getMessage()); throw new UserExistsException("User '" + user.getUsername() + "' already exists!"); } }
From source file:com.siacra.beans.EscuelaBean.java
/** * Delete Escuela/* w w w .j a v a 2 s . c o m*/ * * @param char id - idescuela */ public void deleteEscuela() { try { Escuela escuela = getEscuelaService().getEscuelaById(getIdescuela()); String escuelaEliminada = escuela.getCodigoescuela(); getEscuelaService().deleteEscuela(escuela); addMessage("La Escuela " + escuelaEliminada + " fue eliminada correctamente"); } catch (DataIntegrityViolationException e) { e.printStackTrace(); addMessage("La Escuela no puede ser eliminada debido a que tiene registros relacionados"); } }
From source file:org.openhie.openempi.service.impl.UserManagerImpl.java
/** * {@inheritDoc}/* w ww. java 2 s . c o m*/ */ public User saveUser(User user) throws UserExistsException { if (user.getVersion() == null) { // if new user, lowercase userId user.setUsername(user.getUsername().toLowerCase()); } // Get and prepare password management-related artifacts boolean passwordChanged = false; if (passwordEncoder != null) { // Check whether we have to encrypt (or re-encrypt) the password if (user.getVersion() == null) { // New user, always encrypt passwordChanged = true; } else { // Existing user, check password in DB String currentPassword = dao.getUserPassword(user.getUsername()); if (currentPassword == null) { passwordChanged = true; } else { if (!currentPassword.equals(user.getPassword())) { passwordChanged = true; } } } // If password was changed (or new user), encrypt it if (passwordChanged) { user.setPassword(passwordEncoder.encodePassword(user.getPassword(), null)); } } else { log.warn("PasswordEncoder not set, skipping password encryption..."); } try { return dao.saveUser(user); } catch (DataIntegrityViolationException e) { e.printStackTrace(); log.warn(e.getMessage()); throw new UserExistsException("User '" + user.getUsername() + "' already exists!"); } catch (EntityExistsException e) { // needed for JPA e.printStackTrace(); log.warn(e.getMessage()); throw new UserExistsException("User '" + user.getUsername() + "' already exists!"); } }
From source file:com.siacra.beans.AcuerdoBean.java
public void deleteAcuerdo() { try {/*from www . j a v a 2s . co m*/ Acuerdo acuerdo = getAcuerdoService().getAcuerdoById(getIdacuerdo()); String acuerdoEliminado = acuerdo.getCodigoacuerdo(); getAcuerdoService().deleteAcuerdo(acuerdo); addMessage("El acuerdo " + acuerdoEliminado + " fue eliminado correctamente"); } catch (DataIntegrityViolationException e) { e.printStackTrace(); addMessage("El acuerdo no puede ser eliminado debido a que tiene registros relacionados"); } }
From source file:net.frontlinesms.plugins.textforms.ui.ManageTextFormsPanelHandler.java
public void deleteTextForm() { LOG.debug("deleteTextForm"); TextForm textform = this.getSelectedTextForm(); if (textform != null) { try {/* w w w . j a va 2 s . c o m*/ this.textformDao.deleteTextForm(textform); this.queryGenerator.refresh(); } catch (DataIntegrityViolationException ex) { ex.printStackTrace(); this.ui.alert(TextFormsMessages.getHandlerErrorDeleteTextForm()); } } this.ui.removeConfirmationDialog(); }
From source file:com.siacra.beans.ContratoBean.java
/** * Delete Contrato/*from www. j a v a 2s .co m*/ * * * */ public void deleteContrato() { try { Contrato contrato = new Contrato(); contrato = getContratoService().getContratoById(getIdcontrato()); String eliminado = contrato.getTipocontrato(); getContratoService().deleteContrato(contrato); addMessage("El contrato " + eliminado + " fue eliminado correctamente"); } catch (DataIntegrityViolationException e) { e.printStackTrace(); addMessage("El contrato no puede ser eliminado debido a que tiene categorias asociadas"); } }
From source file:com.siacra.beans.EscalafonBean.java
/** * Delete Escalafon//www .j a va2 s . co m * * * */ public void deleteEscalafon() { try { Escalafon escalafon = new Escalafon(); escalafon = getEscalafonService().getEscalafonById(getIdescalafon()); String eliminado = escalafon.getTipoescalafon(); getEscalafonService().deleteEscalafon(escalafon); addMessage("El escalafon " + eliminado + " fue eliminado correctamente"); } catch (DataIntegrityViolationException e) { e.printStackTrace(); addMessage("El escalafon no puede ser eliminado debido a que tiene categorias asociadas"); } }
From source file:migration.JournalMigration.java
/** * general write to database method. Writes all objects in array o to the * database, knowing they are from type ident * //from w w w . j a va2 s .c om * @param o * the o * @param ident * the ident */ private void writeToDB(final Object[] o, final String ident) { for (int i = 0; i < o.length; i++) { try { this.help.write(o[i], ident, this.factory, i); } catch (final org.springframework.dao.DataAccessResourceFailureException e) { // e.printStackTrace(); System.err.println("i: " + i); i--; } catch (final org.springframework.dao.DataIntegrityViolationException v) { v.printStackTrace(); } } }
From source file:com.siacra.beans.ActividadBean.java
/** * Delete Actividad//from ww w . j ava 2s . co m */ public void deleteActividad() { try { Actividad actividad = getActividadService().getActividadById(getIdactividad()); String eliminado = actividad.getNombreactividad(); getActividadService().deleteActividad(actividad); addMessage("La actividad " + eliminado + " fue eliminada correctamente"); refreshActividades(); } catch (DataIntegrityViolationException e) { e.printStackTrace(); addMessage("La actividad no puede ser eliminada, debido a que otros registros ocupan esta actividad"); } }