Class AEntityAPI<T extends ITransferableEntity>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Class<T> entityClass  
    • Constructor Summary

      Constructors 
      Constructor Description
      AEntityAPI()
      Instantiates a new entity API.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      T create​(UserContext uc, T entity)
      Method for creating a entity.
      T[] create​(UserContext uc, T[] entities)
      Method for creating multiple entities.
      Boolean delete​(UserContext uc, T entity)
      Method for deleting a entity.
      Boolean delete​(UserContext uc, T[] entities)
      Method for deleting multiple entities.
      Boolean deleteAllBy​(UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
      Method for deleting entities using a QueryCriteriaManagers.
      Boolean deleteById​(UserContext uc, Integer id)
      Method for deleting a entity by its ID.
      Boolean deleteById​(UserContext uc, Long id)
      Method for deleting a entity by its ID.
      List<T> getAll​(UserContext uc)
      Method for determining all available entities in the user context.
      List<T> getAllBy​(UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
      Method for determining all entities using a QueryCriteriaManagers.
      <C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager>
      List<Map<String,​Serializable>>
      getAttributes​(UserContext uc, C cm)
      This method allows for the selection of certain attributes of entities instead of reading the entire entity
      <R,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager>
      List<R>
      getAttributes​(UserContext uc, C cm, Class<R> resultClass)
      This method allows for the selection of certain attributes of entities instead of reading the entire entity.
      T getBy​(UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
      Method for determining an entity using a QueryCriteriaManagers.
      T getById​(UserContext uc, Integer id)
      Method for retrieving an entity by its ID.
      T getById​(UserContext uc, Long id)
      Method for retrieving an entity by its ID.
      <R extends ITransferableEntity>
      Set<R>
      getEntityRefs​(UserContext uc, T entity)
      Returns a set of entities that reference the given entity and depend on it.
      PagedResult<T> getPagedResult​(UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)  
      <C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager>
      javax.persistence.Tuple
      getSingleAttributes​(UserContext uc, C cm)
      <R,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager>
      R
      getSingleAttributes​(UserContext uc, C cm, Class<R> resultClass)
      This method allows for the selection of certain attributes of an entity instead of reading the entire entity
      <C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding>
      int
      resultTotalCount​(UserContext uc, C cm)
      Method for determining the number of hits when searching for entities using a IFilterableCriteriaManager.
      int resultTotalCount​(UserContext uc, de.xima.cmn.criteria.QueryCriteriaManager qcm)
      Method for determining the number of hits when searching for entities using a QueryCriteriaManager.
      T update​(UserContext uc, T entity)
      Method for updating a entity.
      T[] update​(UserContext uc, T[] entities)
      Method for updating multiple entities.
    • Constructor Detail

      • AEntityAPI

        public AEntityAPI()
        Instantiates a new entity API.
    • Method Detail

      • create

        public T create​(UserContext uc,
                        T entity)
        Method for creating a entity.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        entity - the entity to be created.
        Returns:
        The created entity.
      • create

        public T[] create​(UserContext uc,
                          T[] entities)
        Method for creating multiple entities.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        entities - a Array of the entities to be created.
        Returns:
        Array of the created entities.
      • update

        public T update​(UserContext uc,
                        T entity)
        Method for updating a entity.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        entity - the entity to be update.
        Returns:
        The updated entity.
      • delete

        public Boolean delete​(UserContext uc,
                              T entity)
        Method for deleting a entity.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        entity - the entity to be deleted.
        Returns:
        Boolean if the deletion was successful.
      • delete

        public Boolean delete​(UserContext uc,
                              T[] entities)
        Method for deleting multiple entities.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        entities - a Array of the entities to be deleted.
        Returns:
        Boolean if the deletion was successful.
      • update

        public T[] update​(UserContext uc,
                          T[] entities)
        Method for updating multiple entities.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        entities - a Array of the entities to be updated.
        Returns:
        Array with the updated entities.
      • getAll

        public List<T> getAll​(UserContext uc)
        Method for determining all available entities in the user context.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        Returns:
        List of the available entities.
      • getById

        public T getById​(UserContext uc,
                         Long id)
        Method for retrieving an entity by its ID.
        Parameters:
        uc - The user context to use when accessing the database.
        id - The ID of the entity.
        Returns:
        The entity with the given ID, or null when no such entity exist.
      • getById

        public T getById​(UserContext uc,
                         Integer id)
        Method for retrieving an entity by its ID.
        Parameters:
        uc - The user context to use when accessing the database.
        id - The ID of an entity.
        Returns:
        The entity with the given ID, or null when no such entity exist.
      • deleteById

        public Boolean deleteById​(UserContext uc,
                                  Long id)
        Method for deleting a entity by its ID.
        Parameters:
        uc - The user context to use when accessing the database.
        id - The ID of an entity to delete.
        Returns:
        true when the entity was deleted, false otherwise when no entity with the given ID exists.
      • deleteById

        public Boolean deleteById​(UserContext uc,
                                  Integer id)
        Method for deleting a entity by its ID.
        Parameters:
        uc - The user context to use when accessing the database.
        id - The ID of an entity to delete.
        Returns:
        true when the entity was deleted, false otherwise when no entity with the given ID exists.
      • resultTotalCount

        public int resultTotalCount​(UserContext uc,
                                    de.xima.cmn.criteria.QueryCriteriaManager qcm)
        Method for determining the number of hits when searching for entities using a QueryCriteriaManager.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        qcm - the QueryCriteriaManager which should be used for the search.
        Returns:
        Integer the found number of entities
      • resultTotalCount

        public <C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> int resultTotalCount​(UserContext uc,
                                                                                                                                                                 C cm)
        Method for determining the number of hits when searching for entities using a IFilterableCriteriaManager.
        Type Parameters:
        C - Type of the criteria manager to use for the search.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        cm - the IFilterableCriteriaManager which should be used for the search.
        Returns:
        Integer the found number of entities
      • getBy

        public T getBy​(UserContext uc,
                       de.xima.cmn.criteria.QueryCriteriaManager qcm)
        Method for determining an entity using a QueryCriteriaManagers.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        qcm - the QueryCriteriaManager which should be used for the search.
        Returns:
        The found entity.
      • getAllBy

        public List<T> getAllBy​(UserContext uc,
                                de.xima.cmn.criteria.QueryCriteriaManager qcm)
        Method for determining all entities using a QueryCriteriaManagers.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        qcm - the QueryCriteriaManager which should be used for the search.
        Returns:
        List the found entities.
      • getPagedResult

        public PagedResult<T> getPagedResult​(UserContext uc,
                                             de.xima.cmn.criteria.QueryCriteriaManager qcm)
      • getAttributes

        public <C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> List<Map<String,​Serializable>> getAttributes​(UserContext uc,
                                                                                                                                                                                                                                                                                                                                                                                  C cm)
                                                                                                                                                                                                                                                                                                                                                                           throws NotSerializableException
        This method allows for the selection of certain attributes of entities instead of reading the entire entity
        Type Parameters:
        C - type of the criteria manager
        Parameters:
        uc - UserContext which will be used for the transaction
        cm - the criteria manager used for filtering, sorting, selecting, paging
        Returns:
        List of Maps that contain the values of the selected attributes
        Throws:
        NotSerializableException - when attributes are not serializable
      • getAttributes

        public <R,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> List<R> getAttributes​(UserContext uc,
                                                                                                                                                                                                                                                                                                                                                             C cm,
                                                                                                                                                                                                                                                                                                                                                             Class<R> resultClass)
        This method allows for the selection of certain attributes of entities instead of reading the entire entity. That result will be returned in form of a list of objects. These objects are defined by the given result class
        Type Parameters:
        R - type of result class
        C - type of the criteria manager
        Parameters:
        uc - UserContext which will be used for the transaction
        cm - the criteria manager used for filtering, sorting, selecting, paging
        resultClass - Type of the POJO used to wrap the resulting data.
        Returns:
        List of objects that contain the values of the selected attributes
      • getSingleAttributes

        @Deprecated
        public <C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> javax.persistence.Tuple getSingleAttributes​(UserContext uc,
                                                                                                                                                                                                                                                                                                                                                                           C cm)
        This method allows for the selection of certain attributes of an entity instead of reading the entire entity
        Type Parameters:
        C - type of the criteria manager
        Parameters:
        uc - UserContext which will be used
        cm - The query manager that contains lists for filtering, sorting and selecting. These lists, if available, are included in the SQL query. This value can be null. The lists contained in the query manager can also be null or empty.
        Returns:
        Tuple that contains the values of the selected attributes
        Since:
        6.6.0
      • getSingleAttributes

        public <R,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> R getSingleAttributes​(UserContext uc,
                                                                                                                                                                                                                                                                                                                                                             C cm,
                                                                                                                                                                                                                                                                                                                                                             Class<R> resultClass)
        This method allows for the selection of certain attributes of an entity instead of reading the entire entity
        Type Parameters:
        R - Type of the POJO for wrapping the resulting data.
        C - type of the criteria manager
        Parameters:
        uc - User context for accessing the database.
        cm - The query manager that contains lists for filtering, sorting and selecting. These lists, if available, are included in the SQL query. This value can be null. The lists contained in the query manager can also be null or empty.
        resultClass - Class of the object, in which the result value will be placed
        Returns:
        A list of rows with the selected attributes, wrapped with the given POJO class.
        Since:
        6.6.0
      • getEntityRefs

        public <R extends ITransferableEntitySet<R> getEntityRefs​(UserContext uc,
                                                                    T entity)
        Returns a set of entities that reference the given entity and depend on it. An entity can usually not be deleted if it is still being referenced by and depended on by other entities.
        Type Parameters:
        R - type of the entities that are referencing the given entity.
        Parameters:
        uc - user context for database transactions.
        entity - being referenced.
        Returns:
        a set of entities that reference the given entity.
        Throws:
        ClassCastException - if a referencing entity is not of type R.
        Since:
        8.0.0
      • deleteAllBy

        public Boolean deleteAllBy​(UserContext uc,
                                   de.xima.cmn.criteria.QueryCriteriaManager qcm)
        Method for deleting entities using a QueryCriteriaManagers.
        Parameters:
        uc - UserContext the user context in which the action is to be performed.
        qcm - the QueryCriteriaManager which should be used when deleting.
        Returns:
        Boolean if the deletion was successful.