Beispiel #1
0
 // #list-validate
 public List<ValidationError> validate() {
   List<ValidationError> errors = new ArrayList<ValidationError>();
   if (User.byEmail(email) != null) {
     errors.add(new ValidationError("email", "This e-mail is already registered."));
   }
   return errors.isEmpty() ? null : errors;
 }
Beispiel #2
0
    public Object run(Connection connection, Object argument) throws Throwable {
      String[] vals = (String[]) argument;
      List<Integer> keys = new ArrayList<Integer>();
      for (String val : vals) {
        Integer key =
            connection
                .createQuery(
                    "insert into testRunInsideTransactionWithResultTable(value) values(:val)",
                    "runnerWithResultTester")
                .addParameter("val", val)
                .executeUpdate()
                .getKey(Integer.class);
        keys.add(key);
      }

      return keys;
    }
 private static <T> List<T> join(List<? extends T> list, T element) {
   List<T> result = new ArrayList<T>(list.size() + 1);
   result.addAll(list);
   result.add(element);
   return result;
 }