Package org.conserve.tools

Examples of org.conserve.tools.ObjectStack


    for(int lvl = 0;lvl<stack.getSize();lvl++)
    {
      generator.addForbiddenString(stack.getRepresentation(lvl).getTableName());
    }
    // find the existing stack that most closely match the new stack
    ObjectStack closestStack = null;
    int maxHeight = -1;
    for (ObjectStack existing : namedStacks)
    {
      int maxLevel = Math.min(stack.getSize(), existing.getSize());
      for (int x = 0; x < maxLevel; x++)
      {
        ObjectRepresentation o1 = stack.getRepresentation(x);
        ObjectRepresentation o2 = existing.getRepresentation(x);
        if (!o1.getRepresentedClass().equals(o2.getRepresentedClass()))
        {
          break;
        }
        else
        {
          if (x > maxHeight)
          {
            maxHeight = x;
            closestStack = existing;
          }
        }
      }
    }
    // copy names from existing to new stack
    for (int x = 0; x <= maxHeight; x++)
    {
      stack.getRepresentation(x).setAsName(
          closestStack.getRepresentation(x).getAsName());
    }
    // fill in remaining names from generator
    for (int x = maxHeight + 1; x < stack.getSize(); x++)
    {
      stack.getRepresentation(x).setAsName(generator.next());
View Full Code Here


    ResultSet rs = ps.executeQuery();
    while (rs.next())
    {
      int currentLevel = fromStack.getSize() - 1;
      // create a new entry in the to-tables
      ObjectStack nuStack = new ObjectStack(adapter, subClass.getRepresentedClass());
      nuStack.saveNoCache(cw, lowestCommonSubClassLevel + 1);
      // get the to-id of the highest non-common subclass
      long nuId = nuStack.getRepresentation(lowestCommonSubClassLevel + 1).getId();
      // cast the id to the correct level
      Long fromId = rs.getLong(Defaults.ID_COL);
      long oldId = getCastIdDatabase(fromStack, lowestCommonSubClassLevel + 1, subClass, fromId, cw);
      // rewrite the pointers C__ID and C__REALCLASS in the lowest common
      // subclass
View Full Code Here

    // check if the object exists
    Long databaseId = cache.getDatabaseId(object);
    if (databaseId == null)
    {
      // the object is unknown
      ObjectStack stack = new ObjectStack(this.adapter,
          object.getClass(), object, delayBuffer);
      stack.save(cw);
      res = stack.getActualRepresentation().getId();
      // label the object as having been inserted by the outside
      if (protect)
      {
        protectionManager.protectObjectExternal(tableName, res,
            ObjectTools.getSystemicName(object.getClass()), cw);
View Full Code Here

   * @return a prototype that can be used to generate PreparedStatements.
   * @throws SQLException
   */
  public StatementPrototype generate(Class<?> klass, boolean addJoins) throws SQLException
  {
    return this.generate(new ObjectStack(adapter, klass), addJoins);
  }
View Full Code Here

            {
              if (subClauses[x] instanceof Selector)
              {
                Selector sel = (Selector) subClauses[x];

                ObjectStack oStack = new ObjectStack(adapter, sel.getSelectionObject().getClass(),
                    sel.getSelectionObject(), new DelayedInsertionBuffer(adapter.getPersist()));
                typeIds.nameStack(oStack);
                generateClause(oStack, sel, sp, sorted);
              }
              else
View Full Code Here

   * @param mainStatement
   */
  private void generateOrder(Sorter sorter, StatementPrototype mainStatement)
  {
    // add order statements for all non-null values
    ObjectStack oStack = new ObjectStack(adapter, sorter.getSortObject().getClass(), sorter.getSortObject());
    this.typeIds.nameStack(oStack);
    mainStatement.getIdStatementGenerator().addPropertyTablesToJoin(oStack, null);
    for (int t = 0; t < oStack.getSize(); t++)
    {
      ObjectRepresentation rep = oStack.getRepresentation(t);
      for (Integer index : rep)
      {
        StringBuilder statement = new StringBuilder();
        statement.append(rep.getAsName());
        statement.append(".");
View Full Code Here

            if (rep.getDelayedInsertionBuffer().isKnown(id))
            {
              break;
            }
            rep.getDelayedInsertionBuffer().addId(id);
            ObjectStack propertyStack = new ObjectStack(adapter, property.getClass(), property,
                rep.getDelayedInsertionBuffer());
            nameStack(rep.getAsName() + "." + propertyName, propertyStack);
            Class<?> propertyClass = rep.getReturnType(x);

            if (propertyClass.isInterface())
            {
              propertyClass = Object.class;
            }
            ObjectRepresentation propertyRep = propertyStack.getRepresentation(propertyClass);

            conditional.append(" = ");
            conditional.append(propertyRep.getAsName());
            conditional.append(".");
            conditional.append(Defaults.ID_COL);
View Full Code Here

            {
              break;
            }
            rep.getDelayedInsertionBuffer().addId(id);
            // name the property
            ObjectStack propertyStack = new ObjectStack(adapter, o.getClass(), o,
                rep.getDelayedInsertionBuffer());
            nameStack(relationAsName + "." + Defaults.VALUE_COL, propertyStack);
            ObjectRepresentation propertyRep = propertyStack.getRepresentation(propertyClass);
            sb.append(" = ");
            sb.append(propertyRep.getAsName());
            sb.append(".");
            sb.append(Defaults.ID_COL);
            // save to query
View Full Code Here

TOP

Related Classes of org.conserve.tools.ObjectStack

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.