Examples of SpiTransaction


Examples of com.avaje.ebeaninternal.api.SpiTransaction

 
 
    private PreparedStatement bindStmt(PersistRequestUpdateSql request, boolean batchThisRequest) throws SQLException {
       
      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){
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

    /**
     * Execute the orm update request.
     */
    public int execute(PersistRequestOrmUpdate request) {

        SpiTransaction t = request.getTransaction();
       
        boolean batchThisRequest = t.isBatchThisRequest();
       
        PreparedStatement pstmt = null;
        try {
           
          pstmt = bindStmt(request, batchThisRequest);
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

    }
 
    private PreparedStatement bindStmt(PersistRequestOrmUpdate request, boolean batchThisRequest) throws SQLException {
       
      SpiUpdate<?> ormUpdate = request.getOrmUpdate();
      SpiTransaction t = request.getTransaction();
     
      String sql = ormUpdate.getUpdateStatement();
     
      // 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;
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

        query.setIdList(idList);
      }
     
      BeanIdList result = new BeanIdList(idList);
     
      SpiTransaction t = request.getTransaction();
      Connection conn = t.getInternalConnection();
      pstmt = conn.prepareStatement(sql);
     
      if (query.getBufferFetchSizeHint() > 0){
        pstmt.setFetchSize(query.getBufferFetchSizeHint());
      }
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

        q.setPersistenceContext(new DefaultPersistenceContext());
        q.setAutofetch(false);
        q.select(sb.toString());
        q.where().idEq(id);

        SpiTransaction t = request.getTransaction();
        if (t.isLogSummary()) {
          t.logSummary("-- Ebean fetching foreign key values for delete of " + descriptor.getName() + " id:" + id);
        }
        beanWithForeignKeys = (EntityBean)server.findUnique(q, t);
    }
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

    /**
     * execute the CallableSql requests.
     */
    public int execute(PersistRequestCallableSql request) {

        SpiTransaction t = request.getTransaction();
       
        boolean batchThisRequest = t.isBatchThisRequest();
       
        CallableStatement cstmt = null;
        try {
           
          cstmt = bindStmt(request, batchThisRequest);
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

 
 
    private CallableStatement bindStmt(PersistRequestCallableSql request, boolean batchThisRequest) throws SQLException {
       
      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){
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

  public int findRowCount() throws SQLException {

    startNano = System.nanoTime();
    try {
     
      SpiTransaction t = request.getTransaction();
      Connection conn = t.getInternalConnection();
      pstmt = conn.prepareStatement(sql);
 
      if (query.getTimeout() > 0){
        pstmt.setQueryTimeout(query.getTimeout());
      }
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

    SpiSqlQuery query = request.getQuery();

    long startTime = System.currentTimeMillis();

    SpiTransaction t = request.getTransaction();
    Connection conn = t.getInternalConnection();
    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;
          if (TransactionManager.SQL_LOGGER.isTraceEnabled()) {
            logSql = Str.add(logSql, "; --bind(", bindLog, ")");
          }
          t.logSql(logSql);
        }
 
        rset = pstmt.executeQuery();
 
        propNames = getPropertyNames(rset);
      }
     
      // calculate the initialCapacity of the Map to reduce
      // rehashing for queries with 12+ columns
      float initCap = (propNames.length) / 0.7f;
      int estimateCapacity = (int) initCap + 1;

      // determine the maxRows limit
      int maxRows = defaultMaxRows;
      if (query.getMaxRows() >= 1) {
        maxRows = query.getMaxRows();
      }

      int loadRowCount = 0;

      SqlQueryListener listener = query.getListener();

      BeanCollectionWrapper wrapper = new BeanCollectionWrapper(request);
      boolean isMap = wrapper.isMap();
      String mapKey = query.getMapKey();
     
      SqlRow bean = null;
     
      while (rset.next()) {
        synchronized (query) {         
          // synchronise for query.cancel() support   
          if (!query.isCancelled()){
            bean = readRow(request, rset, propNames, estimateCapacity);
          }
        }
        if (bean != null){
          // bean can be null if query cancelled
          if (listener != null) {
            listener.process(bean);
 
          } else {
            if (isMap) {
              Object keyValue = bean.get(mapKey);
              wrapper.addToMap(bean, keyValue);
            } else {
              wrapper.addToCollection(bean);
            }
          }
 
          loadRowCount++;
 
          if (loadRowCount == maxRows) {
            // break, as we have hit the max rows to fetch...
            break;
          }
        }
      }

      BeanCollection<?> beanColl = wrapper.getBeanCollection();

      if (request.isLogSummary()) {
        long exeTime = System.currentTimeMillis() - startTime;
        String msg = "SqlQuery  rows[" + loadRowCount + "] time[" + exeTime + "] bind[" + bindLog + "]";
        t.logSummary(msg);
      }
     
      if (query.isCancelled()){
        logger.debug("Query was cancelled during execution rows:"+loadRowCount);
      }
View Full Code Here

Examples of com.avaje.ebeaninternal.api.SpiTransaction

  /**
   * Flushes the jdbc batch by default unless explicitly turned off on the transaction.
   */
  private <T> void flushJdbcBatchOnQuery(OrmQueryRequest<T> request) {

    SpiTransaction t = request.getTransaction();
    if (t.isBatchFlushOnQuery()) {
      // before we perform a query, we need to flush any
      // previous persist requests that are queued/batched.
      // The query may read data affected by those requests.
      t.flushBatch();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.