Package com.oracle.nosql.spring.data.core

# Class NosqlTemplate

java.lang.Object
com.oracle.nosql.spring.data.core.NosqlTemplateBase
com.oracle.nosql.spring.data.core.NosqlTemplate

All Implemented Interfaces:
  `NosqlOperations`, `org.springframework.beans.factory.Aware`, `org.springframework.context.ApplicationContextAware`

public class NosqlTemplate extends NosqlTemplateBase implements NosqlOperations

- ## Field Summary

  ### Fields inherited from class com.oracle.nosql.spring.data.core.NosqlTemplateBase

  `applicationContext, JSON_COLUMN, LOG, mappingNosqlConverter, nosqlClient, nosqlDbFactory, psCache`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NosqlTemplate(NosqlDbFactory nosqlDbFactory, MappingNosqlConverter mappingNosqlConverter)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `count(NosqlEntityInformation<?,?> entityInformation)`
  Returns a count of all the entries in the given table.
  `<T> Iterable<MapValue>`
  `count(NosqlEntityInformation<T,?> entityInformation, NosqlQuery query)`
  `static NosqlTemplate`
  `create(NosqlDbConfig nosqlDBConfig)`
  `static NosqlTemplate`
  `create(NosqlDbFactory nosqlDbFactory)`
  `boolean`
  `createTableIfNotExists(NosqlEntityInformation<?,?> entityInformation)`
  Creates a table for the given entity type if it doesn't exist.
  `<T, ID> Iterable<T>`
  `delete(NosqlEntityInformation<T,ID> entityInformation, NosqlQuery query)`
  `void`
  `deleteAll(NosqlEntityInformation<?,?> entityInformation)`
  Deletes all entries from the given table.
  `<T, ID> void`
  `deleteAll(NosqlEntityInformation<T,ID> entityInformation, Iterable<? extends ID> ids)`
  Deletes all the entries with the ids from the given table.
  `<T, ID> void`
  `deleteById(NosqlEntityInformation<T,ID> entityInformation, ID id)`
  Deletes the entity with the id from the given table.
  `<T, ID> void`
  `deleteInShard(String tableName, Class<T> entityClass, Iterable<? extends ID> ids)`
  Deletes ids from one shard.
  `boolean`
  `dropTableIfExists(String tableName)`
  Drops table and returns true if result indicates table state changed to DROPPED or DROPPING.
  `<S, T> Iterable<T>`
  `find(NosqlEntityInformation<S,?> entityInformation, Class<T> targetType, NosqlQuery query)`
  Executes a NosqlQuery (this can be a CriteriaQuery for queries derived from repository method names or a StringQuery for native queries).
  `<T> Iterable<T>`
  `findAll(NosqlEntityInformation<T,?> entityInformation)`
  Returns a result of all the entities in the given table.
  `<T> org.springframework.data.domain.Page<T>`
  `findAll(NosqlEntityInformation<T,?> entityInformation, org.springframework.data.domain.Pageable pageable)`
  Returns all entities in the given table sorted accordingly grouped in pages.
  `<T> Iterable<T>`
  `findAll(NosqlEntityInformation<T,?> entityInformation, org.springframework.data.domain.Sort sort)`
  Returns all entities in the given table sorted accordingly.
  `<T> Iterable<T>`
  `findAll(Class<T> entityClass)`
  Returns a result of all the entities in the table.
  `<T, ID> Iterable<T>`
  `findAllById(NosqlEntityInformation<T,ID> entityInformation, Iterable<ID> ids)`
  Returns all the entities in the table for the given ids.
  `<T, ID> T`
  `findById(NosqlEntityInformation<T,ID> entityInformation, ID id)`
  Returns the entity for the given id in the given table.
  `<T, ID> T`
  `findById(ID id, Class<T> javaType)`
  Returns the entity for the given table.
  `MappingNosqlConverter`
  `getConverter()`
  Returns the assigned mapping converter.
  `NoSQLHandle`
  `getNosqlClient()`
  `<T> NosqlEntityInformation<T,?>`
  `getNosqlEntityInformation(Class<T> domainClass)`
  `String`
  `getTableName(Class<?> domainClass)`
  Returns the tableName for the given entity class.
  `<T, ID> T`
  `insert(NosqlEntityInformation<T,ID> entityInformation, T entity)`
  If entity doesn't have autogen field objectToSave is wrote using put.
  `<T> T`
  `insert(T entity)`
  Inserts the entity into the table, if id generated is used the id field must be null or 0.
  `Iterable<MapValue>`
  `runQuery(NosqlEntityInformation<?,?> entityInformation, String query)`
  `Iterable<MapValue>`
  `runQueryJavaParams(NosqlEntityInformation<?,?> entityInformation, String query, Map<String,Object> javaParams)`
  javaParams is a Map of param_name to Java objects
  `Iterable<MapValue>`
  `runQueryNosqlParams(NosqlEntityInformation<?,?> entityInformation, String query, Map<String,FieldValue> nosqlParams)`
  nosqlParams is a Map of param_name to FieldValue
  `void`
  `runTableRequest(String statement)`
  `void`
  `setApplicationContext(org.springframework.context.ApplicationContext applicationContext)`
  `<T, ID> void`
  `update(NosqlEntityInformation<T,ID> entityInformation, T entity)`
  Updates the entity into the given table.
  `<T> void`
  `update(T entity)`
  Updates the entity into the table.

  ### Methods inherited from class com.oracle.nosql.spring.data.core.NosqlTemplateBase

  `clearPreparedStatementsCache, doCheckExistingTable, doCreateTable, doDelete, doExecuteMapValueQuery, doGet, doGetTable, doPut, doRunQueryNosqlParams, doTableRequest, doUpdate, getCreateTableDDL`

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface com.oracle.nosql.spring.data.core.NosqlOperations

  `clearPreparedStatementsCache`

- ## Constructor Details

  - ### NosqlTemplate

    public NosqlTemplate(NosqlDbFactory nosqlDbFactory, MappingNosqlConverter mappingNosqlConverter)

- ## Method Details

  - ### create

    public static NosqlTemplate create(NosqlDbConfig nosqlDBConfig) throws ClassNotFoundException
    Throws:
      `ClassNotFoundException`

  - ### create

    public static NosqlTemplate create(NosqlDbFactory nosqlDbFactory) throws ClassNotFoundException
    Throws:
      `ClassNotFoundException`

  - ### setApplicationContext

    public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
    Specified by:
      `setApplicationContext` in interface `org.springframework.context.ApplicationContextAware`
    Overrides:
      `setApplicationContext` in class `NosqlTemplateBase`
    Throws:
      `org.springframework.beans.BeansException`

  - ### getTableName

    public String getTableName(Class<?> domainClass)
    Description copied from interface: `NosqlOperations`
    Returns the tableName for the given entity class.
    Specified by:
      `getTableName` in interface `NosqlOperations`

  - ### createTableIfNotExists

    public boolean createTableIfNotExists(NosqlEntityInformation<?,?> entityInformation)
    Description copied from interface: `NosqlOperations`
    Creates a table for the given entity type if it doesn't exist.
    Specified by:
      `createTableIfNotExists` in interface `NosqlOperations`

  - ### insert

    public <T> T insert(@NonNull T entity)
    Description copied from interface: `NosqlOperations`
    Inserts the entity into the table, if id generated is used the id field must be null or 0.
    Specified by:
      `insert` in interface `NosqlOperations`

  - ### insert

    public <T, ID> T insert(NosqlEntityInformation<T,ID> entityInformation, @NonNull T entity)
    If entity doesn't have autogen field objectToSave is wrote using put. If entity has autogen field objectToSave should not have field set.
    Specified by:
      `insert` in interface `NosqlOperations`

  - ### update

    public <T> void update(T entity)
    Description copied from interface: `NosqlOperations`
    Updates the entity into the table. Entity must contain a valid id value.
    Specified by:
      `update` in interface `NosqlOperations`

  - ### update

    public <T, ID> void update(NosqlEntityInformation<T,ID> entityInformation, T entity)
    Description copied from interface: `NosqlOperations`
    Updates the entity into the given table. Entity must contain a valid id value.
    Specified by:
      `update` in interface `NosqlOperations`

  - ### deleteAll

    public void deleteAll(NosqlEntityInformation<?,?> entityInformation)
    Description copied from interface: `NosqlOperations`
    Deletes all entries from the given table.
    Specified by:
      `deleteAll` in interface `NosqlOperations`

  - ### deleteAll

    public <T, ID> void deleteAll(NosqlEntityInformation<T,ID> entityInformation, Iterable<? extends ID> ids)
    Description copied from interface: `NosqlOperations`
    Deletes all the entries with the ids from the given table.
    Specified by:
      `deleteAll` in interface `NosqlOperations`

  - ### deleteInShard

    public <T, ID> void deleteInShard(String tableName, Class<T> entityClass, Iterable<? extends ID> ids)
    Deletes ids from one shard. Note: All ids must be in the same shard otherwise it's an error. It uses `NoSQLHandle.writeMultiple(WriteMultipleRequest)`.

  - ### dropTableIfExists

    public boolean dropTableIfExists(String tableName)
    Drops table and returns true if result indicates table state changed to DROPPED or DROPPING. Uses `NosqlDbFactory.getTableReqTimeout()` and `NosqlDbFactory.getTableReqPollInterval()` to check the result.
    Specified by:
      `dropTableIfExists` in interface `NosqlOperations`

  - ### getConverter

    public MappingNosqlConverter getConverter()
    Description copied from interface: `NosqlOperations`
    Returns the assigned mapping converter.
    Specified by:
      `getConverter` in interface `NosqlOperations`

  - ### getNosqlEntityInformation

    public <T> NosqlEntityInformation<T,?> getNosqlEntityInformation(Class<T> domainClass)

  - ### findById

    public <T, ID> T findById(ID id, Class<T> javaType)
    Description copied from interface: `NosqlOperations`
    Returns the entity for the given table.
    Specified by:
      `findById` in interface `NosqlOperations`

  - ### findById

    public <T, ID> T findById(NosqlEntityInformation<T,ID> entityInformation, ID id)
    Description copied from interface: `NosqlOperations`
    Returns the entity for the given id in the given table.
    Specified by:
      `findById` in interface `NosqlOperations`

  - ### findAllById

    public <T, ID> Iterable<T> findAllById(NosqlEntityInformation<T,ID> entityInformation, Iterable<ID> ids)
    Description copied from interface: `NosqlOperations`
    Returns all the entities in the table for the given ids.
    Specified by:
      `findAllById` in interface `NosqlOperations`

  - ### deleteById

    public <T, ID> void deleteById(NosqlEntityInformation<T,ID> entityInformation, ID id)
    Description copied from interface: `NosqlOperations`
    Deletes the entity with the id from the given table.
    Specified by:
      `deleteById` in interface `NosqlOperations`

  - ### findAll

    public <T> Iterable<T> findAll(Class<T> entityClass)
    Description copied from interface: `NosqlOperations`
    Returns a result of all the entities in the table. Not recommended, unless table is known to contain a small amount of rows. Instead use the method with Pageable parameter.
    Specified by:
      `findAll` in interface `NosqlOperations`

  - ### findAll

    public <T> Iterable<T> findAll(NosqlEntityInformation<T,?> entityInformation)
    Description copied from interface: `NosqlOperations`
    Returns a result of all the entities in the given table. Not recommended, unless table is known to contain a small amount of rows. Instead use the method with Pageable parameter.
    Specified by:
      `findAll` in interface `NosqlOperations`

  - ### count

    public long count(NosqlEntityInformation<?,?> entityInformation)
    Description copied from interface: `NosqlOperations`
    Returns a count of all the entries in the given table.
    Specified by:
      `count` in interface `NosqlOperations`

  - ### findAll

    public <T> Iterable<T> findAll(NosqlEntityInformation<T,?> entityInformation, org.springframework.data.domain.Sort sort)
    Description copied from interface: `NosqlOperations`
    Returns all entities in the given table sorted accordingly.
    Specified by:
      `findAll` in interface `NosqlOperations`

  - ### findAll

    public <T> org.springframework.data.domain.Page<T> findAll(NosqlEntityInformation<T,?> entityInformation, org.springframework.data.domain.Pageable pageable)
    Description copied from interface: `NosqlOperations`
    Returns all entities in the given table sorted accordingly grouped in pages.
    Specified by:
      `findAll` in interface `NosqlOperations`

  - ### runTableRequest

    public void runTableRequest(String statement)

  - ### runQuery

    public Iterable<MapValue> runQuery(NosqlEntityInformation<?,?> entityInformation, String query)

  - ### runQueryJavaParams

    public Iterable<MapValue> runQueryJavaParams(NosqlEntityInformation<?,?> entityInformation, String query, Map<String,Object> javaParams)
    javaParams is a Map of param_name to Java objects

  - ### runQueryNosqlParams

    public Iterable<MapValue> runQueryNosqlParams(NosqlEntityInformation<?,?> entityInformation, String query, Map<String,FieldValue> nosqlParams)
    nosqlParams is a Map of param_name to FieldValue

  - ### count

    public <T> Iterable<MapValue> count(NosqlEntityInformation<T,?> entityInformation, NosqlQuery query)
    Specified by:
      `count` in interface `NosqlOperations`

  - ### delete

    public <T, ID> Iterable<T> delete(NosqlEntityInformation<T,ID> entityInformation, NosqlQuery query)
    Specified by:
      `delete` in interface `NosqlOperations`

  - ### find

    public <S, T> Iterable<T> find(NosqlEntityInformation<S,?> entityInformation, Class<T> targetType, NosqlQuery query)
    Description copied from interface: `NosqlOperations`
    Executes a NosqlQuery (this can be a CriteriaQuery for queries derived from repository method names or a StringQuery for native queries).
    Specified by:
      `find` in interface `NosqlOperations`

  - ### getNosqlClient

    public NoSQLHandle getNosqlClient()