Package com.avaje.ebeaninternal.api

Examples of com.avaje.ebeaninternal.api.BindParams


   * be consistent with JDBC PreparedStatement. You need to set a parameter value for each ? you
   * have in the query.
   */
  public DefaultOrmQuery<T> setParameter(int position, Object value) {
    if (bindParams == null) {
      bindParams = new BindParams();
    }
    bindParams.setParameter(position, value);
    return this;
  }
View Full Code Here


  /**
   * Set a named bind parameter. Named parameters have a colon to prefix the name.
   */
  public DefaultOrmQuery<T> setParameter(String name, Object value) {
    if (bindParams == null) {
      bindParams = new BindParams();
    }
    bindParams.setParameter(name, value);
    return this;
  }
View Full Code Here

      SpiSqlUpdate updateSql = request.getUpdateSql();
      SpiTransaction t = request.getTransaction();
     
      String sql = updateSql.getSql();
     
      BindParams bindParams = updateSql.getBindParams();
       
      // process named parameters if required
      sql = BindParamsParser.parse(bindParams, sql);
       
      boolean logSql = request.isLogSql();
     
      PreparedStatement pstmt;
      if (batchThisRequest){
        pstmt = pstmtFactory.getPstmt(t, logSql, sql, request);
        if (pstmtBatch != null){
          // oracle specific JDBC setting batch size ahead of time
          int batchSize = t.getBatchSize();
          if (batchSize < 1){
            batchSize = defaultBatchSize;
          }
          pstmtBatch.setBatchSize(pstmt, batchSize);
        }
       
      } else {
          if (logSql){
              t.logSql(sql);
          }
        pstmt = pstmtFactory.getPstmt(t, sql);
      }
     
      if (updateSql.getTimeout() > 0){
        pstmt.setQueryTimeout(updateSql.getTimeout());
      }
     
        String bindLog = null;
        if (!bindParams.isEmpty()){        
          bindLog = binder.bind(bindParams, new DataBind(pstmt));
        }
       
        request.setBindLog(bindLog);
       
View Full Code Here

     
      // convert bean and property names to table and
      // column names if required
      sql = translate(request, sql);
     
      BindParams bindParams = ormUpdate.getBindParams();
       
      // process named parameters if required
      sql = BindParamsParser.parse(bindParams, sql);
       
      ormUpdate.setGeneratedSql(sql);
     
      boolean logSql = request.isLogSql();
     
      PreparedStatement pstmt;
      if (batchThisRequest){
        pstmt = pstmtFactory.getPstmt(t, logSql, sql, request);
       
      } else {
          if (logSql){
              t.logSql(sql);
          }
        pstmt = pstmtFactory.getPstmt(t, sql);
      }
       
        String bindLog = null;
        if (!bindParams.isEmpty()){        
          bindLog = binder.bind(bindParams, new DataBind(pstmt));
        }
       
        request.setBindLog(bindLog);
       
View Full Code Here

  /**
   * Create with a specific server. This means you can use the
   * SqlUpdate.execute() method.
   */
  public DefaultSqlUpdate(EbeanServer server, String sql) {
    this(server, sql, new BindParams());
  }
View Full Code Here

  /**
   * Create with some sql.
   */
  public DefaultSqlUpdate(String sql) {
    this(null, sql, new BindParams());
  }
View Full Code Here

      SpiCallableSql callableSql = request.getCallableSql();
      SpiTransaction t = request.getTransaction();
     
      String sql = callableSql.getSql();
     
      BindParams bindParams = callableSql.getBindParams();
       
      // process named parameters if required
      sql = BindParamsParser.parse(bindParams, sql);
       
      boolean logSql = request.isLogSql();
     
      CallableStatement cstmt;
      if (batchThisRequest){
        cstmt = pstmtFactory.getCstmt(t, logSql, sql, request);
       
      } else {
          if (logSql){
              t.logSql(sql);
          }
        cstmt = pstmtFactory.getCstmt(t, sql);
      }
       
      if (callableSql.getTimeout() > 0){
        cstmt.setQueryTimeout(callableSql.getTimeout());
      }
     
        String bindLog = null;
        if (!bindParams.isEmpty()){
          bindLog = binder.bind(bindParams, new DataBind(cstmt));
        }
       
        request.setBindLog(bindLog);
       
View Full Code Here

    ResultSet rset = null;
    PreparedStatement pstmt = null;

    String sql = query.getQuery();

    BindParams bindParams = query.getBindParams();

    if (!bindParams.isEmpty()) {
      // convert any named parameters if required
      sql = BindParamsParser.parse(bindParams, sql);
    }

    try {

      String bindLog = "";
      String[] propNames = null;
     
      synchronized (query) {
        if (query.isCancelled()){
          logger.trace("Query already cancelled");
          return null;
        }
       
        // synchronise for query.cancel() support   
        pstmt = conn.prepareStatement(sql);
 
        if (query.getTimeout() > 0){
          pstmt.setQueryTimeout(query.getTimeout());
        }
        if (query.getBufferFetchSizeHint() > 0){
          pstmt.setFetchSize(query.getBufferFetchSizeHint());
        }
       
        if (!bindParams.isEmpty()) {
          bindLog = binder.bind(bindParams, new DataBind(pstmt));
        }
 
        if (request.isLogSql()) {
          String logSql = sql;
View Full Code Here

          return new SqlLimitResponse("--ResultSetBasedRawSql", false);
        }
     
        if (!rsql.isParsed()){
            String sql = rsql.getUnparsedSql();
            BindParams bindParams = request.getQuery().getBindParams();
            if (bindParams != null && bindParams.requiresNamedParamsPrepare()){
                // convert named parameters into positioned parameters
                sql = BindParamsParser.parse(bindParams, sql);
            }
           
            return new SqlLimitResponse(sql, false);
View Full Code Here

        StringBuilder sb = new StringBuilder();
        sb.append(sql.getPreFrom());
        sb.append(" ");
       
        String s = sql.getPreWhere();
        BindParams bindParams = request.getQuery().getBindParams();
        if (bindParams != null && bindParams.requiresNamedParamsPrepare()){
            // convert named parameters into positioned parameters
            // Named Parameters only allowed prior to dynamic where
            // clause (so not allowed in having etc - use unparsed)
            s = BindParamsParser.parse(bindParams, s);
        }
View Full Code Here

TOP

Related Classes of com.avaje.ebeaninternal.api.BindParams

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.