List of usage examples for org.hibernate PropertyValueException getPropertyName
public String getPropertyName()
From source file:cz.nkp.urnnbn.processmanager.persistence.ProcessDAOImplTest.java
License:Open Source License
public void testSaveProcessEmptyLogin() { Process process = buildProcess(); process.setOwnerLogin(null);/*from www .j a v a 2 s . co m*/ try { dao.saveProcess(process); fail(); } catch (PropertyValueException e) { assertEquals(Process.class.getName(), e.getEntityName()); assertEquals("ownerLogin", e.getPropertyName()); } }
From source file:cz.nkp.urnnbn.processmanager.persistence.ProcessDAOImplTest.java
License:Open Source License
public void testSaveProcessEmptyType() { Process process = buildProcess(); process.setType(null);//from ww w. j a va2 s. c om try { dao.saveProcess(process); fail(); } catch (PropertyValueException e) { assertEquals(Process.class.getName(), e.getEntityName()); assertEquals("type", e.getPropertyName()); } }
From source file:cz.nkp.urnnbn.processmanager.persistence.ProcessDAOImplTest.java
License:Open Source License
public void testSaveProcessEmptyState() { Process process = buildProcess(); process.setState(null);/*from w ww . j a v a 2 s. co m*/ try { dao.saveProcess(process); fail(); } catch (PropertyValueException e) { assertEquals(Process.class.getName(), e.getEntityName()); assertEquals("state", e.getPropertyName()); } }
From source file:cz.nkp.urnnbn.processmanager.persistence.XmlTransformationDAOImplTest.java
License:Open Source License
public void testSaveTransformationEmptyLogin() { XmlTransformation saved = dao.saveTransformation(buildTransformation()); saved.setOwnerLogin(null);/*from ww w . j a v a2s . c o m*/ try { dao.saveTransformation(saved); fail(); } catch (PropertyValueException e) { assertEquals(XmlTransformation.class.getName(), e.getEntityName()); assertEquals("ownerLogin", e.getPropertyName()); } }
From source file:cz.nkp.urnnbn.processmanager.persistence.XmlTransformationDAOImplTest.java
License:Open Source License
public void testSaveTransformationEmptyName() { XmlTransformation saved = dao.saveTransformation(buildTransformation()); saved.setName(null);/*from w w w .j av a2 s.c om*/ try { dao.saveTransformation(saved); fail(); } catch (PropertyValueException e) { assertEquals(XmlTransformation.class.getName(), e.getEntityName()); assertEquals("name", e.getPropertyName()); } }
From source file:cz.nkp.urnnbn.processmanager.persistence.XmlTransformationDAOImplTest.java
License:Open Source License
public void testSaveTransformationEmptyXslt() { XmlTransformation saved = dao.saveTransformation(buildTransformation()); saved.setXslt(null);/* ww w.j ava 2 s . c om*/ try { dao.saveTransformation(saved); fail(); } catch (PropertyValueException e) { assertEquals(XmlTransformation.class.getName(), e.getEntityName()); assertEquals("xslt", e.getPropertyName()); } }
From source file:rest.resteasy.crud.ExceptionHandler.java
License:Open Source License
private InvalidValue[] findInvalidValues(Throwable t) { if (t instanceof InvalidStateException) return ((InvalidStateException) t).getInvalidValues(); if (t instanceof PropertyValueException) { PropertyValueException x = (PropertyValueException) t; // watch it, keep this in sync with exception handling InvalidValue invalidValue = new InvalidValue(x.getMessage(), null, x.getPropertyName(), null, null); InvalidValue[] invalidValues = new InvalidValue[1]; invalidValues[0] = invalidValue; return invalidValues; }//from ww w .j a va 2s . c o m if (t.getCause() != null) return findInvalidValues(t.getCause()); return null; }
From source file:stroom.entity.server.util.EntityServiceExceptionUtil.java
License:Apache License
/** * Unwrap an exception and log it if required. *///from w ww. ja va 2 s. c o m public static String unwrapMessage(final Throwable rootEx, final Throwable e) { if (e instanceof EntityExistsException) { return "Unable to create record as it matches an existing record"; } if (e instanceof OptimisticLockException) { final StringBuilder msg = new StringBuilder(); msg.append("Unable to save record state as it has been updated by another transaction."); return msg.toString(); } if (e instanceof PersistenceException) { final PersistenceException psEx = (PersistenceException) e; if (psEx.getCause() != null) { return unwrapMessage(rootEx, psEx.getCause()); } // Unknown type of error return getDefaultMessage(psEx, rootEx); } if (e instanceof PropertyValueException) { final PropertyValueException pEx = (PropertyValueException) e; final StringBuilder msg = new StringBuilder(); msg.append("Unable to save record state. "); msg.append(pEx.getPropertyName()); msg.append(": "); if (pEx.getMessage().contains("not-null")) { msg.append("mandatory"); } else { msg.append(pEx.getMessage()); } return msg.toString(); } if (e instanceof ConstraintViolationException) { final ConstraintViolationException constraintViolationException = (ConstraintViolationException) e; final StringBuilder msg = new StringBuilder(); msg.append("Unable to save record state. "); for (final ConstraintViolation<?> violation : constraintViolationException.getConstraintViolations()) { msg.append(violation.getPropertyPath().toString()); msg.append(": "); msg.append(violation.getMessage()); msg.append(". "); } return msg.toString(); } if (e instanceof java.sql.SQLException) { final StringBuilder msg = new StringBuilder(); msg.append("Unable to save record state. "); msg.append(e.getMessage()); return msg.toString(); } if (e instanceof EntityServiceException) { return e.getMessage(); } if (e.getCause() != null) { return unwrapMessage(rootEx, e.getCause()); } return getDefaultMessage(e, rootEx); }