Package org.teiid.query.sql.lang
Class Insert
- java.lang.Object
-
- org.teiid.query.sql.lang.Command
-
- org.teiid.query.sql.lang.ProcedureContainer
-
- org.teiid.query.sql.lang.Insert
-
- All Implemented Interfaces:
Cloneable
,TargetedCommand
,LanguageObject
public class Insert extends ProcedureContainer
Represents a SQL Insert statement of the form: "INSERT INTO <group> (<variables>) VALUES <values>".
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Field Summary
-
Fields inherited from class org.teiid.query.sql.lang.Command
tempGroupIDs, TYPE_ALTER_PROC, TYPE_ALTER_TRIGGER, TYPE_ALTER_VIEW, TYPE_BATCHED_UPDATE, TYPE_CREATE, TYPE_DELETE, TYPE_DROP, TYPE_DYNAMIC, TYPE_EXPLAIN, TYPE_INSERT, TYPE_QUERY, TYPE_SOURCE_EVENT, TYPE_STORED_PROCEDURE, TYPE_TRIGGER_ACTION, TYPE_UNKNOWN, TYPE_UPDATE, TYPE_UPDATE_PROCEDURE
-
-
Constructor Summary
Constructors Constructor Description Insert()
Constructs a default instance of this class.Insert(GroupSymbol group, List<ElementSymbol> variables, List values)
Construct an instance with group, variable list (may be null), and values
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.void
addValue(Expression value)
Adds a value to the list of valuesvoid
addVariable(ElementSymbol var)
Add a variable to end of listvoid
addVariables(Collection<ElementSymbol> vars)
Add a collection of variables to end of listboolean
areResultsCachable()
Whether the results are cachable.Object
clone()
Return a deep copy of this Insert.boolean
equals(Object obj)
Compare two Insert commands for equality.Criteria
getConstraint()
GroupSymbol
getGroup()
Returns the group being inserted intoList<Expression>
getProjectedSymbols()
Get the ordered list of all elements returned by this query.QueryCommand
getQueryExpression()
TupleSource
getTupleSource()
int
getType()
Return type of command.List
getValues()
Returns a list of values to insert to be inserted.List<ElementSymbol>
getVariables()
Return an ordered List of variables, may be null if no columns were specifiedint
hashCode()
Get hashcode for command.boolean
isUpsert()
void
setConstraint(Criteria constraint)
void
setGroup(GroupSymbol group)
Set the group for this insert statementvoid
setQueryExpression(QueryCommand query)
void
setTupleSource(TupleSource tupleSource)
void
setUpsert(boolean merge)
void
setValues(List values)
Sets the values to be inserted.void
setVariables(Collection<ElementSymbol> vars)
Set a collection of variables that replace the existing variables-
Methods inherited from class org.teiid.query.sql.lang.ProcedureContainer
addTag, copyMetadataState, getUpdateCount, getUpdateInfo, hasTag, setUpdateCount, setUpdateInfo
-
Methods inherited from class org.teiid.query.sql.lang.Command
addExternalGroupToContext, copyMetadataState, getActualCommand, getAllExternalGroups, getCacheHint, getCommandToken, getCorrelatedReferences, getExternalGroupContexts, getOption, getProcessorPlan, getResultSetColumns, getSourceHint, getTemporaryMetadata, getUpdateCommandSymbol, printCommandTree, printCommandTree, pushNewResolvingContext, returnsResultSet, sameOptionAndHint, setCacheHint, setCorrelatedReferences, setExternalGroupContexts, setOption, setProcessorPlan, setSourceHint, setTemporaryMetadata, toString
-
-
-
-
Constructor Detail
-
Insert
public Insert()
Constructs a default instance of this class.
-
Insert
public Insert(GroupSymbol group, List<ElementSymbol> variables, List values)
Construct an instance with group, variable list (may be null), and values- Parameters:
group
- Group associated with this insertvariables
- List of ElementSymbols that represent columns for the values, null implies all columnsvalues
- List of Expression values to be inserted
-
-
Method Detail
-
getType
public int getType()
Return type of command.
-
getGroup
public GroupSymbol getGroup()
Returns the group being inserted into- Returns:
- Group being inserted into
-
setGroup
public void setGroup(GroupSymbol group)
Set the group for this insert statement- Parameters:
group
- Group to be inserted into
-
getVariables
public List<ElementSymbol> getVariables()
Return an ordered List of variables, may be null if no columns were specified- Returns:
- List of
ElementSymbol
-
addVariable
public void addVariable(ElementSymbol var)
Add a variable to end of list- Parameters:
var
- Variable to add to the list
-
addVariables
public void addVariables(Collection<ElementSymbol> vars)
Add a collection of variables to end of list- Parameters:
vars
- Variables to add to the list - collection of ElementSymbol
-
getValues
public List getValues()
Returns a list of values to insert to be inserted.- Returns:
- List of
Expression
s
-
setValues
public void setValues(List values)
Sets the values to be inserted.- Parameters:
values
- List ofExpression
s
-
setVariables
public void setVariables(Collection<ElementSymbol> vars)
Set a collection of variables that replace the existing variables- Parameters:
vars
- Variables to be set on this object (ElementSymbols)
-
addValue
public void addValue(Expression value)
Adds a value to the list of values- Parameters:
value
- Expression to be added to the list of values
-
setQueryExpression
public void setQueryExpression(QueryCommand query)
-
getQueryExpression
public QueryCommand getQueryExpression()
-
acceptVisitor
public void acceptVisitor(LanguageVisitor visitor)
Description copied from interface:LanguageObject
Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.- Parameters:
visitor
- Visitor being used
-
hashCode
public int hashCode()
Get hashcode for command. WARNING: This hash code relies on the hash codes of the Group, variables. If the command changes, it's hash code will change and it can be lost from collections. Hash code is only valid after command has been completely constructed.
-
equals
public boolean equals(Object obj)
Compare two Insert commands for equality. Will only evaluate to equal if they are IDENTICAL: group is equal, value is equal and variables are equal.
-
clone
public Object clone()
Return a deep copy of this Insert.- Specified by:
clone
in interfaceLanguageObject
- Specified by:
clone
in classCommand
- Returns:
- Deep copy of Insert
-
getProjectedSymbols
public List<Expression> getProjectedSymbols()
Get the ordered list of all elements returned by this query. These elements may be ElementSymbols or ExpressionSymbols but in all cases each represents a single column.- Specified by:
getProjectedSymbols
in classCommand
- Returns:
- Ordered list of SingleElementSymbol
-
areResultsCachable
public boolean areResultsCachable()
Description copied from class:Command
Whether the results are cachable.- Specified by:
areResultsCachable
in classCommand
- Returns:
- True if the results are cachable; false otherwise.
- See Also:
Command.areResultsCachable()
-
setTupleSource
public void setTupleSource(TupleSource tupleSource)
-
getTupleSource
public TupleSource getTupleSource()
-
getConstraint
public Criteria getConstraint()
-
setConstraint
public void setConstraint(Criteria constraint)
-
isUpsert
public boolean isUpsert()
-
setUpsert
public void setUpsert(boolean merge)
-
-