Package org.xorm

Examples of org.xorm.RelationshipMapping


         (lastColumn, Operator.IN, collectionToIDs((Collection) owner.evaluate(this))));
    return true;
      }

      String field = ((Expression.Member) owner).getName();
      RelationshipMapping rm = mapping.getRelationship(field);
      ClassMapping targetMapping = modelMapping.getClassMapping
    (rm.getSource().getElementClass());
      Selector s = null;
      Selector old = selector;
      if (operand instanceof Expression.Variable) {
    // This field is really the variable, using targetMapping
    selector = new Selector(targetMapping.getTable(),
          null);
      } else if (operand instanceof Expression.Parameter) {
    if (param != null) {
        param = XORM.extractPrimaryKey(JDOHelper.getObjectId(param));
    }
    selector = new Selector
        (rm.getTarget().getColumn().getTable(),
         new SimpleCondition
       (rm.getTarget().getColumn(),
        Operator.EQUAL, param));
    selector.setJoinColumn(rm.getTarget().getColumn());

    // If we have a parameter on a MToN mapping,
    // we can skip the target table
    selector.setJoinColumn(rm.getSource().getColumn());
    old.setCondition
        (new SimpleCondition(mapping.getTable().getPrimaryKey(),
           Operator.CONTAINS, selector));
    return true;
      }
      if (rm.isMToN()) {
    s = new Selector
        (rm.getTarget().getColumn().getTable(),
         new SimpleCondition
       (rm.getTarget().getColumn(),
        Operator.EQUAL,
        selector));
      } else {
    s = selector;
      }
      s.setJoinColumn(rm.getSource().getColumn());
      old.setCondition
    (new SimpleCondition(mapping.getTable().getPrimaryKey(),
             Operator.CONTAINS, s));
      if (operand instanceof Expression.Variable) {
    varToSelector.put(((Expression.Variable) operand).getName(),
          top);
    top = null;
      }
  } else if ("startsWith".equals(name)) {
      selector.setCondition
    (new SimpleCondition(column, Operator.STARTS_WITH,
             param));
  } else if ("endsWith".equals(name)) {
      selector.setCondition
    (new SimpleCondition(column, Operator.ENDS_WITH,
             param));
  } else if ("strstr".equals(name)) {
      selector.setCondition
    (new SimpleCondition(column, Operator.STR_CONTAINS,
             param));
  } else if ("isEmpty".equals(name)) {
      // model.model_id where model_id = model_platform
      //  .model_id where model_id is null
      String field = ((Expression.Member) exp.getOwner()).getName();
      RelationshipMapping rm = mapping.getRelationship(field);
      Selector s = new Selector
    (rm.getSource().getColumn().getTable(),
     new SimpleCondition(rm.getSource().getColumn(),
             Operator.EQUAL, null));
      s.setJoinColumn(rm.getSource().getColumn());
      s.setOuterJoin(true);
      selector.setCondition(new SimpleCondition
          (selector.getTable().getPrimaryKey(),
           Operator.CONTAINS, s));
  }
View Full Code Here

TOP

Related Classes of org.xorm.RelationshipMapping

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.