Class UpdateItemStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.UpdateItemStateObject
- All Implemented Interfaces:
StateObject
The
new_value specified for an update operation must be compatible in type with the
field to which it is assigned.
BNF: update_item ::= [identification_variable.]{state_field | single_valued_association_field} = new_value
- Since:
- 2.4
- Version:
- 2.5
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringNotifies the new value property has changed. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newUpdateItemStateObject.UpdateItemStateObject(UpdateClauseStateObject parent, String path, String newValue) Creates a newUpdateItemStateObject.UpdateItemStateObject(UpdateClauseStateObject parent, String path, StateObject newValue) Creates a newUpdateItemStateObject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(StateObjectVisitor visitor) Visits thisStateObjectby the givenvisitor.protected voidaddChildren(List<StateObject> children) Adds the children of thisStateObjectto the given list.voidappendToPath(String text) Appends the given sequence of characters to the path expression.Creates and returns a newINewValueStateObjectBuilderthat can be used to programmatically create a new value expression and once the expression is complete,INewValueStateObjectBuilder.commit()will push theStateObjectrepresentation of that expression as this new value object.Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.Returns theStateObjectrepresenting the new value.Returns the parent of thisStateObject.getPath()Returns the string representation of the path expression.ReturnsbooleanDetermines whether theStateObjectrepresenting the new value is present.protected voidInitializes this state object.booleanisEquivalent(StateObject stateObject) Determines whether the givenStateObjectis equivalent to this one, i.e.items()Returns the segments in the state field path in order.intReturns the number of segments in the path expression.voidparseNewValue(String newValue) Parses the given JPQL fragment, which represents the new value.voidsetExpression(UpdateItem expression) Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.voidsetNewValue(StateObject newValue) Sets the new value to be the givenStateObject.voidChanges the path expression with the list of segments, the identification variable will also be updated with the first segment.voidChanges the path expression with the list of segments, the identification variable will also be updated with the first segment.voidsetPaths(ListIterator<String> paths) Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.voidsetVirtualIdentificationVariable(String identificationVariable) The state field path expression is not qualified by the identification variable.protected voidtoTextInternal(Appendable writer) Prints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
Field Details
-
NEW_VALUE_PROPERTY
Notifies the new value property has changed.- See Also:
-
-
Constructor Details
-
UpdateItemStateObject
Creates a newUpdateItemStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
NullPointerException- The given parent cannot benull
-
UpdateItemStateObject
Creates a newUpdateItemStateObject.- Parameters:
parent- The parent of this state object, which cannot benullpath- The state field path to receive the new valuenewValue- The actual expression representing the new value- Throws:
NullPointerException- The given parent cannot benull
-
UpdateItemStateObject
Creates a newUpdateItemStateObject.- Parameters:
parent- The parent of this state object, which cannot benullpath- The state field path to receive the new valuenewValue- The JPQL fragment representing the new value- Throws:
NullPointerException- The given parent cannot benull
-
-
Method Details
-
accept
Description copied from interface:StateObjectVisits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addChildren
Description copied from class:AbstractStateObjectAdds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractStateObject- Parameters:
children- The list used to store the children
-
appendToPath
Appends the given sequence of characters to the path expression. If the sequence does not begin with a dot, then the first segment will be appended to the last segment and then new segments will be created.- Parameters:
text- The sequence of characters to append to the path expression
-
getBuilder
Creates and returns a newINewValueStateObjectBuilderthat can be used to programmatically create a new value expression and once the expression is complete,INewValueStateObjectBuilder.commit()will push theStateObjectrepresentation of that expression as this new value object.- Returns:
- A new builder that can be used to quickly create a new value expression
-
getExpression
Description copied from interface:StateObjectReturns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- Overrides:
getExpressionin classAbstractStateObject- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObjectornullwhen the JPQL query is manually created (i.e. not from a string)
-
getNewValue
Returns theStateObjectrepresenting the new value.- Returns:
- The new value expression or
nullif it's not yet defined
-
getParent
Description copied from interface:StateObjectReturns the parent of thisStateObject.- Specified by:
getParentin interfaceStateObject- Overrides:
getParentin classAbstractStateObject- Returns:
- Returns the parent of this
StateObject, which isnullonly when this is the root of the hierarchy
-
getPath
Returns the string representation of the path expression. If the identification variable is virtual, then it is not part of the result.- Returns:
- The path expression, which is never
null
-
getStateFieldPath
Returns -
hasNewValue
public boolean hasNewValue()Determines whether theStateObjectrepresenting the new value is present.- Returns:
truethe new value exists; otherwisefalse
-
initialize
protected void initialize()Description copied from class:AbstractStateObjectInitializes this state object.- Overrides:
initializein classAbstractStateObject
-
isEquivalent
Description copied from interface:StateObjectDetermines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Overrides:
isEquivalentin classAbstractStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
items
Returns the segments in the state field path in order.- Returns:
- An
ListIterableover the paths of the state field path
-
itemsSize
public int itemsSize()Returns the number of segments in the path expression.- Returns:
- The number of segments
-
parseNewValue
Parses the given JPQL fragment, which represents the new value.- Parameters:
newValue- The string representation of the new value to parse and to convert into aStateObject
-
setExpression
Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.- Parameters:
expression- Theparsed objectrepresenting an update item
-
setNewValue
Sets the new value to be the givenStateObject.- Parameters:
newValue- TheStateObjectrepresenting the new value
-
setPath
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.- Parameters:
path- The new path expression
-
setPaths
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.- Parameters:
paths- The new path expression
-
setPaths
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.- Parameters:
paths- The new path expression
-
setVirtualIdentificationVariable
The state field path expression is not qualified by the identification variable.- Parameters:
identificationVariable- The virtual variable that was generated based on the entity name
-
toTextInternal
Description copied from class:AbstractStateObjectPrints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternalin classAbstractStateObject- Parameters:
writer- The writer used to print out the string representation- Throws:
IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-