Package com.jk.data.dataaccess.orm
Class JKObjectDataAccessImpl
java.lang.Object
com.jk.data.dataaccess.orm.JKObjectDataAccessImpl
- All Implemented Interfaces:
JKObjectDataAccess
The Class JKObjectDataAccessImpl.
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new JK object data access impl.JKObjectDataAccessImpl
(JKDataSource dataSource) Instantiates a new JK object data access impl.JKObjectDataAccessImpl
(String dataSourcePrefix) Instantiates a new JK object data access impl. -
Method Summary
Modifier and TypeMethodDescription<T> T
clone
(T model) Clone.void
closeTransaction
(boolean commit) Close transaction.<T> T
Delete.<T> T
delete
(T object) Delete.void
Detach.<T> List<T>
executeQuery
(Class<T> clas, String queryString, Object... paramters) Execute query.<T> T
Find.<T> List<T>
findByFieldName
(Class<T> clas, String fieldName, Object value) Find by field name.<T> T
findOneByFieldName
(Class<T> clas, String fieldName, Object fieldValue) Find one by field name.<T> T
findSingleEntity
(Class<T> clas, String queryString, Object... paramters) Find single entity.protected JKDataSource
Gets the data source.protected jakarta.persistence.EntityManager
getEntityManager
(boolean withTrx) Gets the entity manager.<T extends JKEntity>
TgetFirstRecord
(Class<T> clas) Gets the first record.<T> List<T>
Gets the list.<T> List<T>
Gets the list.<T> List<T>
getListAndCache
(Class<T> clas) Gets the list and cache.protected String
getQueryOrder
(Class<? extends JKEntity> clas) Gets the query order.<T> void
handleTimeStamps
(T object) Handle time stamps.<T> T
insert
(T object) Insert.<T> T
insertOrUpdate
(T object) Insert or update.void
setMaxResults
(int maxResults) Sets the max results.void
Start transaction.<T> T
update
(T object) Update.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
-
Constructor Details
-
JKObjectDataAccessImpl
public JKObjectDataAccessImpl()Instantiates a new JK object data access impl. -
JKObjectDataAccessImpl
Instantiates a new JK object data access impl.- Parameters:
dataSourcePrefix
- the data source prefix
-
JKObjectDataAccessImpl
Instantiates a new JK object data access impl.- Parameters:
dataSource
- the data source
-
-
Method Details
-
insert
public <T> T insert(T object) Insert.- Specified by:
insert
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
object
- the object- Returns:
- the t
-
update
public <T> T update(T object) Update.- Specified by:
update
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
object
- the object- Returns:
- the t
-
handleTimeStamps
public <T> void handleTimeStamps(T object) Handle time stamps.- Type Parameters:
T
- the generic type- Parameters:
object
- the object
-
find
Find.- Specified by:
find
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
clas
- the clasid
- the id- Returns:
- the t
-
delete
public <T> T delete(T object) Delete.- Specified by:
delete
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
object
- the object- Returns:
- the t
-
delete
Delete.- Specified by:
delete
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
type
- the typeid
- the id- Returns:
- the t
-
getList
Gets the list.- Specified by:
getList
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
clas
- the clas- Returns:
- the list
-
getListAndCache
Gets the list and cache.- Specified by:
getListAndCache
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
clas
- the clas- Returns:
- the list and cache
-
getList
Gets the list.- Specified by:
getList
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
clas
- the clasparamters
- the paramters- Returns:
- the list
-
executeQuery
Execute query.- Specified by:
executeQuery
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
clas
- the clasqueryString
- the query stringparamters
- the paramters- Returns:
- the list
-
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager(boolean withTrx) Gets the entity manager.- Parameters:
withTrx
- the with trx- Returns:
- the entity manager
-
getDataSource
Gets the data source.- Returns:
- the data source
-
getQueryOrder
protected String getQueryOrder(Class<? extends JKEntity> clas) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException Gets the query order.- Parameters:
clas
- the clas- Returns:
- the query order
- Throws:
NoSuchMethodException
- the no such method exceptionIllegalAccessException
- the illegal access exceptionInvocationTargetException
- the invocation target exception
-
findSingleEntity
Find single entity.- Type Parameters:
T
- the generic type- Parameters:
clas
- the clasqueryString
- the query stringparamters
- the paramters- Returns:
- the t
-
getFirstRecord
Gets the first record.- Type Parameters:
T
- the generic type- Parameters:
clas
- the clas- Returns:
- the first record
-
findByFieldName
Find by field name.- Specified by:
findByFieldName
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
clas
- the clasfieldName
- the field namevalue
- the value- Returns:
- the list
-
insertOrUpdate
public <T> T insertOrUpdate(T object) Insert or update.- Specified by:
insertOrUpdate
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
object
- the object- Returns:
- the t
-
findOneByFieldName
Find one by field name.- Specified by:
findOneByFieldName
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
clas
- the clasfieldName
- the field namefieldValue
- the field value- Returns:
- the t
-
setMaxResults
public void setMaxResults(int maxResults) Sets the max results.- Specified by:
setMaxResults
in interfaceJKObjectDataAccess
- Parameters:
maxResults
- the new max results
-
detach
Detach.- Specified by:
detach
in interfaceJKObjectDataAccess
- Parameters:
model
- the model
-
clone
public <T> T clone(T model) Clone.- Specified by:
clone
in interfaceJKObjectDataAccess
- Type Parameters:
T
- the generic type- Parameters:
model
- the model- Returns:
- the t
-
startTransaction
public void startTransaction()Start transaction.- Specified by:
startTransaction
in interfaceJKObjectDataAccess
-
closeTransaction
public void closeTransaction(boolean commit) Close transaction.- Specified by:
closeTransaction
in interfaceJKObjectDataAccess
- Parameters:
commit
- the commit
-