Package org.conserve.tools

Examples of org.conserve.tools.StatementPrototype


    }

    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(".");
    statement.append(Defaults.ID_COL);
    statement.append(",");
    statement.append(shortName);
    statement.append(".");
    statement.append(Defaults.REAL_CLASS_COL);
    statement.append(",");
    statement.append(shortName);
    statement.append(".");
    statement.append(Defaults.REAL_ID_COL);
    statement.append(" FROM ");
    if (id != null)
    {
      sp.addEqualsClause(shortName + "." + Defaults.ID_COL, id);
    }
    PreparedStatement ps = sp.toPreparedStatement(cw, statement.toString());
    ResultSet rs = ps.executeQuery();
    List<HashMap<String, Object>> propertyVector = createPropertyVector(rs);
    ps.close();
    // If a row has a REALCLASS entry, load data for the subclass
    for (HashMap<String, Object> map : propertyVector)
View Full Code Here


    }

    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();
    for (HashMap<String, Object> map : propertyVector)
    {
View Full Code Here

    }

    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();
    if (rs.next())
    {
      res = rs.getLong(1);
    }
View Full Code Here

      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,
        sp.getSelectStartQuery());
    ResultSet rs = ps.executeQuery();
    List<HashMap<String, Object>> propertyVector = createPropertyVector(rs);
    ps.close();
    for (HashMap<String, Object> map : propertyVector)
    {
View Full Code Here

    // 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)
    {
      throw new SQLException("Wrong number of subclass entities found: "
View Full Code Here

    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,
          prepend.toString());
      try
      {
        Tools.logFine(ps);
        ResultSet rs = ps.executeQuery();
View Full Code Here

  {
    typeStack = stack;
    typeIds = new UniqueIdTree(uidGenerator);
    typeIds.nameStack(typeStack);

    StatementPrototype res = new StatementPrototype(adapter, typeStack, typeStack.getActualRepresentation()
        .getRepresentedClass(), addJoins);

    generateRecursively(res, null, clauses);

    return res;
View Full Code Here

TOP

Related Classes of org.conserve.tools.StatementPrototype

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.