Skip to content

Commit e0ea066

Browse files
dreab8beikov
authored andcommitted
HHH-17674 Add test for issue
1 parent 6c690f5 commit e0ea066

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
}

0 commit comments

Comments
 (0)