Package org.teiid.query.sql.lang
Class Update
- java.lang.Object
-
- org.teiid.query.sql.lang.Command
-
- org.teiid.query.sql.lang.ProcedureContainer
-
- org.teiid.query.sql.lang.Update
-
- All Implemented Interfaces:
Cloneable
,FilteredCommand
,TargetedCommand
,LanguageObject
public class Update extends ProcedureContainer implements FilteredCommand
Represents a SQL Update statement of the form: "UPDATE <group> SET <element> = <expression>, ... [WHERE <criteria>]".
-
-
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 Update()
Constructs a default instance of this class.Update(GroupSymbol group, SetClauseList changeList)
Construct with group and change listUpdate(GroupSymbol group, SetClauseList changeList, Criteria criteria)
Construct with group, change list, and criteria
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.void
addChange(ElementSymbol id, Expression value)
Add change to change list - a change is represented by a CompareCriteria internally but can be added here as an element and an expressionboolean
areResultsCachable()
Whether the results are cachable.Object
clone()
Return a copy of this Update.boolean
equals(Object obj)
Compare two update commands for equality.SetClauseList
getChangeList()
Return the list of CompareCriteria representing updates being madeCriteria
getConstraint()
Criteria
getCriteria()
Returns the criteria object for this command, may be nullGroupSymbol
getGroup()
Returns the group being updatedList
getProjectedSymbols()
Get the ordered list of all elements returned by this query.int
getType()
Return type of command.int
hashCode()
Get hashcode for command.void
setChangeList(SetClauseList changeList)
Set the list of CompareCriteria representing updates being madevoid
setConstraint(Criteria constraint)
void
setCriteria(Criteria criteria)
Set the criteria for this Update commandvoid
setGroup(GroupSymbol group)
Set the group being updatedString
toString()
Returns a string representation of an instance of this class.-
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
-
-
-
-
Constructor Detail
-
Update
public Update()
Constructs a default instance of this class.
-
Update
public Update(GroupSymbol group, SetClauseList changeList)
Construct with group and change list- Parameters:
group
- Group to by updatedchangeList
- List of CompareCriteria that represent Element and expression updates
-
Update
public Update(GroupSymbol group, SetClauseList changeList, Criteria criteria)
Construct with group, change list, and criteria- Parameters:
group
- DataGroupID that represents the group being updatedchangeList
- of changeCriteria that represent Element and value pairingscriteria
- Criteria that defines what rows get updated
-
-
Method Detail
-
getType
public int getType()
Return type of command.
-
getGroup
public GroupSymbol getGroup()
Returns the group being updated- Specified by:
getGroup
in interfaceTargetedCommand
- Returns:
- Group being updated
-
setGroup
public void setGroup(GroupSymbol group)
Set the group being updated- Parameters:
group
- Group being updated
-
setChangeList
public void setChangeList(SetClauseList changeList)
Set the list of CompareCriteria representing updates being made- Parameters:
changeList
- List of CompareCriteria
-
getChangeList
public SetClauseList getChangeList()
Return the list of CompareCriteria representing updates being made- Returns:
- List of CompareCriteria
-
addChange
public void addChange(ElementSymbol id, Expression value)
Add change to change list - a change is represented by a CompareCriteria internally but can be added here as an element and an expression- Parameters:
id
- Element to be changedvalue
- Expression, often a value, being set
-
getCriteria
public Criteria getCriteria()
Returns the criteria object for this command, may be null- Specified by:
getCriteria
in interfaceFilteredCommand
- Returns:
- Criteria, may be null
-
setCriteria
public void setCriteria(Criteria criteria)
Set the criteria for this Update command- Specified by:
setCriteria
in interfaceFilteredCommand
- Parameters:
criteria
- Criteria to be associated with this command
-
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.- Specified by:
acceptVisitor
in interfaceLanguageObject
- 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, changeList and Criteria clause. 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.
-
toString
public String toString()
Returns a string representation of an instance of this class.
-
equals
public boolean equals(Object obj)
Compare two update commands for equality. Will only evaluate to equal if they are IDENTICAL: group is equal, changeList contains same compareCriteria, criteria are in the same exact structure.
-
clone
public Object clone()
Return a copy of this Update.- Specified by:
clone
in interfaceLanguageObject
- Specified by:
clone
in classCommand
- Returns:
- Deep clone
-
getProjectedSymbols
public List 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()
-
getConstraint
public Criteria getConstraint()
-
setConstraint
public void setConstraint(Criteria constraint)
-
-