* 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));
}