Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.parser

public final Class UpdateClause

extends AbstractExpression
Class Inheritance
Imports
java.util.ArrayList, .Collection, .List, org.eclipse.persistence.jpa.jpql.ExpressionTools, .WordParser

This is the update clause of the update statement.

An UPDATE statement provides bulk operations over sets of entities of a single entity class (together with its subclasses, if any). Only one entity abstract schema type may be specified in the UPDATE clause.

BNF: update_clause ::= UPDATE abstract_schema_name [[AS] identification_variable] SET update_item {, update_item}*
Author
Pascal Filion
Since
2.3
Version
2.5
See Also
UpdateStatement, UpdateItem

Field Summary

Modifier and TypeField and Description
private boolean
hasSpaceAfterRangeVariableDeclaration

Determines whether a whitespace was parsed after the abstract schema name declaration.

private boolean
hasSpaceAfterSet

Determines whether a whitespace was parsed after SET.

private boolean
hasSpaceAfterUpdate

Determines whether a whitespace was parsed after UPDATE.

private AbstractExpression
rangeVariableDeclaration

The Expression representing the range variable declaration.

private String
setIdentifier

The actual SET identifier found in the string representation of the JPQL query.

private String
updateIdentifier

The actual UPDATE identifier found in the string representation of the JPQL query.

private AbstractExpression
updateItems

The expression containing the update items.

Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
COMMADOTDOUBLE_QUOTELEFT_CURLY_BRACKETLEFT_PARENTHESISNOT_DEFINEDRIGHT_CURLY_BRACKETRIGHT_PARENTHESISSINGLE_QUOTESPACEUNDERSCORE

Constructor Summary

AccessConstructor and Description
public
UpdateClause(AbstractExpression
The parent of this expression
parent
)

Creates a new UpdateClause.

Method Summary

Modifier and TypeMethod and Description
public void
accept(ExpressionVisitor
The ExpressionVisitor to visit this object
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.
public void
acceptChildren(ExpressionVisitor
The visitor to visit the children of this object.
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression.
protected void
addChildrenTo(Collection<Expression>
The collection used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.
protected void
addOrderedChildrenTo(List<Expression>
The list used to store the string representation of this AbstractExpression
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.
public CollectionExpression

Returns:

The single update item represented by a temporary collection
buildCollectionExpression
()

Creates a new CollectionExpression that will wrap the single update item.

public JPQLQueryBNF
findQueryBNF(Expression
The Expression that is a descendant of this one
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.
public String

Returns:

The SET identifier that was actually parsed, or an empty string if it was not parsed
getActualSetIdentifier
()

Returns the actual SET found in the string representation of the JPQL query, which has the actual case that was used.

public String

Returns:

The UPDATE identifier that was actually parsed
getActualUpdateIdentifier
()

Returns the actual UPDATE found in the string representation of the JPQL query, which has the actual case that was used.

public JPQLQueryBNF
public Expression

Returns:

The expression that was parsed representing the range variable declaration
getRangeVariableDeclaration
()

Returns the Expression representing the range variable declaration.

public Expression

Returns:

The expression that was parsed representing the single or multiple update items
getUpdateItems
()

Returns the Expression representing the single update item or the collection of update items.

public boolean

Returns:

true if the range variable declaration was parsed; false otherwise
hasRangeVariableDeclaration
()

Determines whether the range variable declaration was parsed.

public boolean

Returns:

true if SET was part of the query; false otherwise
hasSet
()

Determines whether SET was parsed or not.

public boolean

Returns:

true if there was a whitespace after the abstract schema name declaration; false otherwise
hasSpaceAfterRangeVariableDeclaration
()

Determines whether a whitespace was found after the abstract schema name declaration.

public boolean

Returns:

true if there was a whitespace after SET; false otherwise
hasSpaceAfterSet
()

Determines whether a whitespace was found after SET.

public boolean

Returns:

true if there was a whitespace after the identifier UPDATE; false otherwise
hasSpaceAfterUpdate
()

Determines whether a whitespace was found after the identifier UPDATE.

public boolean

Returns:

true if something was parsed after SET even if it was a malformed expression; false if nothing was parsed
hasUpdateItems
()

Determines whether the update items section of the query was parsed.

protected boolean
isParsingComplete(WordParser
The text to parse based on the current position of the cursor
wordParser
,
String
The word that was retrieved from the given text, which is the first word in the text
word
,
Expression
The Expression that has already been parsed
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text.
protected void
parse(WordParser
The text to parse based on the current position of the cursor
wordParser
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.
protected void
toParsedText(StringBuilder
The buffer used to append this Expression's string representation
writer
,
boolean
Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers
actual
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoActualTexttoParsedTexttoString

Field Detail

hasSpaceAfterRangeVariableDeclarationback to summary
private boolean hasSpaceAfterRangeVariableDeclaration

Determines whether a whitespace was parsed after the abstract schema name declaration.

hasSpaceAfterSetback to summary
private boolean hasSpaceAfterSet

Determines whether a whitespace was parsed after SET.

hasSpaceAfterUpdateback to summary
private boolean hasSpaceAfterUpdate

Determines whether a whitespace was parsed after UPDATE.

rangeVariableDeclarationback to summary
private AbstractExpression rangeVariableDeclaration

The Expression representing the range variable declaration.

setIdentifierback to summary
private String setIdentifier

The actual SET identifier found in the string representation of the JPQL query.

updateIdentifierback to summary
private String updateIdentifier

The actual UPDATE identifier found in the string representation of the JPQL query.

updateItemsback to summary
private AbstractExpression updateItems

The expression containing the update items.

Constructor Detail

UpdateClauseback to summary
public UpdateClause(AbstractExpression parent)

Creates a new UpdateClause.

Parameters
parent:AbstractExpression

The parent of this expression

Method Detail

acceptback to summary
public void accept(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.

Parameters
visitor:ExpressionVisitor

The ExpressionVisitor to visit this object

Annotations
@Override
acceptChildrenback to summary
public void acceptChildren(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression. This method can be used to optimize traversing the children since a new list is not created every time children() is called.

This does not traverse the Expression sub-hierarchy, use a subclass of AbstractTraverseChildrenVisitor in order to traverse the entire sub-hierarchy.

Parameters
visitor:ExpressionVisitor

The visitor to visit the children of this object.

Annotations
@Override
addChildrenToback to summary
protected void addChildrenTo(Collection<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.

Parameters
children:Collection<Expression>

The collection used to store the children

Annotations
@Override
addOrderedChildrenToback to summary
protected void addOrderedChildrenTo(List<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.

Parameters
children:List<Expression>

The list used to store the string representation of this AbstractExpression

Annotations
@Override
buildCollectionExpressionback to summary
public CollectionExpression buildCollectionExpression()

Creates a new CollectionExpression that will wrap the single update item.

Returns:CollectionExpression

The single update item represented by a temporary collection

findQueryBNFback to summary
public JPQLQueryBNF findQueryBNF(Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.

Parameters
expression:Expression

The Expression that is a descendant of this one

Returns:JPQLQueryBNF

The JPQLQueryBNF that was used to parse the given expression

Annotations
@Override
getActualSetIdentifierback to summary
public String getActualSetIdentifier()

Returns the actual SET found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The SET identifier that was actually parsed, or an empty string if it was not parsed

getActualUpdateIdentifierback to summary
public String getActualUpdateIdentifier()

Returns the actual UPDATE found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The UPDATE identifier that was actually parsed

getQueryBNFback to summary
public JPQLQueryBNF getQueryBNF()

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Returns the BNF of this Expression.

Returns:JPQLQueryBNF

The JPQLQueryBNF, which represents the grammar of this Expression

Annotations
@Override
getRangeVariableDeclarationback to summary
public Expression getRangeVariableDeclaration()

Returns the Expression representing the range variable declaration.

Returns:Expression

The expression that was parsed representing the range variable declaration

getUpdateItemsback to summary
public Expression getUpdateItems()

Returns the Expression representing the single update item or the collection of update items.

Returns:Expression

The expression that was parsed representing the single or multiple update items

hasRangeVariableDeclarationback to summary
public boolean hasRangeVariableDeclaration()

Determines whether the range variable declaration was parsed.

Returns:boolean

true if the range variable declaration was parsed; false otherwise

hasSetback to summary
public boolean hasSet()

Determines whether SET was parsed or not.

Returns:boolean

true if SET was part of the query; false otherwise

hasSpaceAfterRangeVariableDeclarationback to summary
public boolean hasSpaceAfterRangeVariableDeclaration()

Determines whether a whitespace was found after the abstract schema name declaration.

Returns:boolean

true if there was a whitespace after the abstract schema name declaration; false otherwise

hasSpaceAfterSetback to summary
public boolean hasSpaceAfterSet()

Determines whether a whitespace was found after SET.

Returns:boolean

true if there was a whitespace after SET; false otherwise

hasSpaceAfterUpdateback to summary
public boolean hasSpaceAfterUpdate()

Determines whether a whitespace was found after the identifier UPDATE.

Returns:boolean

true if there was a whitespace after the identifier UPDATE; false otherwise

hasUpdateItemsback to summary
public boolean hasUpdateItems()

Determines whether the update items section of the query was parsed.

Returns:boolean

true if something was parsed after SET even if it was a malformed expression; false if nothing was parsed

isParsingCompleteback to summary
protected boolean isParsingComplete(WordParser wordParser, String word, Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text. The text is never empty.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

word:String

The word that was retrieved from the given text, which is the first word in the text

expression:Expression

The Expression that has already been parsed

Returns:boolean

true if the text no longer can't be parsed by the current expression; false if more can be parsed

Annotations
@Override
parseback to summary
protected void parse(WordParser wordParser, boolean tolerant)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

tolerant:boolean

Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries

Annotations
@Override
toParsedTextback to summary
protected void toParsedText(StringBuilder writer, boolean actual)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.

Parameters
writer:StringBuilder

The buffer used to append this Expression's string representation

actual:boolean

Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers

Annotations
@Override