Skip to content

Commit 3d21604

Browse files
andrei-ivanovgbadner
authored andcommitted
Test for HHH-5255
(cherry picked from commit e0347f8)
1 parent 5394659 commit 3d21604

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

hibernate-core/src/test/java/org/hibernate/test/instrument/buildtime/InstrumentTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
package org.hibernate.test.instrument.buildtime;
88

99
import org.junit.Test;
10-
1110
import org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper;
1211
import org.hibernate.test.instrument.cases.Executable;
1312
import org.hibernate.test.instrument.cases.TestCustomColumnReadAndWrite;
1413
import org.hibernate.test.instrument.cases.TestDirtyCheckExecutable;
1514
import org.hibernate.test.instrument.cases.TestFetchAllExecutable;
1615
import org.hibernate.test.instrument.cases.TestInjectFieldInterceptorExecutable;
1716
import org.hibernate.test.instrument.cases.TestIsPropertyInitializedExecutable;
17+
import org.hibernate.test.instrument.cases.TestLazyBasicPropertyUpdateExecutable;
1818
import org.hibernate.test.instrument.cases.TestLazyExecutable;
1919
import org.hibernate.test.instrument.cases.TestLazyManyToOneExecutable;
2020
import org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable;
@@ -72,6 +72,11 @@ public void testLazyPropertyCustomTypeExecutable() throws Exception {
7272
execute( new TestLazyPropertyCustomTypeExecutable() );
7373
}
7474

75+
@Test
76+
public void testLazyBasicPropertyUpdate() throws Exception {
77+
execute( new TestLazyBasicPropertyUpdateExecutable() );
78+
}
79+
7580
@Test
7681
public void testSharedPKOneToOne() throws Exception {
7782
execute( new TestSharedPKOneToOneExecutable() );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.hibernate.test.instrument.cases;
2+
import org.junit.Assert;
3+
4+
import org.hibernate.Hibernate;
5+
import org.hibernate.Session;
6+
import org.hibernate.Transaction;
7+
import org.hibernate.test.instrument.domain.Document;
8+
import org.hibernate.test.instrument.domain.Folder;
9+
import org.hibernate.test.instrument.domain.Owner;
10+
11+
/**
12+
* @author Andrei Ivanov
13+
*/
14+
public class TestLazyBasicPropertyUpdateExecutable extends AbstractExecutable {
15+
public void execute() {
16+
Session s = getFactory().openSession();
17+
Transaction t = s.beginTransaction();
18+
Owner o = new Owner();
19+
Document doc = new Document();
20+
Folder fol = new Folder();
21+
o.setName("gavin");
22+
doc.setName("Hibernate in Action");
23+
doc.setSummary("blah");
24+
doc.updateText("blah blah");
25+
fol.setName("books");
26+
doc.setOwner(o);
27+
doc.setFolder(fol);
28+
fol.getDocuments().add(doc);
29+
Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) );
30+
s.persist(o);
31+
s.persist(fol);
32+
t.commit();
33+
34+
s.evict(doc);
35+
36+
doc.setSummary("u");
37+
s.merge(doc);
38+
39+
s.close();
40+
}
41+
}

hibernate-core/src/test/java/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ public void testLazyPropertyCustomType() {
115115
executeExecutable( "org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable" );
116116
}
117117

118+
@Test
119+
public void testLazyBasicPropertyUpdate() {
120+
executeExecutable( "org.hibernate.test.instrument.cases.TestLazyBasicPropertyUpdateExecutable" );
121+
}
122+
118123
@Test
119124
public void testSharedPKOneToOne() {
120125
executeExecutable( "org.hibernate.test.instrument.cases.TestSharedPKOneToOneExecutable" );

0 commit comments

Comments
 (0)