diff --git a/hibernate-core/src/test/java/org/hibernate/test/instrument/buildtime/InstrumentTest.java b/hibernate-core/src/test/java/org/hibernate/test/instrument/buildtime/InstrumentTest.java index e5760ac4dc..68626d75ae 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/instrument/buildtime/InstrumentTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/instrument/buildtime/InstrumentTest.java @@ -24,7 +24,6 @@ package org.hibernate.test.instrument.buildtime; import org.junit.Test; - import org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper; import org.hibernate.test.instrument.cases.Executable; import org.hibernate.test.instrument.cases.TestCustomColumnReadAndWrite; @@ -32,6 +31,7 @@ import org.hibernate.test.instrument.cases.TestDirtyCheckExecutable; import org.hibernate.test.instrument.cases.TestFetchAllExecutable; import org.hibernate.test.instrument.cases.TestInjectFieldInterceptorExecutable; import org.hibernate.test.instrument.cases.TestIsPropertyInitializedExecutable; +import org.hibernate.test.instrument.cases.TestLazyBasicPropertyUpdateExecutable; import org.hibernate.test.instrument.cases.TestLazyExecutable; import org.hibernate.test.instrument.cases.TestLazyManyToOneExecutable; import org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable; @@ -89,6 +89,11 @@ public class InstrumentTest extends BaseUnitTestCase { execute( new TestLazyPropertyCustomTypeExecutable() ); } + @Test + public void testLazyBasicPropertyUpdate() throws Exception { + execute( new TestLazyBasicPropertyUpdateExecutable() ); + } + @Test public void testSharedPKOneToOne() throws Exception { execute( new TestSharedPKOneToOneExecutable() ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/instrument/cases/TestLazyBasicPropertyUpdateExecutable.java b/hibernate-core/src/test/java/org/hibernate/test/instrument/cases/TestLazyBasicPropertyUpdateExecutable.java new file mode 100644 index 0000000000..377573b7ca --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/instrument/cases/TestLazyBasicPropertyUpdateExecutable.java @@ -0,0 +1,41 @@ +package org.hibernate.test.instrument.cases; +import org.junit.Assert; + +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.test.instrument.domain.Document; +import org.hibernate.test.instrument.domain.Folder; +import org.hibernate.test.instrument.domain.Owner; + +/** + * @author Andrei Ivanov + */ +public class TestLazyBasicPropertyUpdateExecutable extends AbstractExecutable { + public void execute() { + Session s = getFactory().openSession(); + Transaction t = s.beginTransaction(); + Owner o = new Owner(); + Document doc = new Document(); + Folder fol = new Folder(); + o.setName("gavin"); + doc.setName("Hibernate in Action"); + doc.setSummary("blah"); + doc.updateText("blah blah"); + fol.setName("books"); + doc.setOwner(o); + doc.setFolder(fol); + fol.getDocuments().add(doc); + Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) ); + s.persist(o); + s.persist(fol); + t.commit(); + + s.evict(doc); + + doc.setSummary("u"); + s.merge(doc); + + s.close(); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java b/hibernate-core/src/test/java/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java index f87c8de092..f702fad157 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/test/instrument/runtime/AbstractTransformingClassLoaderInstrumentTestCase.java @@ -123,6 +123,11 @@ public abstract class AbstractTransformingClassLoaderInstrumentTestCase extends executeExecutable( "org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable" ); } + @Test + public void testLazyBasicPropertyUpdate() { + executeExecutable( "org.hibernate.test.instrument.cases.TestLazyBasicPropertyUpdateExecutable" ); + } + @Test public void testSharedPKOneToOne() { executeExecutable( "org.hibernate.test.instrument.cases.TestSharedPKOneToOneExecutable" );