use of org.jowidgets.cap.common.api.exception.UniqueConstraintViolationException in project jo-client-platform by jo-source.
the class UniqueConstraintCheckerImpl method checkCreation.
@Override
public void checkCreation(final Collection<? extends IBeanData> beansData, final IExecutionCallback executionCallback) {
final IFilter filter = createFilter(beansData);
final SyncResultCallback<Integer> resultCallback = new SyncResultCallback<Integer>();
final List<IBeanKey> parentBeanKeys = Collections.emptyList();
this.readerService.count(resultCallback, parentBeanKeys, filter, null, executionCallback);
final Integer result = resultCallback.getResultSynchronious();
if (result != null && result.intValue() > 0) {
throw new UniqueConstraintViolationException(propertyNames);
}
}
use of org.jowidgets.cap.common.api.exception.UniqueConstraintViolationException in project jo-client-platform by jo-source.
the class HibernateOracleExceptionDecoratorImpl method decorate.
@Override
public Throwable decorate(final Throwable original) {
if (original instanceof PersistenceException) {
final PersistenceException persistenceException = (PersistenceException) original;
final Throwable cause = persistenceException.getCause();
if (cause instanceof ConstraintViolationException) {
final String constraintName = getConstraintName((ConstraintViolationException) cause);
if (!EmptyCheck.isEmpty(constraintName)) {
final ConstraintType constraintType = getConstraintType(constraintName);
if (constraintType == ConstraintType.FK) {
return new ForeignKeyConstraintViolationException();
} else if (constraintType != ConstraintType.UNSUPPORTED) {
final List<String> properties = getViolatedProperties(constraintName, constraintType);
if (!EmptyCheck.isEmpty(properties)) {
return new UniqueConstraintViolationException(properties);
}
}
}
}
}
return original;
}
Aggregations