@Override
 public StatementBuilder getStatementBuilder() {
   StatementBuilder statementBuilder = new OracleStatementBuilder();
   statementBuilder.setConverter(new DefaultBeanPropertyConverter());
   statementBuilder.setInterceptor(interceptor);
   return statementBuilder;
 }
Example #2
0
 /**
  * Convert an int array to the Java source code that represents this array. Null will be converted
  * to 'null'.
  *
  * @param array the int array
  * @return the Java source code (including new int[]{})
  */
 public static String quoteJavaIntArray(int[] array) {
   if (array == null) {
     return "null";
   }
   StatementBuilder buff = new StatementBuilder("new int[]{");
   for (int a : array) {
     buff.appendExceptFirst(", ");
     buff.append(a);
   }
   return buff.append('}').toString();
 }
Example #3
0
  public static Map<Long, Long> loadZutaten(Long id, Connection con) throws SQLException {
    Map<Long, Long> zutaten = new HashMap<Long, Long>();

    String sql = "select zut_id, menge from zut2rez where rez_id = ?";
    PreparedStatement stmt = null;
    StatementBuilder builder = new StatementBuilder();
    stmt = builder.buildQuery(sql, con);
    stmt.setLong(1, id);
    ResultSet rs = stmt.executeQuery();

    while (rs.next()) {
      zutaten.put(rs.getLong("zut_id"), rs.getLong("menge"));
    }

    return zutaten;
  }
Example #4
0
 /**
  * Combine an array of strings to one array using the given separator character. A backslash and
  * the separator character and escaped using a backslash.
  *
  * @param list the string array
  * @param separatorChar the separator character
  * @return the combined string
  */
 public static String arrayCombine(String[] list, char separatorChar) {
   StatementBuilder buff = new StatementBuilder();
   for (String s : list) {
     buff.appendExceptFirst(String.valueOf(separatorChar));
     if (s == null) {
       s = "";
     }
     for (int j = 0, length = s.length(); j < length; j++) {
       char c = s.charAt(j);
       if (c == '\\' || c == separatorChar) {
         buff.append('\\');
       }
       buff.append(c);
     }
   }
   return buff.toString();
 }
Example #5
0
 private QueryBuilder<T, ID> checkQueryBuilderMethod(String methodName) throws SQLException {
   if (statementBuilder instanceof QueryBuilder) {
     return (QueryBuilder<T, ID>) statementBuilder;
   } else {
     throw new SQLException(
         "Cannot call " + methodName + " on a statement of type " + statementBuilder.getType());
   }
 }
  public List<Statement> getOutOfPackageStatements() {
    List<Statement> statements = new ArrayList<Statement>();

    List<LinkedListTree> statementsAST =
        ASTUtils.findChildrenByType(ast, AS3Parser.OUT_OF_FUNCTION_STMT);
    for (LinkedListTree statementAST : statementsAST) {
      final LinkedListTree child = statementAST.getFirstChild();
      if (child != null) {
        statements.add(StatementBuilder.build(child));
      }
    }

    return statements;
  }
Example #7
0
  public static List findRezepte(Query q, Connection con) throws SQLException {
    PreparedStatement stmt = null;
    ResultSet rs = null;

    try {
      StatementBuilder builder = new StatementBuilder();
      builder.add("id", q.getExpression("id"));
      builder.add("name", q.getExpression("name"));
      builder.add("anleitung", q.getExpression("anleitung"));

      if (q.getResultType() == ResultType.NAMES) {
        stmt = builder.buildQuery("select id, name from rezept", con);

        return makeNameList(stmt.executeQuery());
      } else {
        stmt = builder.buildQuery("select id, name, anleitung, bzr_login from rezept ", con);
        return makeObjectList(stmt.executeQuery());
      }
    } finally {
      DbUtil.close(rs, stmt);
    }
  }
Example #8
0
 public PreparedDelete<T> prepareDelete() throws SQLException {
   return statementBuilder.prepareStatement(null);
 }
Example #9
0
 /** A short-cut for calling {@link QueryBuilder#prepare()}. */
 public PreparedQuery<T> prepare() throws SQLException {
   return statementBuilder.prepareStatement(null);
 }
Example #10
0
 @Override
 public void reset() {
   super.reset();
   updateClauseList = null;
 }