Class PreparedStatementSpyConnectionProvider

  • All Implemented Interfaces:
    Serializable, org.hibernate.engine.jdbc.connections.spi.ConnectionProvider, org.hibernate.service.Service, org.hibernate.service.spi.Configurable, org.hibernate.service.spi.ServiceRegistryAwareService, org.hibernate.service.spi.Stoppable, org.hibernate.service.spi.Wrapped

    public class PreparedStatementSpyConnectionProvider
    extends ConnectionProviderDelegate
    This ConnectionProvider extends any other ConnectionProvider that would be used by default taken the current configuration properties, and it intercept the underlying PreparedStatement method calls.
    See Also:
    Serialized Form
    • Constructor Detail

      • PreparedStatementSpyConnectionProvider

        public PreparedStatementSpyConnectionProvider()
      • PreparedStatementSpyConnectionProvider

        public PreparedStatementSpyConnectionProvider​(boolean forceSupportsAggressiveRelease)
    • Method Detail

      • stop

        public void stop()
        Specified by:
        stop in interface org.hibernate.service.spi.Stoppable
        Overrides:
        stop in class ConnectionProviderDelegate
      • clear

        public void clear()
        Clears the recorded PreparedStatements and reset the associated Mocks.
      • getPreparedStatement

        public PreparedStatement getPreparedStatement​(String sql)
        Get one and only one PreparedStatement associated to the given SQL statement.
        Parameters:
        sql - SQL statement.
        Returns:
        matching PreparedStatement.
        Throws:
        IllegalArgumentException - If there is no matching PreparedStatement or multiple instances, an exception is being thrown.
      • getPreparedStatements

        public List<PreparedStatement> getPreparedStatements​(String sql)
        Get the PreparedStatements that are associated to the following SQL statement.
        Parameters:
        sql - SQL statement.
        Returns:
        list of recorded PreparedStatements matching the SQL statement.
      • getPreparedStatements

        public List<PreparedStatement> getPreparedStatements()
        Get the PreparedStatements that were executed since the last clear operation.
        Returns:
        list of recorded PreparedStatements.
      • getPreparedStatementsAndSql

        public Map<PreparedStatement,​String> getPreparedStatementsAndSql()
        Returns:
        the PreparedStatements that were executed since the last clear operation, along with each statement's corresponding SQL.
      • getPreparedSQLStatements

        public List<String> getPreparedSQLStatements()
        Get the PreparedStatements SQL statements.
        Returns:
        list of recorded PreparedStatements SQL statements.
      • getExecuteStatements

        public List<String> getExecuteStatements()
        Get the SQL statements that were executed since the last clear operation.
        Returns:
        list of recorded update statements.
      • getExecuteUpdateStatements

        public List<String> getExecuteUpdateStatements()
        Get the SQL update statements that were executed since the last clear operation.
        Returns:
        list of recorded update statements.
      • getAcquiredConnections

        public List<Connection> getAcquiredConnections()
        Get a list of current acquired Connections.
        Returns:
        list of current acquired Connections
      • getReleasedConnections

        public List<Connection> getReleasedConnections()
        Get a list of current released Connections.
        Returns:
        list of current released Connections