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.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
ConstructorsConstructorDescriptionSpannerPersistentEntityImpl(org.springframework.data.util.TypeInformation<T> information, SpannerMappingContext spannerMappingContext, SpannerEntityProcessor spannerEntityProcessor) Creates aSpannerPersistentEntityImpl. -
Method Summary
Modifier and TypeMethodDescriptionvoidcolumns()Gets the column names stored for this entity.voiddoWithColumnBackedProperties(org.springframework.data.mapping.PropertyHandler<SpannerPersistentProperty> handler) Applies the givenPropertyHandlerto allSpannerPersistentPropertys contained in thisSpannerPersistentPropertythat are stored as columns in the table for this entity.voiddoWithInterleavedProperties(org.springframework.data.mapping.PropertyHandler<SpannerPersistentProperty> handler) Applies the givenPropertyHandlerto allSpannerPersistentPropertys contained in thisSpannerPersistentPropertythat 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 theWhereannotation from the entity's class or inherited from parents or an empty string when no annotation found.protected booleanbooleanReturns true if the entity has at least one eagerly load interleaved property.booleanbooleanReturns true if the entity has a muti-field key.booleanhasWhere()Returns true when the entity has an annotationWherewith a non-empty value.booleanisJsonProperty(Class<?> type) voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) Gets the name of the Cloud Spanner table.voidverify()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, getVersionProperty, hasVersionProperty, isAnnotationPresent, isCreatorArgument, isIdProperty, isImmutable, isNew, isVersionProperty, iterator, requiresPropertyPopulation, returnPropertyIfBetterIdPropertyCandidateOrNull, setEvaluationContextProvider, setPersistentPropertyAccessorFactoryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface org.springframework.data.mapping.model.MutablePersistentEntity
addAssociation, setEvaluationContextProvider, setPersistentPropertyAccessorFactoryMethods 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:
addPersistentPropertyin interfaceorg.springframework.data.mapping.model.MutablePersistentEntity<T,SpannerPersistentProperty> - Overrides:
addPersistentPropertyin classorg.springframework.data.mapping.model.BasicPersistentEntity<T,SpannerPersistentProperty>
-
getIdProperty
- Specified by:
getIdPropertyin interfaceorg.springframework.data.mapping.PersistentEntity<T,SpannerPersistentProperty> - Specified by:
getIdPropertyin interfaceSpannerPersistentEntity<T>- Overrides:
getIdPropertyin classorg.springframework.data.mapping.model.BasicPersistentEntity<T,SpannerPersistentProperty>
-
doWithInterleavedProperties
public void doWithInterleavedProperties(org.springframework.data.mapping.PropertyHandler<SpannerPersistentProperty> handler) Description copied from interface:SpannerPersistentEntityApplies the givenPropertyHandlerto allSpannerPersistentPropertys contained in thisSpannerPersistentPropertythat are collections of child entities.- Specified by:
doWithInterleavedPropertiesin interfaceSpannerPersistentEntity<T>- Parameters:
handler- must not be null.
-
doWithColumnBackedProperties
public void doWithColumnBackedProperties(org.springframework.data.mapping.PropertyHandler<SpannerPersistentProperty> handler) Description copied from interface:SpannerPersistentEntityApplies the givenPropertyHandlerto allSpannerPersistentPropertys contained in thisSpannerPersistentPropertythat are stored as columns in the table for this entity.- Specified by:
doWithColumnBackedPropertiesin interfaceSpannerPersistentEntity<T>- Parameters:
handler- must not be null.
-
hasIdProperty
public boolean hasIdProperty()- Specified by:
hasIdPropertyin interfaceorg.springframework.data.mapping.PersistentEntity<T,SpannerPersistentProperty> - Overrides:
hasIdPropertyin classorg.springframework.data.mapping.model.BasicPersistentEntity<T,SpannerPersistentProperty>
-
verify
public void verify()- Specified by:
verifyin interfaceorg.springframework.data.mapping.model.MutablePersistentEntity<T,SpannerPersistentProperty> - Overrides:
verifyin classorg.springframework.data.mapping.model.BasicPersistentEntity<T,SpannerPersistentProperty>
-
getPrimaryKeyProperties
Description copied from interface:SpannerPersistentEntityGets the primary key properties in order. Embedded object properties containing key parts are represented as a single property.- Specified by:
getPrimaryKeyPropertiesin interfaceSpannerPersistentEntity<T>- Returns:
- an array of the properties comprising the primary key in order.
-
getFlattenedPrimaryKeyProperties
Description copied from interface:SpannerPersistentEntityGets the primary key properties in order. Embedded object properties containing key parts are flattened into their multiple primary key properties.- Specified by:
getFlattenedPrimaryKeyPropertiesin interfaceSpannerPersistentEntity<T>- Returns:
- an array of the properties comprising the primary key in order.
-
getSpannerMappingContext
Description copied from interface:SpannerPersistentEntityGets the SpannerMappingContext that can be used to create persistent entities of types that appear as properties of this entity.- Specified by:
getSpannerMappingContextin interfaceSpannerPersistentEntity<T>- Returns:
- the SpannerMappingContext instance
-
getSpannerEntityProcessor
Description copied from interface:SpannerPersistentEntityGets a SpannerEntityProcessor that can be used to create Cloud Spanner keys from one or more persistent properties.- Specified by:
getSpannerEntityProcessorin interfaceSpannerPersistentEntity<T>- Returns:
- a SpannerEntityProcessor.
-
tableName
Description copied from interface:SpannerPersistentEntityGets the name of the Cloud Spanner table.- Specified by:
tableNamein interfaceSpannerPersistentEntity<T>- Returns:
- the name of the table.
-
hasMultiFieldKey
public boolean hasMultiFieldKey()Description copied from interface:SpannerPersistentEntityReturns true if the entity has a muti-field key.- Specified by:
hasMultiFieldKeyin interfaceSpannerPersistentEntity<T>- Returns:
- true if the entity has a muti-field key
-
hasEagerlyLoadedProperties
public boolean hasEagerlyLoadedProperties()Description copied from interface:SpannerPersistentEntityReturns true if the entity has at least one eagerly load interleaved property.- Specified by:
hasEagerlyLoadedPropertiesin interfaceSpannerPersistentEntity<T>- Returns:
- true if the entity has at least one eagerly load interleaved property
- See Also:
-
getWhere
Description copied from interface:SpannerPersistentEntityReturns the value of theWhereannotation from the entity's class or inherited from parents or an empty string when no annotation found.- Specified by:
getWherein interfaceSpannerPersistentEntity<T>- Returns:
- the value of the
Wherefrom 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:SpannerPersistentEntityReturns true when the entity has an annotationWherewith a non-empty value.- Specified by:
hasWherein interfaceSpannerPersistentEntity<T>- Returns:
- true when the entity has an annotation
Wherewith a non-empty value. - See Also:
-
columns
Description copied from interface:SpannerPersistentEntityGets the column names stored for this entity.- Specified by:
columnsin interfaceSpannerPersistentEntity<T>- Returns:
- the column names.
-
isJsonProperty
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin 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:
getPropertyAccessorin interfaceorg.springframework.data.mapping.PersistentEntity<T,SpannerPersistentProperty> - Overrides:
getPropertyAccessorin classorg.springframework.data.mapping.model.BasicPersistentEntity<T,SpannerPersistentProperty>
-
getPrimaryKeyColumnName
Description copied from interface:SpannerPersistentEntityReturns 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:
getPrimaryKeyColumnNamein interfaceSpannerPersistentEntity<T>- Returns:
- a primary key column name
-