File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
src/main/java/com/yannbriancon/interceptor Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 5
5
6
6
<groupId >com.yannbriancon</groupId >
7
7
<artifactId >spring-hibernate-query-utils</artifactId >
8
- <version >1.0.0 </version >
8
+ <version >1.0.1 </version >
9
9
<packaging >jar</packaging >
10
10
11
11
<name >spring-hibernate-query-utils</name >
Original file line number Diff line number Diff line change 12
12
import java .io .Serializable ;
13
13
import java .util .HashSet ;
14
14
import java .util .Set ;
15
+ import java .util .function .Supplier ;
15
16
16
17
@ Component
17
18
@ EnableConfigurationProperties (HibernateQueryInterceptorProperties .class )
18
19
public class HibernateQueryInterceptor extends EmptyInterceptor {
19
20
20
21
private transient ThreadLocal <Long > threadQueryCount = new ThreadLocal <>();
21
22
22
- private transient ThreadLocal <Set <String >> threadPreviouslyLoadedEntities = new ThreadLocal <>();
23
+ private transient ThreadLocal <Set <String >> threadPreviouslyLoadedEntities =
24
+ ThreadLocal .withInitial (new EmptySetSupplier ());
23
25
24
26
private static final Logger LOGGER = LoggerFactory .getLogger (HibernateQueryInterceptor .class );
25
27
26
28
private final HibernateQueryInterceptorProperties hibernateQueryInterceptorProperties ;
27
29
28
30
public HibernateQueryInterceptor (HibernateQueryInterceptorProperties hibernateQueryInterceptorProperties ) {
29
- threadPreviouslyLoadedEntities .set (new HashSet <>());
30
31
this .hibernateQueryInterceptorProperties = hibernateQueryInterceptorProperties ;
31
32
}
32
33
@@ -117,3 +118,9 @@ private void logDetectedNPlusOneQuery(String entityName) {
117
118
}
118
119
}
119
120
}
121
+
122
+ class EmptySetSupplier implements Supplier <Set <String >> {
123
+ public Set <String > get (){
124
+ return new HashSet <>();
125
+ }
126
+ }
You can’t perform that action at this time.
0 commit comments