Class AbstractModifyClauseStateObject
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractModifyClauseStateObject
-
- All Implemented Interfaces:
DeclarationStateObject
,StateObject
- Direct Known Subclasses:
DeleteClauseStateObject
,UpdateClauseStateObject
public abstract class AbstractModifyClauseStateObject extends AbstractStateObject implements DeclarationStateObject
- Version:
- 2.5
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractModifyClauseStateObject(AbstractModifyStatementStateObject parent)
Creates a newUpdateClauseStateObject
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObject
to the given list.ListIterable<VariableDeclarationStateObject>
declarations()
Returns the list of declarations declared in the declaration clause of the current query.IManagedType
findManagedType(StateObject stateObject)
Returns theIManagedType
for the given identification variable.java.lang.String
getAbstractSchemaName()
Returns the abstract schema name.AbstractSchemaNameStateObject
getAbstractSchemaNameStateObject()
Returns theAbstractSchemaNameStateObject
holding onto the abstract schema name.DeclarationStateObject
getDeclaration()
Returns the declaration clause which defines the domain of the query by declaring identification variables.IEntity
getEntity()
Returns the actualIEntity
that has the abstract schema name.java.lang.String
getIdentificationVariable()
Returns the identification variable name that is ranging over the abstract schema type.IdentificationVariableStateObject
getIdentificationVariableStateObject()
Returns theIdentificationVariableStateObject
holding onto the identification variable.abstract java.lang.String
getIdentifier()
Returns the JPQL identifier of this clause.IManagedType
getManagedType(StateObject stateObject)
Returns theIManagedType
for the given identification variable.AbstractModifyStatementStateObject
getParent()
Returns the parent of thisStateObject
.RangeVariableDeclarationStateObject
getRangeVariableDeclaration()
Returns theStateObject
that defines the range variable declaration.boolean
hasIdentificationVariable()
Determines whether an identification variable was defined.protected void
initialize()
Initializes this state object.boolean
isEquivalent(StateObject stateObject)
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.void
setDeclaration(java.lang.String abstractSchemaName)
Sets the abstract schema name to the given value and removes the identification variable.void
setDeclaration(java.lang.String abstractSchemaName, java.lang.String identificationVariable)
Sets the abstract schema name to the given value and the identification variable that will range over it.void
setDeclaration(IEntity entity)
Sets the abstract schema name to the given value.void
setDeclaration(IEntity entity, java.lang.String identificationVariable)
Sets the abstract schema name to the given value and the identification variable that will range over it.void
setEntity(IEntity entity)
Sets the actualIEntity
and updates the abstract schema name.void
setEntityName(java.lang.String entityName)
Sets the name of the abstract schema, which is the name of the entity.void
setIdentificationVariable(java.lang.String identificationVariable)
Sets the new identification variable that will range over the abstract schema name.protected void
toTextInternal(java.lang.Appendable writer)
Prints out a string representation of thisStateObject
, which should not be used to define atrue
string 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, getDecorator, getExpression, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
accept, addPropertyChangeListener, children, decorate, findIdentificationVariable, getDecorator, getExpression, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toText
-
-
-
-
Constructor Detail
-
AbstractModifyClauseStateObject
protected AbstractModifyClauseStateObject(AbstractModifyStatementStateObject parent)
Creates a newUpdateClauseStateObject
.- Parameters:
parent
- The parent of this state object
-
-
Method Detail
-
addChildren
protected void addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObject
to the given list.- Overrides:
addChildren
in classAbstractStateObject
- Parameters:
children
- The list used to store the children
-
declarations
public ListIterable<VariableDeclarationStateObject> declarations()
Returns the list of declarations declared in the declaration clause of the current query.- Specified by:
declarations
in interfaceDeclarationStateObject
- Returns:
- The list of
VariableDeclarationStateObject
that define the domain of the query
-
findManagedType
public IManagedType findManagedType(StateObject stateObject)
Returns theIManagedType
for the given identification variable. If the declaration is for a subquery and there is no managed type associated with the identification then the search will traverse up the query hierarchy.
In the above query, the managed type associated with the identification variable:SELECT e FROM Department d JOIN KEY(d.employees).addresses a
- d is "Department"
- a is "Address"
- Specified by:
findManagedType
in interfaceDeclarationStateObject
- Parameters:
stateObject
- TheStateObject
that should be an simple identification variable or an encapsulated identification variable with the identifierKEY
orVALUE
- Returns:
- The
IManagedType
representing the domain object declared by the given identification variable - See Also:
DeclarationStateObject.getManagedType(StateObject)
-
getAbstractSchemaName
public java.lang.String getAbstractSchemaName()
Returns the abstract schema name.- Returns:
- The name of the abstract schema type for which the identification variable is ranging over
-
getAbstractSchemaNameStateObject
public AbstractSchemaNameStateObject getAbstractSchemaNameStateObject()
Returns theAbstractSchemaNameStateObject
holding onto the abstract schema name.- Returns:
- The
AbstractSchemaNameStateObject
, which is nevernull
-
getDeclaration
public DeclarationStateObject getDeclaration()
Returns the declaration clause which defines the domain of the query by declaring identification variables.- Specified by:
getDeclaration
in interfaceStateObject
- Overrides:
getDeclaration
in classAbstractStateObject
- Returns:
- The declaration clause of which this
StateObject
is a child; i.e. either the top-level declaration if this is part of the top query or the sub-level declaration if this is part of a subquery
-
getEntity
public IEntity getEntity()
Returns the actualIEntity
that has the abstract schema name.- Returns:
- The actual
IEntity
ornull
if no entity exists
-
getIdentificationVariable
public java.lang.String getIdentificationVariable()
Returns the identification variable name that is ranging over the abstract schema type.- Returns:
- The identification variable name
-
getIdentificationVariableStateObject
public IdentificationVariableStateObject getIdentificationVariableStateObject()
Returns theIdentificationVariableStateObject
holding onto the identification variable.- Returns:
- The
IdentificationVariableStateObject
, which is nevernull
-
getIdentifier
public abstract java.lang.String getIdentifier()
Returns the JPQL identifier of this clause.- Returns:
- The JPQL identifier
-
getManagedType
public IManagedType getManagedType(StateObject stateObject)
Returns theIManagedType
for the given identification variable. The search does not traverse up the query hierarchy if this declaration is for a subquery.
In the above query, the managed type associated with the identification variable:SELECT e FROM Department d JOIN KEY(d.employees).addresses a
- d is "Department"
- a is "Address"
- Specified by:
getManagedType
in interfaceDeclarationStateObject
- Parameters:
stateObject
- TheStateObject
that should be an simple identification variable or an encapsulated identification variable with the identifierKEY
orVALUE
- Returns:
- The
IManagedType
representing the domain object declared by the given identification variable - See Also:
DeclarationStateObject.findManagedType(StateObject)
-
getParent
public AbstractModifyStatementStateObject getParent()
Returns the parent of thisStateObject
.- Specified by:
getParent
in interfaceStateObject
- Overrides:
getParent
in classAbstractStateObject
- Returns:
- Returns the parent of this
StateObject
, which isnull
only when this is the root of the hierarchy
-
getRangeVariableDeclaration
public RangeVariableDeclarationStateObject getRangeVariableDeclaration()
Returns theStateObject
that defines the range variable declaration.- Returns:
- The
StateObject
that defines the range variable declaration, which is nevernull
-
hasIdentificationVariable
public boolean hasIdentificationVariable()
Determines whether an identification variable was defined.- Returns:
true
if an identification variable is defined;false
otherwise
-
initialize
protected void initialize()
Initializes this state object.- Overrides:
initialize
in classAbstractStateObject
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.- Specified by:
isEquivalent
in interfaceStateObject
- Overrides:
isEquivalent
in classAbstractStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
setDeclaration
public void setDeclaration(IEntity entity)
Sets the abstract schema name to the given value.- Parameters:
entity
- TheIEntity
that this clause will range over
-
setDeclaration
public void setDeclaration(IEntity entity, java.lang.String identificationVariable)
Sets the abstract schema name to the given value and the identification variable that will range over it.- Parameters:
entity
- TheIEntity
that this clause will range overidentificationVariable
- The new identification variable
-
setDeclaration
public void setDeclaration(java.lang.String abstractSchemaName)
Sets the abstract schema name to the given value and removes the identification variable.- Parameters:
abstractSchemaName
- The name of the abstract schema, which is the name of the entity
-
setDeclaration
public void setDeclaration(java.lang.String abstractSchemaName, java.lang.String identificationVariable)
Sets the abstract schema name to the given value and the identification variable that will range over it.- Parameters:
abstractSchemaName
- The name of the abstract schema, which is the name of the entityidentificationVariable
- The new identification variable
-
setEntity
public void setEntity(IEntity entity)
Sets the actualIEntity
and updates the abstract schema name.- Parameters:
entity
- TheIEntity
that this clause will range over
-
setEntityName
public void setEntityName(java.lang.String entityName)
Sets the name of the abstract schema, which is the name of the entity.- Parameters:
entityName
- The name of the entity
-
setIdentificationVariable
public void setIdentificationVariable(java.lang.String identificationVariable)
Sets the new identification variable that will range over the abstract schema name.- Parameters:
identificationVariable
- The new identification variable
-
toTextInternal
protected void toTextInternal(java.lang.Appendable writer) throws java.io.IOException
Prints out a string representation of thisStateObject
, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternal
in classAbstractStateObject
- Parameters:
writer
- The writer used to print out the string representation- Throws:
java.io.IOException
- This should never happens, it is only required becauseAppendable
is used instead of any concrete class
-
-