Package com.caucho.amber.type

Examples of com.caucho.amber.type.BeanType


   * Creates a field-based schema.
   */
  public SchemaExpr createField(QueryParser parser, String name)
    throws QueryParseException
  {
    BeanType type = _id.getTargetType();

    AmberField field = type.getField(name);

    if (field == null)
      throw parser.error(L.l("{0}: '{1}' is an unknown field.",
                             type.getBeanClass().getName(),
                             name));

    AmberExpr fieldExpr = _id.createField(parser, name);

    if (fieldExpr instanceof ManyToOneExpr)
      return new ManyToOneSchemaExpr((ManyToOneExpr) fieldExpr, name);

    /*
      if (fieldExpr instanceof ManyToManyExpr)
      return new ManyToManySchemaExpr((ManyToManyExpr) fieldExpr);
    */

    if (fieldExpr instanceof OneToManyExpr)
      return new OneToManySchemaExpr((OneToManyExpr) fieldExpr);

    if (fieldExpr instanceof ElementCollectionExpr)
      return new ElementCollectionSchemaExpr((ElementCollectionExpr) fieldExpr);

    if (fieldExpr instanceof DependentEntityOneToOneExpr)
      return new OneToOneSchemaExpr((DependentEntityOneToOneExpr) fieldExpr, name);

    if (fieldExpr instanceof EmbeddedExpr)
      return new EmbeddedSchemaExpr((EmbeddedExpr) fieldExpr, name);

    throw parser.error(L.l("{0}: '{1}' must be a collection or one-to-one relationship.",
                           type.getBeanClass().getName(),
                           name));
  }
View Full Code Here


   */
  public AmberExpr createField(QueryParser parser, String fieldName)
  {
    AmberField field = null;

    BeanType type = getTargetType();

    do {
      field = type.getField(fieldName);

      if (type instanceof EntityType)
        type = ((EntityType) type).getParentType();
      else // XXX
        type = null;
View Full Code Here

   * Generates the where expression.
   */
  public void generateSelect(CharBuffer cb,
                             boolean fullSelect)
  {
    BeanType type = (BeanType) getType();

    if (type instanceof EmbeddableType) {
      _expr.generateSelect(cb);
      return;
    }

    if (type instanceof EntityType) {
      EntityType relatedType = (EntityType) type;
      cb.append(relatedType.getId().generateSelect(getTable()));
    }

    if (! fullSelect)
      return;

    FromItem item = _fromItem;

    // jpa/0l4b
    if (_rootItem != null) {
      EntityType parentType = (EntityType) type;

      while (parentType.getParentType() != null
             && parentType.getParentType() instanceof EntityType) {
        parentType = parentType.getParentType();
      }

      item = _rootItem;
    }

    String valueSelect = "";

    // jpa/0l12, jpa/0l47
    valueSelect = type.generateLoadSelect(item.getTable(),
                                          item.getName());

    if (valueSelect != null && ! "".equals(valueSelect)) {
      cb.append(", ");
      cb.append(valueSelect);
    }

    for (int i = 0; i < _subItems.size(); i++) {
      item = _subItems.get(i);

      valueSelect = type.generateLoadSelect(item.getTable(), item.getName());

      if (! valueSelect.equals("")) {
        cb.append(", ");
        cb.append(valueSelect);
      }
View Full Code Here

   */
  public AmberExpr createField(QueryParser parser, String fieldName)
  {
    AmberField field = null;

    BeanType type = getTargetType();

    do {
      field = type.getField(fieldName);

      if (type instanceof EntityType)
        type = ((EntityType) type).getParentType();
      else // XXX
        type = null;
View Full Code Here

   * Creates a field-based schema.
   */
  public SchemaExpr createField(QueryParser parser, String name)
    throws QueryParseException
  {
    BeanType type = _id.getTargetType();

    AmberField field = type.getField(name);

    if (field == null)
      throw parser.error(L.l("{0}: '{1}' is an unknown field.",
                             type.getBeanClass().getName(),
                             name));

    AmberExpr fieldExpr = _id.createField(parser, name);

    if (fieldExpr instanceof ManyToOneExpr)
      return new ManyToOneSchemaExpr((ManyToOneExpr) fieldExpr, name);

    /*
      if (fieldExpr instanceof ManyToManyExpr)
      return new ManyToManySchemaExpr((ManyToManyExpr) fieldExpr);
    */

    if (fieldExpr instanceof OneToManyExpr)
      return new OneToManySchemaExpr((OneToManyExpr) fieldExpr);

    if (fieldExpr instanceof ElementCollectionExpr)
      return new ElementCollectionSchemaExpr((ElementCollectionExpr) fieldExpr);

    if (fieldExpr instanceof DependentEntityOneToOneExpr)
      return new OneToOneSchemaExpr((DependentEntityOneToOneExpr) fieldExpr, name);

    if (fieldExpr instanceof EmbeddedExpr)
      return new EmbeddedSchemaExpr((EmbeddedExpr) fieldExpr, name);

    throw parser.error(L.l("{0}: '{1}' must be a collection or one-to-one relationship.",
                           type.getBeanClass().getName(),
                           name));
  }
View Full Code Here

   * Generates the where expression.
   */
  public void generateSelect(CharBuffer cb,
                             boolean fullSelect)
  {
    BeanType type = (BeanType) getType();

    if (type instanceof EmbeddableType) {
      _expr.generateSelect(cb);
      return;
    }

    if (type instanceof EntityType) {
      EntityType relatedType = (EntityType) type;
      cb.append(relatedType.getId().generateSelect(getTable()));
    }

    if (! fullSelect)
      return;

    FromItem item = _fromItem;

    // jpa/0l4b
    if (_rootItem != null) {
      EntityType parentType = (EntityType) type;

      while (parentType.getParentType() != null
       && parentType.getParentType() instanceof EntityType) {
  parentType = parentType.getParentType();
      }

      item = _rootItem;
    }

    String valueSelect = "";

    // jpa/0l12, jpa/0l47
    valueSelect = type.generateLoadSelect(item.getTable(),
                                          item.getName());

    if (valueSelect != null && ! "".equals(valueSelect)) {
      cb.append(", ");
      cb.append(valueSelect);
    }

    for (int i = 0; i < _subItems.size(); i++) {
      item = _subItems.get(i);

      valueSelect = type.generateLoadSelect(item.getTable(), item.getName());

      if (! valueSelect.equals("")) {
        cb.append(", ");
        cb.append(valueSelect);
      }
View Full Code Here

TOP

Related Classes of com.caucho.amber.type.BeanType

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.