File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
hibernate-core/src/test/java/org/hibernate/orm/test/eviction Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .hibernate .orm .test .eviction ;
2
+
3
+ import org .hibernate .testing .orm .junit .DomainModel ;
4
+ import org .hibernate .testing .orm .junit .SessionFactory ;
5
+ import org .hibernate .testing .orm .junit .SessionFactoryScope ;
6
+ import org .junit .jupiter .api .Test ;
7
+
8
+ import jakarta .persistence .Entity ;
9
+ import jakarta .persistence .Id ;
10
+
11
+ @ DomainModel (
12
+ annotatedClasses = EvictAndGetTest .TestEntity .class
13
+ )
14
+ @ SessionFactory
15
+ public class EvictAndGetTest {
16
+
17
+ @ Test
18
+ public void testGetAfterEviction (SessionFactoryScope scope ) {
19
+ scope .inTransaction (
20
+ session -> {
21
+ TestEntity proxy = session .getReference ( TestEntity .class , 1L );
22
+
23
+ TestEntity entity = new TestEntity ( 1L );
24
+ session .persist ( entity );
25
+
26
+ session .flush ();
27
+
28
+ session .evict ( entity );
29
+
30
+ session .get ( TestEntity .class , 1L );
31
+ }
32
+ );
33
+ }
34
+
35
+ @ Entity (name = "TestEntity" )
36
+ public static class TestEntity {
37
+
38
+ @ Id
39
+ private Long id ;
40
+
41
+ private String name ;
42
+
43
+ public TestEntity () {
44
+ }
45
+
46
+ public TestEntity (Long id ) {
47
+ this .id = id ;
48
+ }
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments