File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/main/java/com/lemick/integration/hibernate Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 22
33import org .hibernate .resource .jdbc .spi .StatementInspector ;
44
5+ /**
6+ * NOT Thread-Safe since it is meant to be used by Spring tests that are not multi-threaded
7+ * ThreadLocal does not work because a test can span on multiple threads (ex: a test executing a HTTP request on the server)
8+ */
59public class HibernateStatementCountInspector implements StatementInspector {
610
7- private static final ThreadLocal < HibernateStatistics > statisticsStore = ThreadLocal . withInitial ( HibernateStatistics :: new );
11+ private static final HibernateStatistics statistics = new HibernateStatistics ( );
812
913 private HibernateStatementParser statementParser = new JSQLHibernateStatementParser ();
1014
1115 @ Override
1216 public String inspect (String sql ) {
13- statementParser .parseSqlStatement (sql , statisticsStore . get () );
17+ statementParser .parseSqlStatement (sql , statistics );
1418 return sql ;
1519 }
1620
1721 public static HibernateStatistics getStatistics () {
18- return statisticsStore . get () ;
22+ return statistics ;
1923 }
2024
2125}
You can’t perform that action at this time.
0 commit comments