Class SpannerMutationFactoryImpl

java.lang.Object
com.google.cloud.spring.data.spanner.core.SpannerMutationFactoryImpl
All Implemented Interfaces:
SpannerMutationFactory

public class SpannerMutationFactoryImpl extends Object implements SpannerMutationFactory
Factory that generates mutations for writing to Spanner.
Since:
1.1
  • Constructor Summary

    Constructors
    Constructor
    Description
    SpannerMutationFactoryImpl(SpannerEntityProcessor spannerEntityProcessor, SpannerMappingContext spannerMappingContext, SpannerSchemaUtils spannerSchemaUtils)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> com.google.cloud.spanner.Mutation
    delete(Class<T> entityClass, Iterable<? extends T> entities)
    Deletes several objects from Spanner.
    com.google.cloud.spanner.Mutation
    delete(Class entityClass, com.google.cloud.spanner.Key key)
    Deletes a key from Spanner.
    com.google.cloud.spanner.Mutation
    delete(Class entityClass, com.google.cloud.spanner.KeySet keys)
    Deletes a set of keys from Spanner.
    <T> com.google.cloud.spanner.Mutation
    delete(T object)
    Deletes a single object from Spanner.
    List<com.google.cloud.spanner.Mutation>
    insert(Object object)
    Stores an object and its interleaved child properties in Cloud Spanner.
    List<com.google.cloud.spanner.Mutation>
    update(Object object, Set<String> includeProperties)
    Updates an object and its interleaved child properties in Cloud Spanner.
    List<com.google.cloud.spanner.Mutation>
    upsert(Object object, Set<String> includeProperties)
    Updates or inserts an object and its interleaved child properties in Cloud Spanner.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SpannerMutationFactoryImpl

      public SpannerMutationFactoryImpl(SpannerEntityProcessor spannerEntityProcessor, SpannerMappingContext spannerMappingContext, SpannerSchemaUtils spannerSchemaUtils)
      Constructor.
      Parameters:
      spannerEntityProcessor - the object mapper used to convert between objects and Spanner data types.
      spannerMappingContext - the mapping context used to get metadata from entity types.
      spannerSchemaUtils - the schema utility to use
  • Method Details

    • insert

      public List<com.google.cloud.spanner.Mutation> insert(Object object)
      Description copied from interface: SpannerMutationFactory
      Stores an object and its interleaved child properties in Cloud Spanner. There will be 1 mutation for each entity corresponding to a row in Cloud Spanner. If there are no interleaved children then the returned list will contain the single mutation for the given object.
      Specified by:
      insert in interface SpannerMutationFactory
      Parameters:
      object - the object to store.
      Returns:
      the mutation operations which will store the object and its children.
    • upsert

      public List<com.google.cloud.spanner.Mutation> upsert(Object object, Set<String> includeProperties)
      Description copied from interface: SpannerMutationFactory
      Updates or inserts an object and its interleaved child properties in Cloud Spanner. There will be 1 mutation for each entity corresponding to a row in Cloud Spanner. If there are no interleaved children then the returned list will contain the single mutation for the given object.
      Specified by:
      upsert in interface SpannerMutationFactory
      Parameters:
      object - the object to update or newly insert.
      includeProperties - the properties to use in the operation. if null then all properties are used.
      Returns:
      the mutation operations which will store the object and its children.
    • update

      public List<com.google.cloud.spanner.Mutation> update(Object object, Set<String> includeProperties)
      Description copied from interface: SpannerMutationFactory
      Updates an object and its interleaved child properties in Cloud Spanner. There will be 1 mutation for each entity corresponding to a row in Cloud Spanner. If there are no interleaved children then the returned list will contain the single mutation for the given object.
      Specified by:
      update in interface SpannerMutationFactory
      Parameters:
      object - the object to update.
      includeProperties - the properties to use in the operation. if null then all properties are used.
      Returns:
      the mutation operations which will store the object and its children.
    • delete

      public <T> com.google.cloud.spanner.Mutation delete(Class<T> entityClass, Iterable<? extends T> entities)
      Description copied from interface: SpannerMutationFactory
      Deletes several objects from Spanner.
      Specified by:
      delete in interface SpannerMutationFactory
      Type Parameters:
      T - the type of object to delete.
      Parameters:
      entityClass - the type of the objects to delete.
      entities - a list of objects to delete. Each object can be a subtype of entityClass.
      Returns:
      the delete mutation.
    • delete

      public <T> com.google.cloud.spanner.Mutation delete(T object)
      Description copied from interface: SpannerMutationFactory
      Deletes a single object from Spanner.
      Specified by:
      delete in interface SpannerMutationFactory
      Type Parameters:
      T - the type of the object to delete.
      Parameters:
      object - the object to delete.
      Returns:
      the delete mutation.
    • delete

      public com.google.cloud.spanner.Mutation delete(Class entityClass, com.google.cloud.spanner.KeySet keys)
      Description copied from interface: SpannerMutationFactory
      Deletes a set of keys from Spanner.
      Specified by:
      delete in interface SpannerMutationFactory
      Parameters:
      entityClass - the type of the entity to delete.
      keys - the keys of the objects to delete.
      Returns:
      the delete mutation.
    • delete

      public com.google.cloud.spanner.Mutation delete(Class entityClass, com.google.cloud.spanner.Key key)
      Description copied from interface: SpannerMutationFactory
      Deletes a key from Spanner.
      Specified by:
      delete in interface SpannerMutationFactory
      Parameters:
      entityClass - the type of the entity to delete.
      key - the key of the object to delete.
      Returns:
      the delete mutation.