Class JKObjectDataAccessImpl

java.lang.Object
com.jk.data.dataaccess.orm.JKObjectDataAccessImpl
All Implemented Interfaces:
JKObjectDataAccess

public class JKObjectDataAccessImpl extends Object implements JKObjectDataAccess
The Class JKObjectDataAccessImpl.
  • Constructor Details

    • JKObjectDataAccessImpl

      public JKObjectDataAccessImpl()
      Instantiates a new JK object data access impl.
    • JKObjectDataAccessImpl

      public JKObjectDataAccessImpl(String dataSourcePrefix)
      Instantiates a new JK object data access impl.
      Parameters:
      dataSourcePrefix - the data source prefix
    • JKObjectDataAccessImpl

      public JKObjectDataAccessImpl(JKDataSource dataSource)
      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 interface JKObjectDataAccess
      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 interface JKObjectDataAccess
      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

      public <T> T find(Class<T> clas, Object id)
      Find.
      Specified by:
      find in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      id - the id
      Returns:
      the t
    • delete

      public <T> T delete(T object)
      Delete.
      Specified by:
      delete in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      object - the object
      Returns:
      the t
    • delete

      public <T> T delete(Class<T> type, Object id)
      Delete.
      Specified by:
      delete in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      type - the type
      id - the id
      Returns:
      the t
    • getList

      public <T> List<T> getList(Class<T> clas)
      Gets the list.
      Specified by:
      getList in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      Returns:
      the list
    • getListAndCache

      public <T> List<T> getListAndCache(Class<T> clas)
      Gets the list and cache.
      Specified by:
      getListAndCache in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      Returns:
      the list and cache
    • getList

      public <T> List<T> getList(Class<T> clas, Map<String,Object> paramters)
      Gets the list.
      Specified by:
      getList in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      paramters - the paramters
      Returns:
      the list
    • executeQuery

      public <T> List<T> executeQuery(Class<T> clas, String queryString, Object... paramters)
      Execute query.
      Specified by:
      executeQuery in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      queryString - the query string
      paramters - 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

      protected JKDataSource 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 exception
      IllegalAccessException - the illegal access exception
      InvocationTargetException - the invocation target exception
    • findSingleEntity

      public <T> T findSingleEntity(Class<T> clas, String queryString, Object... paramters)
      Find single entity.
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      queryString - the query string
      paramters - the paramters
      Returns:
      the t
    • getFirstRecord

      public <T extends JKEntity> T getFirstRecord(Class<T> clas)
      Gets the first record.
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      Returns:
      the first record
    • findByFieldName

      public <T> List<T> findByFieldName(Class<T> clas, String fieldName, Object value)
      Find by field name.
      Specified by:
      findByFieldName in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      fieldName - the field name
      value - the value
      Returns:
      the list
    • insertOrUpdate

      public <T> T insertOrUpdate(T object)
      Insert or update.
      Specified by:
      insertOrUpdate in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      object - the object
      Returns:
      the t
    • findOneByFieldName

      public <T> T findOneByFieldName(Class<T> clas, String fieldName, Object fieldValue)
      Find one by field name.
      Specified by:
      findOneByFieldName in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      fieldName - the field name
      fieldValue - the field value
      Returns:
      the t
    • setMaxResults

      public void setMaxResults(int maxResults)
      Sets the max results.
      Specified by:
      setMaxResults in interface JKObjectDataAccess
      Parameters:
      maxResults - the new max results
    • detach

      public void detach(Object model)
      Detach.
      Specified by:
      detach in interface JKObjectDataAccess
      Parameters:
      model - the model
    • clone

      public <T> T clone(T model)
      Clone.
      Specified by:
      clone in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      model - the model
      Returns:
      the t
    • startTransaction

      public void startTransaction()
      Start transaction.
      Specified by:
      startTransaction in interface JKObjectDataAccess
    • closeTransaction

      public void closeTransaction(boolean commit)
      Close transaction.
      Specified by:
      closeTransaction in interface JKObjectDataAccess
      Parameters:
      commit - the commit