Skip to content

Commit e0347f8

Browse files
committed
Test for HHH-5255
1 parent f3a8ba6 commit e0347f8

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
@@ -24,14 +24,14 @@
2424
package org.hibernate.test.instrument.buildtime;
2525

2626
import org.junit.Test;
27-
2827
import org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper;
2928
import org.hibernate.test.instrument.cases.Executable;
3029
import org.hibernate.test.instrument.cases.TestCustomColumnReadAndWrite;
3130
import org.hibernate.test.instrument.cases.TestDirtyCheckExecutable;
3231
import org.hibernate.test.instrument.cases.TestFetchAllExecutable;
3332
import org.hibernate.test.instrument.cases.TestInjectFieldInterceptorExecutable;
3433
import org.hibernate.test.instrument.cases.TestIsPropertyInitializedExecutable;
34+
import org.hibernate.test.instrument.cases.TestLazyBasicPropertyUpdateExecutable;
3535
import org.hibernate.test.instrument.cases.TestLazyExecutable;
3636
import org.hibernate.test.instrument.cases.TestLazyManyToOneExecutable;
3737
import org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable;
@@ -89,6 +89,11 @@ public void testLazyPropertyCustomTypeExecutable() throws Exception {
8989
execute( new TestLazyPropertyCustomTypeExecutable() );
9090
}
9191

92+
@Test
93+
public void testLazyBasicPropertyUpdate() throws Exception {
94+
execute( new TestLazyBasicPropertyUpdateExecutable() );
95+
}
96+
9297
@Test
9398
public void testSharedPKOneToOne() throws Exception {
9499
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
@@ -123,6 +123,11 @@ public void testLazyPropertyCustomType() {
123123
executeExecutable( "org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable" );
124124
}
125125

126+
@Test
127+
public void testLazyBasicPropertyUpdate() {
128+
executeExecutable( "org.hibernate.test.instrument.cases.TestLazyBasicPropertyUpdateExecutable" );
129+
}
130+
126131
@Test
127132
public void testSharedPKOneToOne() {
128133
executeExecutable( "org.hibernate.test.instrument.cases.TestSharedPKOneToOneExecutable" );

0 commit comments

Comments
 (0)