Package org.conserve.select

Examples of org.conserve.select.StatementPrototypeGenerator


    if (!tableManager.tableExists(tableName, cw))
    {
      return res;
    }

    StatementPrototypeGenerator whereGenerator = new StatementPrototypeGenerator(
        adapter);
    whereGenerator.setClauses(clause);
    StatementPrototype sp = whereGenerator.generate(clazz, true);
    // get the id of clazz
    String shortName = whereGenerator.getTypeStack()
        .getActualRepresentation().getAsName();

    StringBuilder statement = new StringBuilder("SELECT ");
    statement.append(shortName);
    statement.append(".");
View Full Code Here


    if (!tableManager.tableExists(clazz, cw))
    {
      return res;
    }

    StatementPrototypeGenerator whereGenerator = new StatementPrototypeGenerator(
        adapter);
    whereGenerator.setClauses(clauses);
    StatementPrototype sp = whereGenerator.generate(clazz, true);
    PreparedStatement ps = sp.toPreparedStatement(cw,
        sp.getSelectStartQuery());
    ResultSet rs = ps.executeQuery();
    List<HashMap<String, Object>> propertyVector = createPropertyVector(rs);
    ps.close();
View Full Code Here

    if (!tableManager.tableExists(clazz, cw))
    {
      return res;
    }

    StatementPrototypeGenerator whereGenerator = new StatementPrototypeGenerator(
        adapter);
    whereGenerator.setClauses(clause);
    StatementPrototype sp = whereGenerator.generate(clazz, true);
    String tableId = sp.getIdStatementGenerator().getJoinTableIds().get(0);
    StringBuilder statement = new StringBuilder("SELECT COUNT(DISTINCT("
        + tableId + "." + Defaults.ID_COL + ")) FROM ");
    PreparedStatement ps = sp.toPreparedStatement(cw, statement.toString());
    ResultSet rs = ps.executeQuery();
View Full Code Here

        NameGenerator.getTableName(clazz, adapter), cw))
    {
      return res;
    }

    StatementPrototypeGenerator whereGenerator = new StatementPrototypeGenerator(
        adapter);
    StatementPrototype sp = whereGenerator.generate(clazz, true);
    String shortName = whereGenerator.getTypeStack()
        .getRepresentation(clazz).getAsName();

    sp.addEqualsClause(shortName + "." + Defaults.ID_COL, id);

    PreparedStatement ps = sp.toPreparedStatement(cw,
View Full Code Here

  {
    String realClassName = (String) map.get(Defaults.REAL_CLASS_COL);
    // erase the 'real' class entry
    map.remove(Defaults.REAL_CLASS_COL);
    StringBuilder statement = new StringBuilder("SELECT * FROM ");
    StatementPrototypeGenerator whereGenerator = new StatementPrototypeGenerator(
        adapter);
    StatementPrototype sp = whereGenerator.generate(clazz, false);
    sp.addEqualsClause(Defaults.ID_COL, dbId);
    PreparedStatement ps = sp.toPreparedStatement(cw, statement.toString());
    ResultSet rs = ps.executeQuery();
    List<HashMap<String, Object>> propertyVector = createPropertyVector(rs);
    if (propertyVector.size() != 1)
View Full Code Here

      // no need to change it, as it's already cast to the correct class.
      return id;
    }
    else
    {
      StatementPrototypeGenerator gen = new StatementPrototypeGenerator(
          adapter);

      StatementPrototype sp = gen.generate(realClass, true);
      sp.addEqualsClause(
          gen.getTypeStack()
              .getRepresentation(
                  gen.getTypeStack().getLevel(realClass))
              .getAsName()
              + "." + Defaults.ID_COL, id);
      StringBuilder prepend = new StringBuilder("SELECT ");
      prepend.append(gen.getTypeStack()
          .getRepresentation(gen.getTypeStack().getLevel(c))
          .getAsName());
      prepend.append(".");
      prepend.append(Defaults.ID_COL);
      prepend.append(" FROM ");
      PreparedStatement ps = sp.toPreparedStatement(cw,
View Full Code Here

        // check if any columns have been removed
        removeObsoleteColumns(tmpRes, valueTypeMap, cw);
        // add all columns to the table
        addNewColumns(tmpRes, valueTypeMap, cw);

        StatementPrototypeGenerator statementGenerator = new StatementPrototypeGenerator(adapter);
        StatementPrototype sp = statementGenerator.generate(s, true);
        String fromName = statementGenerator.getTypeStack().getRepresentation(from.getRepresentedClass())
            .getTableName();
        String toName = statementGenerator.getTypeStack().getActualRepresentation().getTableName();
        String prestatement = "UPDATE " + toName + " SET " + toName + "." + colName + "=" + fromName + "."
            + colName + " ";
        PreparedStatement ps = sp.toPreparedStatement(cw, prestatement);
        Tools.logFine(ps);
        ps.executeUpdate();
View Full Code Here

TOP

Related Classes of org.conserve.select.StatementPrototypeGenerator

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.