private String compositeUniqueConstraintErrorCode(
     Identifiable<?> entity, UniqueConstraint uniqueConstraint) {
   return WordUtils.uncapitalize(jpaUtil.getEntityName(entity))
       + "_"
       + (uniqueConstraint.name() == null
           ? "composite_unique_constraint_error"
           : uniqueConstraint.name().toLowerCase());
 }
 private boolean existsInDatabaseOnAllObjects(Identifiable<?> entity, Map<String, Object> values) {
   if (entity == null || values == null || values.isEmpty()) {
     return false;
   }
   String entityName = jpaUtil.getEntityName(entity);
   String sqlQuery = "select count(c) from " + entityName + " c where";
   boolean first = true;
   for (Map.Entry<String, Object> property : values.entrySet()) {
     sqlQuery += !first ? " and " : " ";
     if (property.getValue() instanceof String) {
       sqlQuery += "upper(" + property.getKey() + ")=:" + property.getKey();
     } else {
       sqlQuery += property.getKey() + "=:" + property.getKey();
     }
     first = false;
   }
   if (entity.isIdSet()) {
     if (!first) {
       sqlQuery += " and";
     }
     sqlQuery += " id<>:id";
   }
   TypedQuery<Long> query = entityManager.createQuery(sqlQuery, Long.class);
   for (Map.Entry<String, Object> property : values.entrySet()) {
     String propertyName = property.getKey();
     Object value = property.getValue();
     if (value instanceof String) {
       value = ((String) value).toUpperCase(LocaleHolder.getLocale());
     }
     query.setParameter(propertyName, value);
   }
   if (entity.isIdSet()) {
     query.setParameter("id", entity.getId());
   }
   return query.getSingleResult() > 0;
 }
 private String simpleUniqueConstraintError(Identifiable<?> entity, String property) {
   return WordUtils.uncapitalize(jpaUtil.getEntityName(entity))
       + "_"
       + property
       + "_already_exists";
 }