org.eobjects.metamodel.query
Class FromItem

java.lang.Object
  extended by org.eobjects.metamodel.util.BaseObject
      extended by org.eobjects.metamodel.query.FromItem
All Implemented Interfaces:
Serializable, Cloneable, QueryItem

public class FromItem
extends BaseObject
implements QueryItem, Cloneable

Represents a FROM item. FROM items can take different forms:

See Also:
FromClause, Serialized Form

Constructor Summary
FromItem(JoinType join, FromItem leftSide, FromItem rightSide, SelectItem[] leftOn, SelectItem[] rightOn)
          Constructor for advanced join types with custom relationships
FromItem(JoinType join, Relationship relationship)
          Constructor for join FROM clauses that join two tables using their relationship.
FromItem(Query subQuery)
          Constructor for sub-query FROM clauses
FromItem(String expression)
          Creates a single unvalidated from item based on a expression.
FromItem(Table table)
          Constructor for table FROM clauses
 
Method Summary
protected  FromItem clone()
           
protected  void decorateIdentity(List<Object> identifiers)
          Subclasses should implement this method and add all fields to the list that are to be included in equals(...) and hashCode() evaluation
 String getAlias()
           
 String getAlias(Table table)
          Gets the alias of a table, if it is registered (and visible, ie. not part of a sub-query) in the FromItem
 String getExpression()
           
 JoinType getJoin()
           
 SelectItem[] getLeftOn()
           
 FromItem getLeftSide()
           
 Query getQuery()
           
 SelectItem[] getRightOn()
           
 FromItem getRightSide()
           
 String getSameQueryAlias()
           
 Query getSubQuery()
           
 Table getTable()
           
 FromItem setAlias(String alias)
           
 QueryItem setQuery(Query query)
           
 String toSql()
           
 String toSql(boolean includeSchemaInColumnPaths)
           
 String toString()
           
 String toStringNoAlias()
           
 String toStringNoAlias(boolean includeSchemaInColumnPaths)
           
 
Methods inherited from class org.eobjects.metamodel.util.BaseObject
classEquals, equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FromItem

public FromItem(Table table)
Constructor for table FROM clauses


FromItem

public FromItem(Query subQuery)
Constructor for sub-query FROM clauses

Parameters:
subQuery - the subquery to use

FromItem

public FromItem(JoinType join,
                Relationship relationship)
Constructor for join FROM clauses that join two tables using their relationship. The primary table of the relationship will be the left side of the join and the foreign table of the relationship will be the right side of the join.

Parameters:
join - the join type to use
relationship - the relationship to use for joining the tables

FromItem

public FromItem(JoinType join,
                FromItem leftSide,
                FromItem rightSide,
                SelectItem[] leftOn,
                SelectItem[] rightOn)
Constructor for advanced join types with custom relationships

Parameters:
join - the join type to use
leftSide - the left side of the join
rightSide - the right side of the join
leftOn - what left-side select items to use for the ON clause
rightOn - what right-side select items to use for the ON clause

FromItem

public FromItem(String expression)
Creates a single unvalidated from item based on a expression. Expression based from items are typically NOT datastore-neutral but are available for special "hacking" needs. Expression based from items can only be used for JDBC based datastores since they are translated directly into SQL.

Parameters:
expression - An expression to use for the from item, for example "MYTABLE".
Method Detail

getAlias

public String getAlias()

getSameQueryAlias

public String getSameQueryAlias()

setAlias

public FromItem setAlias(String alias)

getTable

public Table getTable()

getSubQuery

public Query getSubQuery()

getJoin

public JoinType getJoin()

getLeftSide

public FromItem getLeftSide()

getRightSide

public FromItem getRightSide()

getLeftOn

public SelectItem[] getLeftOn()

getRightOn

public SelectItem[] getRightOn()

getExpression

public String getExpression()

toSql

public String toSql()
Specified by:
toSql in interface QueryItem

toSql

public String toSql(boolean includeSchemaInColumnPaths)
Specified by:
toSql in interface QueryItem

toStringNoAlias

public String toStringNoAlias()

toStringNoAlias

public String toStringNoAlias(boolean includeSchemaInColumnPaths)

getAlias

public String getAlias(Table table)
Gets the alias of a table, if it is registered (and visible, ie. not part of a sub-query) in the FromItem

Parameters:
table - the table to get the alias for
Returns:
the alias or null if none is found

getQuery

public Query getQuery()
Specified by:
getQuery in interface QueryItem

setQuery

public QueryItem setQuery(Query query)
Specified by:
setQuery in interface QueryItem

clone

protected FromItem clone()
Overrides:
clone in class Object

decorateIdentity

protected void decorateIdentity(List<Object> identifiers)
Description copied from class: BaseObject
Subclasses should implement this method and add all fields to the list that are to be included in equals(...) and hashCode() evaluation

Specified by:
decorateIdentity in class BaseObject

toString

public String toString()
Specified by:
toString in interface QueryItem
Overrides:
toString in class BaseObject


Copyright © 2007-2013. All Rights Reserved.