Examples of KeyHolder


Examples of org.springframework.jdbc.support.KeyHolder

      if(orderStatusId!=null){
        String sql = "INSERT INTO "+quoteTable("order_status")+"(order_status_id, language_id, name) VALUES(?, ?, ?)";
        getJdbcOperations().update(sql, orderStatusId,
            desc.getLanguageId(), desc.getName());
      }else{
        KeyHolder keyHolder = new GeneratedKeyHolder();
        getJdbcOperations().update(new PreparedStatementCreator() {
          @Override
          public PreparedStatement createPreparedStatement(Connection con)
              throws SQLException {
            String sql = "INSERT INTO "+quoteTable("order_status")+"(language_id, name) VALUES(?, ?)";
            PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
            ps.setInt(1, desc.getLanguageId());
            ps.setString(2, desc.getName());
            return ps;
          }
        }, keyHolder);
        orderStatusId = keyHolder.getKey().intValue();
      }
    }
  }
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

 
  @Transactional
  @Override
  public void create(final TaxClass taxClass) {
    KeyHolder keyHolder = new GeneratedKeyHolder();
    getJdbcOperations().update(new PreparedStatementCreator() {
      @Override
      public PreparedStatement createPreparedStatement(Connection con)
          throws SQLException {
        String sql = "INSERT INTO "+quoteTable("tax_class")+"(title, description, date_added) VALUES(?,?,?)";
        PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
        ps.setString(1, taxClass.getTitle());
        ps.setString(2, taxClass.getDescription());
        ps.setTimestamp(3, new Timestamp(new Date().getTime()));
        return ps;
      }
    }, keyHolder);
   
    int taxClassId = keyHolder.getKey().intValue();
   
    addTaxRules(taxClassId, taxClass.getTaxRules());
  }
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

 
  @Transactional
  @Override
  public void create(final LanguageForm lang) {
   
    KeyHolder keyHolder = new GeneratedKeyHolder();
    getJdbcOperations().update(new PreparedStatementCreator() {
      @Override
      public PreparedStatement createPreparedStatement(Connection con)
          throws SQLException {
        String sql = "INSERT INTO "+quoteTable("language")+"(name, code, locale, " +
            "directory, filename, image, sort_order, status) VALUES(?,?,?,?,?,?,?,?)";
        PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
        ps.setString(1, lang.getName());
        ps.setString(2, lang.getCode());
        ps.setString(3, lang.getLocaleAsString());
        ps.setString(4, lang.getDirectory());
        ps.setString(5, lang.getFilename());
        ps.setString(6, lang.getImage());
        ps.setInt(7, lang.getSortOrder());
        ps.setInt(8, lang.getStatus());
        return ps;
      }
    }, keyHolder);
   
    int langId = keyHolder.getKey().intValue();
   
    //find default language. We're going to copy text from default language to the new one.
    String langCode = getJdbcOperations().queryForObject("SELECT value FROM "+quoteTable("setting")
        +" WHERE "+quoteName("group")+" = 'config' AND "+quoteName("key")
        +" = 'config_language' AND store_id=0", String.class);
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

 
  @Transactional
  @Override
  public void create(final TaxRate taxRate) {
    KeyHolder keyHolder = new GeneratedKeyHolder();
    getJdbcOperations().update(new PreparedStatementCreator() {
      @Override
      public PreparedStatement createPreparedStatement(Connection con)
          throws SQLException {
        String sql = "INSERT INTO "+quoteTable("tax_rate")+"(name, rate, type, geo_zone_id, date_added, date_modified) VALUES(?,?,?,?,?,?)";
        PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
        ps.setString(1, taxRate.getName());
        ps.setBigDecimal(2, taxRate.getRate());
        ps.setString(3, taxRate.getType());
        ps.setInt(4, taxRate.getGeoZoneId());
        Timestamp timestamp = new Timestamp(new Date().getTime());
        ps.setTimestamp(5, timestamp);
        ps.setTimestamp(6, timestamp);
        return ps;
      }
    }, keyHolder);
   
    int taxRateId = keyHolder.getKey().intValue();
   
    addCustomerGroupIds(taxRateId, taxRate.getCustomerGroupIds());
   
  }
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

 
  @Transactional
  @Override
  public void create(final WeightClass weightClass) {
   
    KeyHolder keyHolder = new GeneratedKeyHolder();
    getJdbcOperations().update(new PreparedStatementCreator() {
      @Override
      public PreparedStatement createPreparedStatement(Connection con)
          throws SQLException {
        String sql = "INSERT INTO " +quoteTable("weight_class")+ "(value) VALUES(?) ";
        PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
        ps.setBigDecimal(1, weightClass.getValue());
        return ps;
      }
    }, keyHolder);
    Integer weightClassId = keyHolder.getKey().intValue();
    addDescsToWeightClass(weightClassId, weightClass.getDescs());
  }
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

      if(stockStatusId!=null){
        String sql = "INSERT INTO "+quoteTable("stock_status")+"(stock_status_id, language_id, name) VALUES(?, ?, ?)";
        getJdbcOperations().update(sql, stockStatusId,
            stockStatus.getLanguageId(), stockStatus.getName());
      }else{
        KeyHolder keyHolder = new GeneratedKeyHolder();
        getJdbcOperations().update(new PreparedStatementCreator() {
          @Override
          public PreparedStatement createPreparedStatement(Connection con)
              throws SQLException {
            String sql = "INSERT INTO "+quoteTable("stock_status")+"(language_id, name) VALUES(?, ?)";
            PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
            ps.setInt(1, stockStatus.getLanguageId());
            ps.setString(2, stockStatus.getName());
            return ps;
          }
        }, keyHolder);
        stockStatusId = keyHolder.getKey().intValue();
      }
    }
  }
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

      if(returnStatusId!=null){
        String sql = "INSERT INTO "+quoteTable("return_status")+"(return_status_id, language_id, name) VALUES(?, ?, ?)";
        getJdbcOperations().update(sql, returnStatusId,
            returnStatus.getLanguageId(), returnStatus.getName());
      }else{
        KeyHolder keyHolder = new GeneratedKeyHolder();
        getJdbcOperations().update(new PreparedStatementCreator() {
          @Override
          public PreparedStatement createPreparedStatement(Connection con)
              throws SQLException {
            String sql = "INSERT INTO "+quoteTable("return_status")+"(language_id, name) VALUES(?, ?)";
            PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
            ps.setInt(1, returnStatus.getLanguageId());
            ps.setString(2, returnStatus.getName());
            return ps;
          }
        }, keyHolder);
        returnStatusId = keyHolder.getKey().intValue();
      }
    }
  }
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

 
  @Transactional
  @Override
  public void create(final VoucherThemeForm vtForm) {
   
    KeyHolder keyHolder = new GeneratedKeyHolder();
    getJdbcOperations().update(new PreparedStatementCreator() {
      @Override
      public PreparedStatement createPreparedStatement(Connection con)
          throws SQLException {
        String sql = "INSERT INTO "+quoteTable("voucher_theme")+" SET image = ?";
        PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
        ps.setString(1, vtForm.getImage());
        return ps;
      }
    }, keyHolder);
    Integer attrId = keyHolder.getKey().intValue();
    vtForm.setId(attrId);
    setAdditionalFormValues(vtForm);
  }
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

      if(returnReasonId!=null){
        String sql = "INSERT INTO "+quoteTable("return_reason")+"(return_reason_id, language_id, name) VALUES(?, ?, ?)";
        getJdbcOperations().update(sql, returnReasonId,
            returnReason.getLanguageId(), returnReason.getName());
      }else{
        KeyHolder keyHolder = new GeneratedKeyHolder();
        getJdbcOperations().update(new PreparedStatementCreator() {
          @Override
          public PreparedStatement createPreparedStatement(Connection con)
              throws SQLException {
            String sql = "INSERT INTO "+quoteTable("return_reason")+"(language_id, name) VALUES(?, ?)";
            PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
            ps.setInt(1, returnReason.getLanguageId());
            ps.setString(2, returnReason.getName());
            return ps;
          }
        }, keyHolder);
        returnReasonId = keyHolder.getKey().intValue();
      }
    }
  }
View Full Code Here

Examples of org.springframework.jdbc.support.KeyHolder

      if(returnActionId!=null){
        String sql = "INSERT INTO "+quoteTable("return_action")+"(return_action_id, language_id, name) VALUES(?, ?, ?)";
        getJdbcOperations().update(sql, returnActionId,
            returnAction.getLanguageId(), returnAction.getName());
      }else{
        KeyHolder keyHolder = new GeneratedKeyHolder();
        getJdbcOperations().update(new PreparedStatementCreator() {
          @Override
          public PreparedStatement createPreparedStatement(Connection con)
              throws SQLException {
            String sql = "INSERT INTO "+quoteTable("return_action")+"(language_id, name) VALUES(?, ?)";
            PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
            ps.setInt(1, returnAction.getLanguageId());
            ps.setString(2, returnAction.getName());
            return ps;
          }
        }, keyHolder);
        returnActionId = keyHolder.getKey().intValue();
      }
    }
  }
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.