Class StandardDao<D extends DataDescriptor,T extends Transaction>

java.lang.Object
com.jbstrap.core.dao.StandardDao<D,T>

public abstract class StandardDao<D extends DataDescriptor,T extends Transaction> extends Object
Interface necessary for a custom data query and handling class. In the JBStrap framework, you can make your own DAO (Data Access Object), but it must implement this interface, otherwise the components that use this custom DAO will not function. The custom DAO can be added with the JBStrap.addDataDescriptorType(String, Class) method The added implementation can be also used for the DataDescriptor When implementing the DAO, the following must also be implemented: the data query, data query using the primary ID, saving, deleting, getting the data row count, the closing of the data provider connection and the query of the transaction class.
Since:
4.0
Author:
JBStrap
See Also:
  • Constructor Details

    • StandardDao

      public StandardDao()
  • Method Details

    • find

      public abstract List<Record> find(T transaction, D dataDescriptor, Client client, int startRow, int endRow, Criteria criteria, List<Order> orders) throws FindException, DataAccessException
      Gets the records, according to the specified parameters. The datarow's returns must be mapped in the records.
      Parameters:
      dataDescriptor - The DataDescriptor, that is the basis of the query. It can be decided in the implementation, if it should return with records matching the DataDescriptor or the class
      client - The actual client instance
      startRow - The starting row of the query
      endRow - The ending row of the query
      criteria - The query criteria
      orders - The ordering of the records in the list
      Returns:
      The queried records, according to the specified parameters
      Throws:
      FindException - Occurs if during the query any error was encountered. Every error (except for access right errors) has to be packaged in this type of error.
      DataAccessException - Occurs if the operation has no access rights to the requested data.
      See Also:
    • findById

      public abstract Record findById(T transaction, D dataDescriptor, Client client, Object id) throws FindException, DataAccessException
      Gets the record, that is specified, by its ID. In every case, it can only return with a single record, since an ID can only be assigned to one record.
      Parameters:
      dataDescriptor - The DataDescriptor, that is the basis of the query. It can be decided in the implementation, if it should return with records matching the DataDescriptor or the class
      client - The actual client instance
      id - The primary ID
      Returns:
      The record that has the specified ID
      Throws:
      FindException - Occurs if during the query any error was encountered. Every error (except for access right errors) has to be packaged in this type of error.
      DataAccessException - Occurs if the operation has no access rights to the requested data.
    • getRowCount

      public abstract long getRowCount(T transaction, D dataDescriptor, Client client, Criteria criteria) throws RowCountException, DataAccessException
      Gets a row count, with the specified parameters.
      Parameters:
      dataDescriptor - The DataDescriptor, that is the basis of the query. It can be decided in the implementation, if it
      client - The actual client instance
      criteria - The query criteria
      Returns:
      The row count, by the specified parameters
      Throws:
      RowCountException - Occurs if during the query any error was encountered. Every error (except for access right errors) has to be packaged in this type of error.
      DataAccessException - Occurs if the operation has no access rights to the requested data.
    • save

      public abstract List<Record> save(T transaction, D dataDescriptor, Client client, List<Record> records) throws SaveException, DataAccessException
      Saves the record(s), with the specified parameters.
      Parameters:
      dataDescriptor - The DataDescriptor, where it will be saved. It can be decided in the implementation, if it should take the class or the DataDescriptor as the basis of the save.
      client - The actual client instance
      records - The records that need to be saved
      Returns:
      The saved records, that can change during the save.
      Throws:
      SaveException - Occurs if during the saving any error was encountered. Every error (except for access right errors) has to be packaged in this type of error.
      DataAccessException - Occurs if the operation has no access rights to the requested data.
    • remove

      public abstract List<Record> remove(T transaction, D dataDescriptor, Client client, List<Record> records) throws RemoveException, DataAccessException
      Removes the records, following the specified parameters.
      Parameters:
      dataDescriptor - The DataDescriptor, where the record will be removed from. It can be decided in the implementation, if it should take the class or the DataDescriptor as the basis of the save.
      client - The actual client instance
      records - The records that need to be removed
      Returns:
      The removed records, that can change during the removal.
      Throws:
      RemoveException - Occurs if during the removal any error was encountered. Every error (except for access right errors) has to be packaged in this type of error.
      DataAccessException - Occurs if the operation has no access rights to the requested data.
    • closeConnection

      public abstract void closeConnection()
      Closes the connection with the data handling layer. It is recommended to be called at least when the application is shut down.