Class SpannerPersistentEntityImpl<T>
java.lang.Object
org.springframework.data.mapping.model.BasicPersistentEntity<T,SpannerPersistentProperty>
com.google.cloud.spring.data.spanner.core.mapping.SpannerPersistentEntityImpl<T>
- Type Parameters:
T
- the type of the persistent entity
- All Implemented Interfaces:
SpannerPersistentEntity<T>
,Iterable<SpannerPersistentProperty>
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.context.EnvironmentAware
,org.springframework.data.mapping.model.MutablePersistentEntity<T,
,SpannerPersistentProperty> org.springframework.data.mapping.PersistentEntity<T,
SpannerPersistentProperty>
public class SpannerPersistentEntityImpl<T>
extends org.springframework.data.mapping.model.BasicPersistentEntity<T,SpannerPersistentProperty>
implements SpannerPersistentEntity<T>
Represents a Cloud Spanner table and its columns' mapping to fields within an entity type.
- Since:
- 1.1
-
Constructor Summary
ConstructorDescriptionSpannerPersistentEntityImpl
(org.springframework.data.util.TypeInformation<T> information, SpannerMappingContext spannerMappingContext, SpannerEntityProcessor spannerEntityProcessor) Creates aSpannerPersistentEntityImpl
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
columns()
Gets the column names stored for this entity.void
doWithColumnBackedProperties
(org.springframework.data.mapping.PropertyHandler<SpannerPersistentProperty> handler) Applies the givenPropertyHandler
to allSpannerPersistentProperty
s contained in thisSpannerPersistentProperty
that are stored as columns in the table for this entity.void
doWithInterleavedProperties
(org.springframework.data.mapping.PropertyHandler<SpannerPersistentProperty> handler) Applies the givenPropertyHandler
to allSpannerPersistentProperty
s contained in thisSpannerPersistentProperty
that are collections of child entities.Gets the primary key properties in order.Returns a primary key column name; if there are multiple primary key columns, returns first one.Gets the primary key properties in order.<B> org.springframework.data.mapping.PersistentPropertyAccessor<B>
getPropertyAccessor
(B object) Gets a SpannerEntityProcessor that can be used to create Cloud Spanner keys from one or more persistent properties.Gets the SpannerMappingContext that can be used to create persistent entities of types that appear as properties of this entity.getWhere()
Returns the value of theWhere
annotation from the entity's class or inherited from parents or an empty string when no annotation found.protected boolean
boolean
Returns true if the entity has at least one eagerly load interleaved property.boolean
boolean
Returns true if the entity has a muti-field key.boolean
hasWhere()
Returns true when the entity has an annotationWhere
with a non-empty value.boolean
isJsonProperty
(Class<?> type) void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) Gets the name of the Cloud Spanner table.void
verify()
Methods inherited from class org.springframework.data.mapping.model.BasicPersistentEntity
addAssociation, doWithAssociations, doWithAssociations, doWithProperties, doWithProperties, findAnnotation, getEvaluationContext, getEvaluationContext, getFallbackIsNewStrategy, getIdentifierAccessor, getInstanceCreatorMetadata, getName, getPersistenceConstructor, getPersistentProperties, getPersistentProperty, getPropertyPathAccessor, getType, getTypeAlias, getTypeInformation, getValueEvaluationContext, getValueEvaluationContext, getVersionProperty, hasVersionProperty, isAnnotationPresent, isCreatorArgument, isIdProperty, isImmutable, isNew, isVersionProperty, iterator, requiresPropertyPopulation, returnPropertyIfBetterIdPropertyCandidateOrNull, setEnvironment, setEvaluationContextProvider, setPersistentPropertyAccessorFactory
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.EnvironmentAware
setEnvironment
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.springframework.data.mapping.model.MutablePersistentEntity
addAssociation, setEvaluationContextProvider, setPersistentPropertyAccessorFactory
Methods inherited from interface org.springframework.data.mapping.PersistentEntity
doWithAll, doWithAssociations, doWithAssociations, doWithProperties, doWithProperties, findAnnotation, getIdentifierAccessor, getInstanceCreatorMetadata, getName, getPersistenceConstructor, getPersistentProperties, getPersistentProperty, getPersistentProperty, getPropertyPathAccessor, getRequiredAnnotation, getRequiredIdProperty, getRequiredPersistentProperty, getRequiredVersionProperty, getType, getTypeAlias, getTypeInformation, getVersionProperty, hasVersionProperty, isAnnotationPresent, isConstructorArgument, isCreatorArgument, isIdProperty, isImmutable, isNew, isVersionProperty, requiresPropertyPopulation
-
Constructor Details
-
SpannerPersistentEntityImpl
public SpannerPersistentEntityImpl(org.springframework.data.util.TypeInformation<T> information, SpannerMappingContext spannerMappingContext, SpannerEntityProcessor spannerEntityProcessor) Creates aSpannerPersistentEntityImpl
.- Parameters:
information
- type information about the underlying entity type.spannerMappingContext
- a mapping context that can be used to create persistent entities from properties of this entityspannerEntityProcessor
- an entity processor used to create keys by converting and combining id properties, as well as to convert keys to property values
-
-
Method Details
-
hasAnnotatedTableName
protected boolean hasAnnotatedTableName() -
addPersistentProperty
- Specified by:
addPersistentProperty
in interfaceorg.springframework.data.mapping.model.MutablePersistentEntity<T,
SpannerPersistentProperty> - Overrides:
addPersistentProperty
in classorg.springframework.data.mapping.model.BasicPersistentEntity<T,
SpannerPersistentProperty>
-
getIdProperty
- Specified by:
getIdProperty
in interfaceorg.springframework.data.mapping.PersistentEntity<T,
SpannerPersistentProperty> - Specified by:
getIdProperty
in interfaceSpannerPersistentEntity<T>
- Overrides:
getIdProperty
in classorg.springframework.data.mapping.model.BasicPersistentEntity<T,
SpannerPersistentProperty>
-
doWithInterleavedProperties
public void doWithInterleavedProperties(org.springframework.data.mapping.PropertyHandler<SpannerPersistentProperty> handler) Description copied from interface:SpannerPersistentEntity
Applies the givenPropertyHandler
to allSpannerPersistentProperty
s contained in thisSpannerPersistentProperty
that are collections of child entities.- Specified by:
doWithInterleavedProperties
in interfaceSpannerPersistentEntity<T>
- Parameters:
handler
- must not be null.
-
doWithColumnBackedProperties
public void doWithColumnBackedProperties(org.springframework.data.mapping.PropertyHandler<SpannerPersistentProperty> handler) Description copied from interface:SpannerPersistentEntity
Applies the givenPropertyHandler
to allSpannerPersistentProperty
s contained in thisSpannerPersistentProperty
that are stored as columns in the table for this entity.- Specified by:
doWithColumnBackedProperties
in interfaceSpannerPersistentEntity<T>
- Parameters:
handler
- must not be null.
-
hasIdProperty
public boolean hasIdProperty()- Specified by:
hasIdProperty
in interfaceorg.springframework.data.mapping.PersistentEntity<T,
SpannerPersistentProperty> - Overrides:
hasIdProperty
in classorg.springframework.data.mapping.model.BasicPersistentEntity<T,
SpannerPersistentProperty>
-
verify
public void verify()- Specified by:
verify
in interfaceorg.springframework.data.mapping.model.MutablePersistentEntity<T,
SpannerPersistentProperty> - Overrides:
verify
in classorg.springframework.data.mapping.model.BasicPersistentEntity<T,
SpannerPersistentProperty>
-
getPrimaryKeyProperties
Description copied from interface:SpannerPersistentEntity
Gets the primary key properties in order. Embedded object properties containing key parts are represented as a single property.- Specified by:
getPrimaryKeyProperties
in interfaceSpannerPersistentEntity<T>
- Returns:
- an array of the properties comprising the primary key in order.
-
getFlattenedPrimaryKeyProperties
Description copied from interface:SpannerPersistentEntity
Gets the primary key properties in order. Embedded object properties containing key parts are flattened into their multiple primary key properties.- Specified by:
getFlattenedPrimaryKeyProperties
in interfaceSpannerPersistentEntity<T>
- Returns:
- an array of the properties comprising the primary key in order.
-
getSpannerMappingContext
Description copied from interface:SpannerPersistentEntity
Gets the SpannerMappingContext that can be used to create persistent entities of types that appear as properties of this entity.- Specified by:
getSpannerMappingContext
in interfaceSpannerPersistentEntity<T>
- Returns:
- the SpannerMappingContext instance
-
getSpannerEntityProcessor
Description copied from interface:SpannerPersistentEntity
Gets a SpannerEntityProcessor that can be used to create Cloud Spanner keys from one or more persistent properties.- Specified by:
getSpannerEntityProcessor
in interfaceSpannerPersistentEntity<T>
- Returns:
- a SpannerEntityProcessor.
-
tableName
Description copied from interface:SpannerPersistentEntity
Gets the name of the Cloud Spanner table.- Specified by:
tableName
in interfaceSpannerPersistentEntity<T>
- Returns:
- the name of the table.
-
hasMultiFieldKey
public boolean hasMultiFieldKey()Description copied from interface:SpannerPersistentEntity
Returns true if the entity has a muti-field key.- Specified by:
hasMultiFieldKey
in interfaceSpannerPersistentEntity<T>
- Returns:
- true if the entity has a muti-field key
-
hasEagerlyLoadedProperties
public boolean hasEagerlyLoadedProperties()Description copied from interface:SpannerPersistentEntity
Returns true if the entity has at least one eagerly load interleaved property.- Specified by:
hasEagerlyLoadedProperties
in interfaceSpannerPersistentEntity<T>
- Returns:
- true if the entity has at least one eagerly load interleaved property
- See Also:
-
getWhere
Description copied from interface:SpannerPersistentEntity
Returns the value of theWhere
annotation from the entity's class or inherited from parents or an empty string when no annotation found.- Specified by:
getWhere
in interfaceSpannerPersistentEntity<T>
- Returns:
- the value of the
Where
from the entity's class or inherited from parents or an empty string when no annotation found. - See Also:
-
hasWhere
public boolean hasWhere()Description copied from interface:SpannerPersistentEntity
Returns true when the entity has an annotationWhere
with a non-empty value.- Specified by:
hasWhere
in interfaceSpannerPersistentEntity<T>
- Returns:
- true when the entity has an annotation
Where
with a non-empty value. - See Also:
-
columns
Description copied from interface:SpannerPersistentEntity
Gets the column names stored for this entity.- Specified by:
columns
in interfaceSpannerPersistentEntity<T>
- Returns:
- the column names.
-
isJsonProperty
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
getPropertyAccessor
@NonNull public <B> org.springframework.data.mapping.PersistentPropertyAccessor<B> getPropertyAccessor(@NonNull B object) - Specified by:
getPropertyAccessor
in interfaceorg.springframework.data.mapping.PersistentEntity<T,
SpannerPersistentProperty> - Overrides:
getPropertyAccessor
in classorg.springframework.data.mapping.model.BasicPersistentEntity<T,
SpannerPersistentProperty>
-
getPrimaryKeyColumnName
Description copied from interface:SpannerPersistentEntity
Returns a primary key column name; if there are multiple primary key columns, returns first one. In case of embedded keys it works recursively.- Specified by:
getPrimaryKeyColumnName
in interfaceSpannerPersistentEntity<T>
- Returns:
- a primary key column name
-