Package com.jk.data.vendors.mongo
Class JKMongoDataAccess
java.lang.Object
com.jk.data.vendors.mongo.JKMongoDataAccess
- All Implemented Interfaces:
JKNoSqlDataAccess
,JKObjectDataAccess
This class provides data access operations for MongoDB using the
{JKNoSqlDataAccess} interface.
It allows insertion, retrieval, deletion, and update of objects in a MongoDB collection.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
clone
(T model) This method is yet to be implemented (TBI).void
closeTransaction
(boolean commit) This method is yet to be implemented (TBI).<T> T
This method deletes an object from the data storage using its identifier (ID).<T> T
delete
(T obj) This method deletes an object from the data storage.<T> void
detach
(T model) This method is yet to be implemented (TBI).<T> List<T>
executeQuery
(Class<T> clas, String queryString, Object... paramters) This method is yet to be implemented (TBI).<T> T
This method finds an object from the data storage using its identifier (ID).<T> List<T>
findByFieldName
(Class<T> clas, String fieldName, Object value) This method retrieves a list of objects of the specified class based on a specific field's value.<T> T
findOneByFieldName
(Class<T> clas, String fieldName, Object fieldValue) This method retrieves a single object of the specified class from the data storage based on a field name and its value.protected <T> com.mongodb.client.MongoCollection<T>
getCollection
(Class<?> clas) This method retrieves a MongoDB collection for the specified class.protected String
getDocumentName
(Class<?> clas) This method retrieves the document name for the specified class.<T> List<T>
This method retrieves a list of objects of the provided class type from the data storage.<T> List<T>
This method retrieves a list of objects of the specified class based on the provided parameters.<T> List<T>
getListAndCache
(Class<T> clas) This method is yet to be implemented (TBI).<T> T
insert
(T obj) This method inserts the provided object into the data storage.<T> T
insertOrUpdate
(T object) This method is yet to be implemented (TBI).void
setMaxResults
(int maxResults) This method is yet to be implemented (TBI).void
This method is yet to be implemented (TBI).<T> T
This method updates a document in the MongoDB collection with the specified ID using the provided object.<T> T
update
(T obj) This method updates an existing object in the data storage.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jk.data.dataaccess.orm.JKObjectDataAccess
executeSingleOutputQuery, getTenantId
-
Constructor Details
-
JKMongoDataAccess
public JKMongoDataAccess()
-
-
Method Details
-
getCollection
This method retrieves a MongoDB collection for the specified class.- Type Parameters:
T
- Specifies the type of objects in the collection.- Parameters:
clas
- Specifies the class for which to retrieve the collection.- Returns:
- the
MongoCollection
for the specified class.
-
getDocumentName
This method retrieves the document name for the specified class.- Parameters:
clas
- Specifies the class for which to determine the document name.- Returns:
- the document name, which is the lower-case simple name of the class.
-
insert
public <T> T insert(T obj) This method inserts the provided object into the data storage.- Specified by:
insert
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object.- Parameters:
obj
- Specifies the object to be inserted- Returns:
- the inserted object.
-
getList
This method retrieves a list of objects of the provided class type from the data storage.- Specified by:
getList
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object.- Parameters:
clas
- Specifies the class type of the objects.- Returns:
- a list of objects from data storage that are of the provided class type.
-
findByFieldName
This method retrieves a list of objects of the specified class based on a specific field's value.- Specified by:
findByFieldName
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of objects to retrieve.- Parameters:
clas
- Specifies the class of objects to retrieve.fieldName
- Specifies the name of the field to search by.value
- Specifies the value to search for within the specified field.- Returns:
- a list of objects matching the specified class and field value criteria.
-
getList
This method retrieves a list of objects of the specified class based on the provided parameters.- Specified by:
getList
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of objects to retrieve.- Parameters:
clas
- Specifies the class of objects to retrieve.filter
- Specifies a map of parameters or criteria for filtering the objects.- Returns:
- a list of objects matching the specified class and criteria.
-
find
This method finds an object from the data storage using its identifier (ID).- Specified by:
find
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object.- Parameters:
clas
- Specifies the class type of the object.id
- Specifies the identifier (ID) of the object to find.- Returns:
- the found object, or null if not found.
-
delete
This method deletes an object from the data storage using its identifier (ID).- Specified by:
delete
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object.- Parameters:
clas
- Specifies the class type of the object.id
- Specifies the object identifier (ID)- Returns:
- the deleted object.
-
delete
public <T> T delete(T obj) This method deletes an object from the data storage.- Specified by:
delete
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object.- Parameters:
obj
- Specifies the object to delete.- Returns:
- the deleted object.
-
update
public <T> T update(T obj) This method updates an existing object in the data storage.- Specified by:
update
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object.- Parameters:
obj
- Specifies the object to update.- Returns:
- the updated object.
-
update
This method updates a document in the MongoDB collection with the specified ID using the provided object.- Type Parameters:
T
- Specifies the type of the object.- Parameters:
id
- Specifies the ID of the document to update.obj
- Specifies the object containing the updated data to be applied to the document.- Returns:
- the updated object after the update operation.
-
findOneByFieldName
This method retrieves a single object of the specified class from the data storage based on a field name and its value.- Specified by:
findOneByFieldName
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of object to retrieve.- Parameters:
clas
- Specifies the class of the object to retrieve.fieldName
- Specifies the name of the field to use as a filter.fieldValue
- Specifies the value to match in the specified field.- Returns:
- the retrieved object, or null if no matching object is found.
-
executeQuery
This method is yet to be implemented (TBI).- Specified by:
executeQuery
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of objects to retrieve.- Parameters:
clas
- Specifies the class of objects to retrieve.queryString
- Specifies the query string to execute.paramters
- Specifies the optional parameters to bind to the query.- Returns:
- null.
-
insertOrUpdate
public <T> T insertOrUpdate(T object) This method is yet to be implemented (TBI).- Specified by:
insertOrUpdate
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object to insert or update.- Parameters:
object
- Specifies the object to insert or update in the data storage.- Returns:
- null.
-
setMaxResults
public void setMaxResults(int maxResults) This method is yet to be implemented (TBI).- Specified by:
setMaxResults
in interfaceJKObjectDataAccess
- Parameters:
maxResults
- Specifies the new max results shown from any executed query.
-
detach
public <T> void detach(T model) This method is yet to be implemented (TBI).- Specified by:
detach
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object to detach.- Parameters:
model
- Specifies the object to detach from the persistence context.
-
clone
public <T> T clone(T model) This method is yet to be implemented (TBI).- Specified by:
clone
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object to clone.- Parameters:
model
- Specifies the object to create a detached copy of.- Returns:
- null.
-
startTransaction
public void startTransaction()This method is yet to be implemented (TBI).- Specified by:
startTransaction
in interfaceJKObjectDataAccess
-
closeTransaction
public void closeTransaction(boolean commit) This method is yet to be implemented (TBI).- Specified by:
closeTransaction
in interfaceJKObjectDataAccess
- Parameters:
commit
- Indicates whether to commit (true) the transaction or to roll it back (false).
-
getListAndCache
This method is yet to be implemented (TBI).- Specified by:
getListAndCache
in interfaceJKObjectDataAccess
- Type Parameters:
T
- Specifies the type of the object.- Parameters:
clas
- Specifies the class type of the objects to retrieve.- Returns:
- null.
-