Examples of UpdateQuery


Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

  public void add(T bean, Connection connection, RelationQuery relationQuery) throws SQLException {

    this.preAddRelations(bean, connection, relationQuery);

    UpdateQuery query = null;

    try {

      query = new UpdateQuery(connection, false, this.insertSQL);

      IntegerCounter integerCounter = new IntegerCounter();

      setQueryValues(bean, query, integerCounter, this.columnMap.values());
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

    this.update(bean, transactionHandler.getConnection(), relationQuery);
  }

  public Integer update(T bean, Connection connection, RelationQuery relationQuery) throws SQLException {

    UpdateQuery query = null;

    try {

      this.preUpdateRelations(bean, connection, relationQuery);

      query = new UpdateQuery(connection, false, this.updateSQL);

      IntegerCounter integerCounter = new IntegerCounter();

      // All fields
      this.setQueryValues(bean, query, integerCounter, this.columnMap.values());

      // Keys from SimpleColumns for where statement
      this.setQueryValues(bean, query, integerCounter, this.simpleKeys);

      // Keys from many to one relations for where statement
      this.setQueryValues(bean, query, integerCounter, this.manyToOneRelationKeys.values());

      query.executeUpdate();

    } finally {

      UpdateQuery.autoCloseQuery(query);
    }

    this.updateRelations(bean, connection, relationQuery);

    return query.getAffectedRows();
  }
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

    this.update(lowLevelQuery, transactionHandler.getConnection());
  }

  public void update(LowLevelQuery<T> lowLevelQuery, Connection connection) throws SQLException {

    UpdateQuery query = null;

    try {

      query = new UpdateQuery(connection, false, lowLevelQuery.getSql());

      this.setCustomQueryParameters(query, lowLevelQuery.getParameters());

      if (lowLevelQuery.getGeneratedKeyCollectors() != null) {

        query.executeUpdate(lowLevelQuery.getGeneratedKeyCollectors());

      } else {

        query.executeUpdate();
      }

    } finally {

      PreparedStatementQuery.autoCloseQuery(query);
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

    this.delete(bean, transactionHandler.getConnection());
  }

  public void delete(T bean, Connection connection) throws SQLException {

    UpdateQuery query = null;

    try {

      query = new UpdateQuery(connection, false, this.deleteSQL);

      IntegerCounter integerCounter = new IntegerCounter();

      // Keys from SimpleColumns for where statement
      this.setQueryValues(bean, query, integerCounter, this.simpleKeys);

      // Keys from many to one relations for where statement
      this.setQueryValues(bean, query, integerCounter, this.manyToOneRelationKeys.values());

      query.executeUpdate();

    } finally {
      PreparedStatementQuery.autoCloseQuery(query);
    }
  }
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

    return this.delete(highLevelQuery, transactionHandler.getConnection());
  }

  public Integer delete(HighLevelQuery<T> highLevelQuery, Connection connection) throws SQLException {

    UpdateQuery query = null;

    try {
      query = new UpdateQuery(connection, false, this.deleteByFieldSQL + this.getCriterias(highLevelQuery, false));

      setQueryParameters(query, highLevelQuery, 1);

      query.executeUpdate();

      return query.getAffectedRows();

    } finally {

      PreparedStatementQuery.autoCloseQuery(query);
    }
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

        stringBuilder.append(" AND " + queryParameter.getColumn().getColumnName() + " " + queryParameter.getOperator() + " ?");
      }
    }

    UpdateQuery query = null;

    try {

      query = new UpdateQuery(connection, false, stringBuilder.toString());

      IntegerCounter integerCounter = new IntegerCounter();

      // Keys values from SimpleColumns for where not in statement
      this.setQueryValues(filteredBeans, query, integerCounter, this.simpleKeys, excludedField);

      // Keys values from many to one relations for where not in statement
      this.setQueryValues(filteredBeans, query, integerCounter, this.manyToOneRelationKeys.values(), excludedField);

      if (queryParameters != null) {

        // Set query param values
        this.setQueryParameters(query, new HighLevelQuery<T>(queryParameters), integerCounter.increment());
      }

      query.executeUpdate();

    } finally {
      PreparedStatementQuery.autoCloseQuery(query);
    }
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

      }
     
      for(RemoteType remoteBean : remoteBeans){
     
        //Set new relations
        UpdateQuery insertQuery;
       
        insertQuery = new UpdateQuery(connection, false, linkTableInsertSQL);
       
        setQueryParameter(insertQuery, this.localColumn, bean, 1);
        setQueryParameter(insertQuery, this.remoteColumn, remoteBean, 2);
       
        insertQuery.executeUpdate();
      }
     
    } catch (IllegalArgumentException e) {

      throw new RuntimeException(e);
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

      if(!initialized){
        init()
      }
     
      //Clear old relations
      UpdateQuery deleteQuery;
     
      deleteQuery = new UpdateQuery(connection, false, linkTableDeleteSQL);
     
      setQueryParameter(deleteQuery, this.localColumn, bean, 1);
     
      deleteQuery.executeUpdate();
     
      //Check if there are any new relations to set
      List<RemoteType> remoteBeans = (List<RemoteType>) field.get(bean);
     
      if(remoteBeans == null){
       
        return;
      }
     
      for(RemoteType remoteBean : remoteBeans){
     
        //Set new relations
        UpdateQuery insertQuery;
       
        insertQuery = new UpdateQuery(connection, false, linkTableInsertSQL);
       
        setQueryParameter(insertQuery, this.localColumn, bean, 1);
        setQueryParameter(insertQuery, this.remoteColumn, remoteBean, 2);
       
        insertQuery.executeUpdate();
      }
     
    } catch (IllegalArgumentException e) {

      throw new RuntimeException(e);
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

        int listIndex = 0;
       
        for (RemoteType value : values) {

          UpdateQuery query = new UpdateQuery(connection, false, insertSQL);

          setKey(query, bean);

          setValue(value, query);

          if(preserveListOrder){
           
            query.setInt(3, listIndex);
            listIndex++;
          }
         
          query.executeUpdate();
        }
      }

    } catch (IllegalArgumentException e) {
View Full Code Here

Examples of se.unlogic.standardutils.dao.querys.UpdateQuery

    if (!initialized) {
      init();
    }

    UpdateQuery query = new UpdateQuery(connection, false, deleteSQL);

    setKey(query, bean);

    query.executeUpdate();

    this.add(bean, connection, relationQuery);
  }
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.