Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl


   * @param sql
   * @param types
   * @return
   */
  public static PreparedStatementCreatorFactory newStmtCreatorFactory(String sql, int... types) {
    return new PreparedStatementCreatorFactory(sql, types);
  }
View Full Code Here


  public Node create(Node newObject) {
    KeyHolder generatedKey = new GeneratedKeyHolder();
    JdbcTemplate j = getJdbcTemplate();
   
    PreparedStatementCreatorFactory creatorFactory =
      new PreparedStatementCreatorFactory(insertSql(),getTypes());
    creatorFactory.setReturnGeneratedKeys(true);
   
    int rows = j.update(creatorFactory.newPreparedStatementCreator(getParameters(newObject)), generatedKey);
    if (rows != 1)
      throw new HiveRuntimeException("Unable to create Resource: "
          + getParameters(newObject));
    if (generatedKey.getKeyList().size() == 0)
      throw new HiveRuntimeException("Unable to retrieve generated primary key");
View Full Code Here

    Lists.copyInto(getParameters(node), params);
    Lists.copyInto(getTypes(), types);
    params[params.length-1] = node.getId();
    types[types.length-1] = Types.INTEGER;
   
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(updateSql(),types);
   
    int rows = j.update(creatorFactory.newPreparedStatementCreator(params));
    if (rows != 1)
      throw new HiveRuntimeException("Unable to update node with id: " + node.getId());
   
    return node;
  }
View Full Code Here

 
  public Node delete(Node node) {
    Object[] parameters = new Object[] { node.getId()};
   
    JdbcTemplate j = getJdbcTemplate();
    PreparedStatementCreatorFactory creatorFactory = new PreparedStatementCreatorFactory(
        "DELETE from node_metadata where id=?",
        new int[] { Types.INTEGER });
    int rows = j.update(creatorFactory
        .newPreparedStatementCreator(parameters));
    if (rows != 1)
      throw new HiveRuntimeException("Unable to delete node for id: " + node.getId());
    return node;
  }
View Full Code Here

    return (Integer) directory.newTransaction().execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus arg0) {
        Integer rowsAffected = 0;
        for (SecondaryIndex secondaryIndex : resource.getSecondaryIndexes()) {
          PreparedStatementCreatorFactory deleteIndexFactory =
            Statements.newStmtCreatorFactory(sql.deleteAllSecondaryIndexKeysForResourceId(secondaryIndex), resource.getColumnType());
          rowsAffected += getJdbcTemplate().update(deleteIndexFactory.newPreparedStatementCreator(parameters));
        }
        return rowsAffected;
      }
    });
  }
View Full Code Here

    //While it is possible to write a record to multiple locations within the Hive, the default implementation
    //inserts a single copy.
    hive.directory().insertPrimaryIndexKey(spork.getType());
    //Next we insert the record into the assigned data node
    Collection<SimpleJdbcDaoSupport> sporkDaos = hive.connection().daoSupport().get(spork.getType(), AccessType.ReadWrite);
    PreparedStatementCreatorFactory stmtFactory =
      new PreparedStatementCreatorFactory(productInsertSql, new int[]{Types.INTEGER, Types.VARCHAR, Types.VARCHAR});
    Object[] parameters = new Object[]{spork.getId(), spork.getName(), spork.getType()};
    for (JdbcDaoSupport dao : sporkDaos)
      dao.getJdbcTemplate().update(stmtFactory.newPreparedStatementCreator(parameters));

    //Update the resource id so that the hive can locate it
    hive.directory().insertResourceId(resourceName, spork.getId(), spork.getType());
    //Finally we update the SecondaryIndex
    hive.directory().insertSecondaryIndexKey(resourceName, "name", spork.getName(), spork.getId());
View Full Code Here

     
      ParsedSql parsedSql1 = this.getParsedSql(sql).getDelegate();
      String sqlToUse1 = NamedParameterUtils.substituteNamedParameters(parsedSql1, paramSource);
      Object[] params = NamedParameterUtils.buildValueArray(parsedSql1, paramSource, null);
      List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql1, paramSource);
      PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse1, declaredParameters);
      pscf.setResultSetType( ResultSet.TYPE_FORWARD_ONLY );
      pscf.setUpdatableResults(false);
      PreparedStatementCreator preparedStatementCreator = pscf.newPreparedStatementCreator(params);
     
      //con.prepareStatement(theSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
     
      preparedStatement = preparedStatementCreator.createPreparedStatement(con);
      this.rs = preparedStatement.executeQuery();
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.