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
-
Field Summary
Fields inherited from class com.oracle.nosql.spring.data.core.NosqlTemplateBase
applicationContext, JSON_COLUMN, LOG, mappingNosqlConverter, nosqlClient, nosqlDbFactory, psCache
-
Constructor Summary
ConstructorDescriptionNosqlTemplate
(NosqlDbFactory nosqlDbFactory, MappingNosqlConverter mappingNosqlConverter) -
Method Summary
Modifier and TypeMethodDescriptionlong
count
(NosqlEntityInformation<?, ?> entityInformation) Returns a count of all the entries in the given table.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>
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 Returns the entity for the given table.Returns the assigned mapping converter.<T> NosqlEntityInformation<T,
?> getNosqlEntityInformation
(Class<T> domainClass) 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.runQuery
(NosqlEntityInformation<?, ?> entityInformation, String query) runQueryJavaParams
(NosqlEntityInformation<?, ?> entityInformation, String query, Map<String, Object> javaParams) javaParams is a Map of param_name to Java objectsrunQueryNosqlParams
(NosqlEntityInformation<?, ?> entityInformation, String query, Map<String, FieldValue> nosqlParams) nosqlParams is a Map of param_name to FieldValuevoid
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
doCreateTableIfNotExists, doDelete, doExecuteMapValueQuery, doGet, doPut, doRunQueryNosqlParams, doTableRequest, doUpdate
-
Constructor Details
-
NosqlTemplate
-
-
Method Details
-
create
- Throws:
ClassNotFoundException
-
create
- Throws:
ClassNotFoundException
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Overrides:
setApplicationContext
in classNosqlTemplateBase
- Throws:
org.springframework.beans.BeansException
-
getTableName
Description copied from interface:NosqlOperations
Returns the tableName for the given entity class.- Specified by:
getTableName
in interfaceNosqlOperations
-
createTableIfNotExists
Description copied from interface:NosqlOperations
Creates a table for the given entity type if it doesn't exist.- Specified by:
createTableIfNotExists
in interfaceNosqlOperations
-
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 interfaceNosqlOperations
-
insert
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 interfaceNosqlOperations
-
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 interfaceNosqlOperations
-
update
Description copied from interface:NosqlOperations
Updates the entity into the given table. Entity must contain a valid id value.- Specified by:
update
in interfaceNosqlOperations
-
deleteAll
Description copied from interface:NosqlOperations
Deletes all entries from the given table.- Specified by:
deleteAll
in interfaceNosqlOperations
-
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 interfaceNosqlOperations
-
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 usesNoSQLHandle.writeMultiple(WriteMultipleRequest)
. -
dropTableIfExists
Drops table and returns true if result indicates table state changed to DROPPED or DROPPING. UsesNosqlDbFactory.getTableReqTimeout()
andNosqlDbFactory.getTableReqPollInterval()
to check the result.- Specified by:
dropTableIfExists
in interfaceNosqlOperations
-
getConverter
Description copied from interface:NosqlOperations
Returns the assigned mapping converter.- Specified by:
getConverter
in interfaceNosqlOperations
-
getNosqlEntityInformation
-
findById
Description copied from interface:NosqlOperations
Returns the entity for the given table.- Specified by:
findById
in interfaceNosqlOperations
-
findById
Description copied from interface:NosqlOperations
Returns the entity for the given id in the given table.- Specified by:
findById
in interfaceNosqlOperations
-
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 interfaceNosqlOperations
-
deleteById
Description copied from interface:NosqlOperations
Deletes the entity with the id from the given table.- Specified by:
deleteById
in interfaceNosqlOperations
-
findAll
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 interfaceNosqlOperations
-
findAll
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 interfaceNosqlOperations
-
count
Description copied from interface:NosqlOperations
Returns a count of all the entries in the given table.- Specified by:
count
in interfaceNosqlOperations
-
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 interfaceNosqlOperations
-
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 interfaceNosqlOperations
-
runTableRequest
-
runQuery
-
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 interfaceNosqlOperations
-
delete
- Specified by:
delete
in interfaceNosqlOperations
-
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 interfaceNosqlOperations
-
getNosqlClient
-