Skip to content

Commit d02c69e

Browse files
dreab8sebersole
authored andcommitted
HHH-19220 Add test for issue
1 parent 702d154 commit d02c69e

File tree

1 file changed

+100
-0
lines changed
  • hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/lazy

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package org.hibernate.orm.test.envers.integration.lazy;
2+
3+
import org.hibernate.annotations.LazyGroup;
4+
import org.hibernate.envers.Audited;
5+
6+
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
7+
import org.hibernate.testing.orm.junit.DomainModel;
8+
import org.hibernate.testing.orm.junit.JiraKey;
9+
import org.hibernate.testing.orm.junit.SessionFactory;
10+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
11+
import org.junit.jupiter.api.BeforeEach;
12+
import org.junit.jupiter.api.Test;
13+
14+
import jakarta.persistence.Basic;
15+
import jakarta.persistence.Entity;
16+
import jakarta.persistence.FetchType;
17+
import jakarta.persistence.Id;
18+
19+
@JiraKey("")
20+
@BytecodeEnhanced
21+
@DomainModel(
22+
annotatedClasses = {
23+
LazyFieldsTest.TestEntity.class,
24+
}
25+
)
26+
@SessionFactory
27+
public class LazyFieldsTest {
28+
29+
private static final Long ID = 1L;
30+
31+
@BeforeEach
32+
public void setUp(SessionFactoryScope scope) {
33+
scope.inTransaction(
34+
session -> {
35+
TestEntity testEntity = new TestEntity( ID, "test data", "lazyString", "group A" );
36+
session.persist( testEntity );
37+
}
38+
);
39+
}
40+
41+
@Test
42+
public void testUpdate(SessionFactoryScope scope) {
43+
scope.inTransaction(
44+
session -> {
45+
TestEntity testEntity = session.find( TestEntity.class, ID );
46+
testEntity.setData( "modified test data" );
47+
}
48+
);
49+
}
50+
51+
@Entity(name = "TestEntity")
52+
public static class TestEntity {
53+
@Id
54+
private Long id;
55+
56+
@Audited
57+
@Basic(optional = false)
58+
private String data;
59+
60+
@Audited
61+
@Basic(fetch = FetchType.LAZY)
62+
private String lazyString;
63+
64+
@Audited
65+
@Basic(fetch = FetchType.LAZY)
66+
@LazyGroup("a")
67+
private String lazyStringGroupA;
68+
69+
public TestEntity() {
70+
}
71+
72+
public TestEntity(Long id, String data, String lazyString, String anotherLazyString) {
73+
this.id = id;
74+
this.data = data;
75+
this.lazyString = lazyString;
76+
this.lazyStringGroupA = anotherLazyString;
77+
}
78+
79+
public Long getId() {
80+
return id;
81+
}
82+
83+
public String getData() {
84+
return data;
85+
}
86+
87+
public void setData(String data) {
88+
this.data = data;
89+
}
90+
91+
public String getLazyString() {
92+
return lazyString;
93+
}
94+
95+
public String getLazyStringGroupA() {
96+
return lazyStringGroupA;
97+
}
98+
}
99+
100+
}

0 commit comments

Comments
 (0)