Package se.unlogic.standardutils.dao.querys

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


      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

  }
 
  public void executeScript(String script) throws SQLException {

    TransactionHandler transactionHandler = null;
    UpdateQuery updateQuery;

    ScriptUtility scriptUtility = new MySQLScriptUtility();
    List<String> statements = scriptUtility.getStatements(script);
   
    try {
     
      transactionHandler = new TransactionHandler(this.dataSource);

      for(String query : statements) {
        updateQuery = transactionHandler.getUpdateQuery(query.toString());
        updateQuery.executeUpdate();
      }
     
      transactionHandler.commit();

    } finally {
View Full Code Here

        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

    if (!initialized) {
      init();
    }

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

    setKey(query, bean);

    query.executeUpdate();

    this.add(bean, connection, relationQuery);
  }
View Full Code Here

  public UpdateQuery getUpdateQuery(String sqlExpression) throws SQLException {

    this.checkStatus();

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

    checkQueryList();
   
    this.queryList.add(query);
View Full Code Here

  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

    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

    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

    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

TOP

Related Classes of se.unlogic.standardutils.dao.querys.UpdateQuery

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.