org.springframework.data.relational.core.mapping

## Class PersistentPropertyPathExtension

- java.lang.Object
- - org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension

    public class PersistentPropertyPathExtension
    extends Object

A wrapper around a `PersistentPropertyPath` for making common operations available used in SQL generation and conversion

Since:
  1.1
Author:
  Jens Schauder

### Constructor Summary

Constructors
Constructor and Description
`PersistentPropertyPathExtension(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

All Methods Instance Methods Concrete Methods
`boolean` `equals(Object o)`
`PersistentPropertyPathExtension` `extendBy(RelationalPersistentProperty property)` Creates a new path by extending the current path by the property passed as an argument.
`Class<?>` `getActualType()` For empty paths this is the type of the entity.
`SqlIdentifier` `getColumnAlias()` The alias for the column used to represent this property in the database.
`SqlIdentifier` `getColumnName()` The name of the column used to represent this property in the database.
`SqlIdentifier` `getEffectiveIdColumnName()` If the table owning ancestor has an id the column name of that id property is returned.
`SqlIdentifier` `getIdColumnName()` The column name of the id column of the ancestor path that represents an actual table.
`PersistentPropertyPathExtension` `getIdDefiningParentPath()` Returns the longest ancestor path that has an `Id` property.
`RelationalPersistentEntity<?>` `getLeafEntity()` The `RelationalPersistentEntity` associated with the leaf of this path.
`int` `getLength()` The length of the path.
`PersistentPropertyPathExtension` `getParentPath()` Returns the path that has the same beginning but is one segment shorter than this path.
`SqlIdentifier` `getQualifierColumn()` The column name used for the list index or map key of the leaf property of this path.
`Class<?>` `getQualifierColumnType()` The type of the qualifier column of the leaf property of this path or null if this is not applicable.
`RelationalPersistentProperty` `getRequiredIdProperty()` The id property of the final element of the path.
`PersistentPropertyPath<? extends RelationalPersistentProperty>` `getRequiredPersistentPropertyPath()` Converts this path to a non-null `PersistentPropertyPath`.
`SqlIdentifier` `getReverseColumnName()` The name of the column used to reference the id in the parent table.
`SqlIdentifier` `getReverseColumnNameAlias()` The alias used in select for the column used to reference the id in the parent table.
`SqlIdentifier` `getTableAlias()` The alias used for the table on which this path is based.
`SqlIdentifier` `getTableName()` 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` `hasIdProperty()`
`boolean` `isCollectionLike()`
`boolean` `isEmbedded()` Returns true exactly when the path is non empty and the leaf property an embedded one.
`boolean` `isEntity()`
`boolean` `isMap()`
`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.
`boolean` `isOrdered()`
`boolean` `isQualified()`
`boolean` `matches(PersistentPropertyPath<RelationalPersistentProperty> path)` Tests if `this` and the argument represent the same path.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### 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 Detail

#### 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

    public PersistentPropertyPathExtension 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

    @Nullable
    public RelationalPersistentEntity<?> getLeafEntity()

The `RelationalPersistentEntity` associated with the leaf of this path.

Returns:
  Might return null when called on a path that does not represent an entity.

#### isEntity

    public boolean isEntity()

Returns:
  true when this is an empty path or the path references an entity.

#### isQualified

    public boolean isQualified()

Returns:
  true when this is references a `List` or `Map`.

#### isCollectionLike

    public boolean isCollectionLike()

Returns:
  true when this is references a `Collection` or an array.

#### getReverseColumnName

    public SqlIdentifier getReverseColumnName()

The name of the column used to reference the id in the parent table.

Throws:
  `IllegalStateException` - when called on an empty path.

#### getReverseColumnNameAlias

    public SqlIdentifier 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

    public SqlIdentifier getColumnName()

The name of the column used to represent this property in the database.

Throws:
  `IllegalStateException` - when called on an empty path.

#### getColumnAlias

    public SqlIdentifier 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

    public PersistentPropertyPathExtension getIdDefiningParentPath()

Returns the longest ancestor path that has an `Id` property.

Returns:
  A path that starts just as this path but is shorter. Guaranteed to be not null.

#### getTableName

    public SqlIdentifier 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.

#### getTableAlias

    @Nullable
    public SqlIdentifier 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

    public SqlIdentifier getIdColumnName()

The column name of the id column of the ancestor path that represents an actual table.

#### getEffectiveIdColumnName

    public SqlIdentifier 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

    public boolean matches(PersistentPropertyPath<RelationalPersistentProperty> path)

Tests if `this` 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

    public RelationalPersistentProperty 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

    @Nullable
    public SqlIdentifier getQualifierColumn()

The column name used for the list index or map key of the leaf property of this path.

Returns:
  May be null.

#### getQualifierColumnType

    @Nullable
    public Class<?> 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

    public PersistentPropertyPathExtension extendBy(RelationalPersistentProperty property)

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

    public String toString()

Overrides:
  `toString` in class `Object`

#### getActualType

    public Class<?> 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:
  `PersistentProperty.getActualType()`

#### 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:
  `RelationalPersistentProperty.isOrdered()`

#### isMap

    public boolean isMap()

Returns:
  true if the leaf property of this path is a `Map`.
See Also:
  `PersistentProperty.isMap()`

#### getRequiredPersistentPropertyPath

    public PersistentPropertyPath<? extends RelationalPersistentProperty> getRequiredPersistentPropertyPath()

Converts this path to a non-null `PersistentPropertyPath`.

Returns:
  Guaranteed to be not null.
Throws:
  `IllegalStateException` - if this path is empty.

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`