mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 23:09:13 +00:00
use default noop methods on SessionEventListener
- also, mark it @Incubating, as was already documented - improve the jdoc for SessionEventListener and StatementInspector
This commit is contained in:
parent
be2999d054
commit
58e9c2a0fc
@ -9,44 +9,55 @@
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE : Consider this an incubating API, likely to change as wider usage indicates changes that need to be made
|
* Implemented by custom listeners that respond to low-level events
|
||||||
|
* involving interactions between the {@link Session} and the database
|
||||||
|
* or second-level cache.
|
||||||
|
* <p>
|
||||||
|
* A {@code SessionEventListener} class applying to all newly-created
|
||||||
|
* sessions may be registered using the configuration property
|
||||||
|
* {@value org.hibernate.cfg.AvailableSettings#AUTO_SESSION_EVENTS_LISTENER}.
|
||||||
|
* A new instance of the class will be created for each new session.
|
||||||
|
* <p>
|
||||||
|
* <em>This an incubating API, subject to change.</em>
|
||||||
*
|
*
|
||||||
* @see org.hibernate.cfg.AvailableSettings#AUTO_SESSION_EVENTS_LISTENER
|
* @see org.hibernate.cfg.AvailableSettings#AUTO_SESSION_EVENTS_LISTENER
|
||||||
|
* @see SessionBuilder#eventListeners(SessionEventListener...)
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@Incubating
|
||||||
public interface SessionEventListener extends Serializable {
|
public interface SessionEventListener extends Serializable {
|
||||||
void transactionCompletion(boolean successful);
|
default void transactionCompletion(boolean successful) {}
|
||||||
|
|
||||||
void jdbcConnectionAcquisitionStart();
|
default void jdbcConnectionAcquisitionStart() {}
|
||||||
void jdbcConnectionAcquisitionEnd();
|
default void jdbcConnectionAcquisitionEnd() {}
|
||||||
|
|
||||||
void jdbcConnectionReleaseStart();
|
default void jdbcConnectionReleaseStart() {}
|
||||||
void jdbcConnectionReleaseEnd();
|
default void jdbcConnectionReleaseEnd() {}
|
||||||
|
|
||||||
void jdbcPrepareStatementStart();
|
default void jdbcPrepareStatementStart() {}
|
||||||
void jdbcPrepareStatementEnd();
|
default void jdbcPrepareStatementEnd() {}
|
||||||
|
|
||||||
void jdbcExecuteStatementStart();
|
default void jdbcExecuteStatementStart() {}
|
||||||
void jdbcExecuteStatementEnd();
|
default void jdbcExecuteStatementEnd() {}
|
||||||
|
|
||||||
void jdbcExecuteBatchStart();
|
default void jdbcExecuteBatchStart() {}
|
||||||
void jdbcExecuteBatchEnd();
|
default void jdbcExecuteBatchEnd() {}
|
||||||
|
|
||||||
void cachePutStart();
|
default void cachePutStart() {}
|
||||||
void cachePutEnd();
|
default void cachePutEnd() {}
|
||||||
|
|
||||||
void cacheGetStart();
|
default void cacheGetStart() {}
|
||||||
void cacheGetEnd(boolean hit);
|
default void cacheGetEnd(boolean hit) {}
|
||||||
|
|
||||||
void flushStart();
|
default void flushStart() {}
|
||||||
void flushEnd(int numberOfEntities, int numberOfCollections);
|
default void flushEnd(int numberOfEntities, int numberOfCollections) {}
|
||||||
|
|
||||||
void partialFlushStart();
|
default void partialFlushStart() {}
|
||||||
void partialFlushEnd(int numberOfEntities, int numberOfCollections);
|
default void partialFlushEnd(int numberOfEntities, int numberOfCollections) {}
|
||||||
|
|
||||||
void dirtyCalculationStart();
|
default void dirtyCalculationStart() {}
|
||||||
void dirtyCalculationEnd(boolean dirty);
|
default void dirtyCalculationEnd(boolean dirty) {}
|
||||||
|
|
||||||
void end();
|
default void end() {}
|
||||||
}
|
}
|
||||||
|
@ -9,24 +9,35 @@
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contract to allow inspection (and swapping) of SQL to be prepared.
|
* Implementors may inspect and even process each SQL command issued
|
||||||
* <p>
|
* by a session, before a {@linkplain java.sql.PreparedStatement JDBC
|
||||||
|
* statement} is prepared. A {@code StatementInspector} may be either:
|
||||||
|
* <ul>
|
||||||
|
* <li>shared by all sessions created by a given session factory, in
|
||||||
|
* which case it must be thread-safe, or
|
||||||
|
* <li>a dedicated instance {@linkplain
|
||||||
|
* org.hibernate.SessionBuilder#statementInspector registered}
|
||||||
|
* for a certain session.
|
||||||
|
* </ul>
|
||||||
* An implementation may be specified via the configuration property
|
* An implementation may be specified via the configuration property
|
||||||
* {@value org.hibernate.cfg.AvailableSettings#STATEMENT_INSPECTOR}.
|
* {@value org.hibernate.cfg.AvailableSettings#STATEMENT_INSPECTOR}.
|
||||||
|
* An implementation registered this way is shared between sessions.
|
||||||
*
|
*
|
||||||
|
* @see org.hibernate.cfg.AvailableSettings#STATEMENT_INSPECTOR
|
||||||
* @see org.hibernate.boot.SessionFactoryBuilder#applyStatementInspector(StatementInspector)
|
* @see org.hibernate.boot.SessionFactoryBuilder#applyStatementInspector(StatementInspector)
|
||||||
|
* @see org.hibernate.SessionBuilder#statementInspector(StatementInspector)
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface StatementInspector extends Serializable {
|
public interface StatementInspector extends Serializable {
|
||||||
/**
|
/**
|
||||||
* Inspect the given SQL, possibly returning a different SQL to be used instead.
|
* Inspect the given SQL command, possibly returning a different
|
||||||
* Note that returning {@code null} is interpreted as returning the same SQL as
|
* SQL command to be used instead. A {@code null} return value is
|
||||||
* was passed.
|
* interpreted as if the method had returned its argument.
|
||||||
*
|
*
|
||||||
* @param sql The SQL to inspect
|
* @param sql The SQL to inspect
|
||||||
*
|
*
|
||||||
* @return The SQL to use; may be {@code null}
|
* @return The processed SQL to use; may be {@code null}
|
||||||
*/
|
*/
|
||||||
String inspect(String sql);
|
String inspect(String sql);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user