Class PersistentPropertyPathExtension
java.lang.Object
org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension
A wrapper around a
PersistentPropertyPath
for making common operations
available used in SQL generation and conversion- Since:
- 1.1
- Author:
- Jens Schauder, Daniil Razorenov
-
Constructor Summary
ConstructorDescriptionPersistentPropertyPathExtension
(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, PersistentPropertyPath<? extends RelationalPersistentProperty> path) Creates a non-empty path.PersistentPropertyPathExtension
(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, RelationalPersistentEntity<?> entity) Creates the empty path referencing the root itself. -
Method Summary
Modifier and TypeMethodDescriptionboolean
extendBy
(RelationalPersistentProperty property) Creates a new path by extending the current path by the property passed as an argument.Class<?>
For empty paths this is the type of the entity.The alias for the column used to represent this property in the database.The name of the column used to represent this property in the database.If the table owning ancestor has an id the column name of that id property is returned.The column name of the id column of the ancestor path that represents an actual table.Returns the longest ancestor path that has anId
property.TheRelationalPersistentEntity
associated with the leaf of this path.int
The length of the path.Returns the path that has the same beginning but is one segment shorter than this path.The fully qualified name of the table this path is tied to or of the longest ancestor path that is actually tied to a table.The column name used for the list index or map key of the leaf property of this path.Class<?>
The type of the qualifier column of the leaf property of this path or null if this is not applicable.The id property of the final element of the path.TheRelationalPersistentEntity
associated with the leaf of this path or throwIllegalStateException
if the leaf cannot be resolved.Converts this path to a non-nullPersistentPropertyPath
.The name of the column used to reference the id in the parent table.The alias used in select for the column used to reference the id in the parent table.The alias used for the table on which this path is based.The name of the table this path is tied to or of the longest ancestor path that is actually tied to a table.int
hashCode()
boolean
boolean
boolean
Returns true exactly when the path is non empty and the leaf property an embedded one.boolean
isEntity()
boolean
isMap()
boolean
Returns true if there are multiple values for this path, i.e. if the path contains at least one element that is a collection and array or a map.boolean
boolean
static boolean
isWritable
(PersistentPropertyPath<? extends RelationalPersistentProperty> path) boolean
Tests ifthis
and the argument represent the same path.toString()
-
Constructor Details
-
PersistentPropertyPathExtension
public PersistentPropertyPathExtension(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, RelationalPersistentEntity<?> entity) Creates the empty path referencing the root itself.- Parameters:
context
- Must not be null.entity
- Root entity of the path. Must not be null.
-
PersistentPropertyPathExtension
public PersistentPropertyPathExtension(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, PersistentPropertyPath<? extends RelationalPersistentProperty> path) Creates a non-empty path.- Parameters:
context
- must not be null.path
- must not be null.
-
-
Method Details
-
isWritable
public static boolean isWritable(PersistentPropertyPath<? extends RelationalPersistentProperty> path) -
isEmbedded
public boolean isEmbedded()Returns true exactly when the path is non empty and the leaf property an embedded one.- Returns:
- if the leaf property is embedded.
-
getParentPath
Returns the path that has the same beginning but is one segment shorter than this path.- Returns:
- the parent path. Guaranteed to be not null.
- Throws:
IllegalStateException
- when called on an empty path.
-
isMultiValued
public boolean isMultiValued()Returns true if there are multiple values for this path, i.e. if the path contains at least one element that is a collection and array or a map.- Returns:
- true if the path contains a multivalued element.
-
getLeafEntity
TheRelationalPersistentEntity
associated with the leaf of this path.- Returns:
- Might return null when called on a path that does not represent an entity.
-
getRequiredLeafEntity
TheRelationalPersistentEntity
associated with the leaf of this path or throwIllegalStateException
if the leaf cannot be resolved.- Returns:
- the required
RelationalPersistentEntity
associated with the leaf of this path. - Throws:
IllegalStateException
- if the persistent entity cannot be resolved.- Since:
- 3.0
-
isEntity
public boolean isEntity()- Returns:
- true when this is an empty path or the path references an entity.
-
isQualified
public boolean isQualified() -
isCollectionLike
public boolean isCollectionLike()- Returns:
- true when this is references a
Collection
or an array.
-
getReverseColumnName
The name of the column used to reference the id in the parent table.- Throws:
IllegalStateException
- when called on an empty path.
-
getReverseColumnNameAlias
The alias used in select for the column used to reference the id in the parent table.- Throws:
IllegalStateException
- when called on an empty path.
-
getColumnName
The name of the column used to represent this property in the database.- Throws:
IllegalStateException
- when called on an empty path.
-
getColumnAlias
The alias for the column used to represent this property in the database.- Throws:
IllegalStateException
- when called on an empty path.
-
hasIdProperty
public boolean hasIdProperty()- Returns:
- true if this path represents an entity which has an Id attribute.
-
getIdDefiningParentPath
Returns the longest ancestor path that has anId
property.- Returns:
- A path that starts just as this path but is shorter. Guaranteed to be not null.
-
getQualifiedTableName
The fully qualified name of the table this path is tied to or of the longest ancestor path that is actually tied to a table.- Returns:
- the name of the table. Guaranteed to be not null.
- Since:
- 3.0
-
getTableName
The name of the table this path is tied to or of the longest ancestor path that is actually tied to a table.- Returns:
- the name of the table. Guaranteed to be not null.
- Since:
- 3.0
-
getTableAlias
The alias used for the table on which this path is based.- Returns:
- a table alias, null if the table owning path is the empty path.
-
getIdColumnName
The column name of the id column of the ancestor path that represents an actual table. -
getEffectiveIdColumnName
If the table owning ancestor has an id the column name of that id property is returned. Otherwise the reverse column is returned. -
getLength
public int getLength()The length of the path. -
matches
Tests ifthis
and the argument represent the same path.- Parameters:
path
- to which this path gets compared. May be null.- Returns:
- Whence the argument matches the path represented by this instance.
-
getRequiredIdProperty
The id property of the final element of the path.- Returns:
- Guaranteed to be not null.
- Throws:
IllegalStateException
- if no such property exists.
-
getQualifierColumn
The column name used for the list index or map key of the leaf property of this path.- Returns:
- May be null.
-
getQualifierColumnType
The type of the qualifier column of the leaf property of this path or null if this is not applicable.- Returns:
- may be null.
-
extendBy
Creates a new path by extending the current path by the property passed as an argument.- Parameters:
property
- must not be null.- Returns:
- Guaranteed to be not null.
-
toString
-
getActualType
For empty paths this is the type of the entity. For non empty paths this is the actual type of the leaf property.- Returns:
- Guaranteed to be not null.
- See Also:
-
isOrdered
public boolean isOrdered()- Returns:
- whether the leaf end of the path is ordered, i.e. the data to populate must be ordered.
- See Also:
-
isMap
public boolean isMap()- Returns:
- true if the leaf property of this path is a
Map
. - See Also:
-
getRequiredPersistentPropertyPath
public PersistentPropertyPath<? extends RelationalPersistentProperty> getRequiredPersistentPropertyPath()Converts this path to a non-nullPersistentPropertyPath
.- Returns:
- Guaranteed to be not null.
- Throws:
IllegalStateException
- if this path is empty.
-
equals
-
hashCode
public int hashCode()
-