Interface JdbcOperations

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <T> java.util.stream.Stream<T> entityStream​(java.sql.ResultSet resultSet, java.lang.Class<T> rootEntity)
      Map a result set to a stream of the given type.
      <T> java.util.stream.Stream<T> entityStream​(java.sql.ResultSet resultSet, java.lang.String prefix, java.lang.Class<T> rootEntity)
      Map a result set to a stream of the given type.
      <R> R execute​(ConnectionCallback<R> callback)
      Execute the given operation with the given callback.
      java.sql.Connection getConnection()
      This method will return the currently active connection for the current transaction or throw an exception if no transaction is present.
      javax.sql.DataSource getDataSource()  
      <R> R prepareStatement​(java.lang.String sql, PreparedStatementCallback<R> callback)
      Execute the given operation with the given callback.
      <E,​D>
      D
      readDTO​(java.lang.String prefix, java.sql.ResultSet resultSet, java.lang.Class<E> rootEntity, java.lang.Class<D> dtoType)
      Read an entity using the given prefix to be passes to result set lookups.
      default <E,​D>
      D
      readDTO​(java.sql.ResultSet resultSet, java.lang.Class<E> rootEntity, java.lang.Class<D> dtoType)
      Read an entity using the given prefix to be passes to result set lookups.
      <E> E readEntity​(java.lang.String prefix, java.sql.ResultSet resultSet, java.lang.Class<E> type)
      Read an entity using the given prefix to be passes to result set lookups.
      default <E> E readEntity​(java.sql.ResultSet resultSet, java.lang.Class<E> type)
      Read an entity using the given prefix to be passes to result set lookups.
    • Method Detail

      • getDataSource

        @NonNull
        javax.sql.DataSource getDataSource()
        Returns:
        The backing data source.
      • getConnection

        @NonNull
        java.sql.Connection getConnection()
        This method will return the currently active connection for the current transaction or throw an exception if no transaction is present.
        Returns:
        The current connection for the active transaction.
        Throws:
        NoTransactionException - if no transaction is present.
      • execute

        @NonNull
        <R> R execute​(@NonNull
                      ConnectionCallback<R> callback)
        Execute the given operation with the given callback.
        Type Parameters:
        R - The result type
        Parameters:
        callback - The callback
        Returns:
        The result
      • prepareStatement

        @NonNull
        <R> R prepareStatement​(@NonNull
                               java.lang.String sql,
                               @NonNull
                               PreparedStatementCallback<R> callback)
        Execute the given operation with the given callback.
        Type Parameters:
        R - The result type
        Parameters:
        sql - The SQL
        callback - The callback
        Returns:
        The result
      • entityStream

        @NonNull
        <T> java.util.stream.Stream<T> entityStream​(@NonNull
                                                    java.sql.ResultSet resultSet,
                                                    @Nullable
                                                    java.lang.String prefix,
                                                    @NonNull
                                                    java.lang.Class<T> rootEntity)
        Map a result set to a stream of the given type.
        Type Parameters:
        T - The generic type
        Parameters:
        resultSet - The result set
        prefix - The prefix to use for each column name that is mapped
        rootEntity - The entity type
        Returns:
        The stream
        Throws:
        DataAccessException - If an error occurs reading the result
      • entityStream

        @NonNull
        <T> java.util.stream.Stream<T> entityStream​(@NonNull
                                                    java.sql.ResultSet resultSet,
                                                    @NonNull
                                                    java.lang.Class<T> rootEntity)
        Map a result set to a stream of the given type.
        Type Parameters:
        T - The generic type
        Parameters:
        resultSet - The result set
        rootEntity - The entity type
        Returns:
        The stream
        Throws:
        DataAccessException - If an error occurs reading the result
      • readEntity

        @NonNull
        <E> E readEntity​(@NonNull
                         java.lang.String prefix,
                         @NonNull
                         java.sql.ResultSet resultSet,
                         @NonNull
                         java.lang.Class<E> type)
                  throws DataAccessException
        Read an entity using the given prefix to be passes to result set lookups.
        Type Parameters:
        E - The entity generic type
        Parameters:
        prefix - The prefix
        resultSet - The result set
        type - The entity type
        Returns:
        The entity result
        Throws:
        DataAccessException - if it is not possible read the result from the result set.
      • readEntity

        @NonNull
        default <E> E readEntity​(@NonNull
                                 java.sql.ResultSet resultSet,
                                 @NonNull
                                 java.lang.Class<E> type)
                          throws DataAccessException
        Read an entity using the given prefix to be passes to result set lookups.
        Type Parameters:
        E - The entity generic type
        Parameters:
        resultSet - The result set
        type - The entity type
        Returns:
        The entity result
        Throws:
        DataAccessException - if it is not possible read the result from the result set.
      • readDTO

        @NonNull
        <E,​D> D readDTO​(@NonNull
                              java.lang.String prefix,
                              @NonNull
                              java.sql.ResultSet resultSet,
                              @NonNull
                              java.lang.Class<E> rootEntity,
                              @NonNull
                              java.lang.Class<D> dtoType)
                       throws DataAccessException
        Read an entity using the given prefix to be passes to result set lookups.
        Type Parameters:
        E - The entity generic type
        D - The DTO generic type
        Parameters:
        prefix - The prefix
        resultSet - The result set
        rootEntity - The entity type
        dtoType - The DTO type. Must be annotated with Introspected
        Returns:
        The entity result
        Throws:
        DataAccessException - if it is not possible read the result from the result set.
      • readDTO

        @NonNull
        default <E,​D> D readDTO​(@NonNull
                                      java.sql.ResultSet resultSet,
                                      @NonNull
                                      java.lang.Class<E> rootEntity,
                                      @NonNull
                                      java.lang.Class<D> dtoType)
                               throws DataAccessException
        Read an entity using the given prefix to be passes to result set lookups.
        Type Parameters:
        E - The entity generic type
        D - The DTO generic type
        Parameters:
        resultSet - The result set
        rootEntity - The entity type
        dtoType - The DTO type. Must be annotated with Introspected
        Returns:
        The entity result
        Throws:
        DataAccessException - if it is not possible read the result from the result set.