Test for HHH-5255

This commit is contained in:
Andrei Ivanov 2015-01-29 18:32:27 +02:00
parent f3a8ba6351
commit e0347f81e8
3 changed files with 52 additions and 1 deletions

View File

@ -24,7 +24,6 @@
package org.hibernate.test.instrument.buildtime; package org.hibernate.test.instrument.buildtime;
import org.junit.Test; import org.junit.Test;
import org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper; import org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper;
import org.hibernate.test.instrument.cases.Executable; import org.hibernate.test.instrument.cases.Executable;
import org.hibernate.test.instrument.cases.TestCustomColumnReadAndWrite; 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.TestFetchAllExecutable;
import org.hibernate.test.instrument.cases.TestInjectFieldInterceptorExecutable; import org.hibernate.test.instrument.cases.TestInjectFieldInterceptorExecutable;
import org.hibernate.test.instrument.cases.TestIsPropertyInitializedExecutable; 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.TestLazyExecutable;
import org.hibernate.test.instrument.cases.TestLazyManyToOneExecutable; import org.hibernate.test.instrument.cases.TestLazyManyToOneExecutable;
import org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable; import org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable;
@ -89,6 +89,11 @@ public class InstrumentTest extends BaseUnitTestCase {
execute( new TestLazyPropertyCustomTypeExecutable() ); execute( new TestLazyPropertyCustomTypeExecutable() );
} }
@Test
public void testLazyBasicPropertyUpdate() throws Exception {
execute( new TestLazyBasicPropertyUpdateExecutable() );
}
@Test @Test
public void testSharedPKOneToOne() throws Exception { public void testSharedPKOneToOne() throws Exception {
execute( new TestSharedPKOneToOneExecutable() ); execute( new TestSharedPKOneToOneExecutable() );

View File

@ -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();
}
}

View File

@ -123,6 +123,11 @@ public abstract class AbstractTransformingClassLoaderInstrumentTestCase extends
executeExecutable( "org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable" ); executeExecutable( "org.hibernate.test.instrument.cases.TestLazyPropertyCustomTypeExecutable" );
} }
@Test
public void testLazyBasicPropertyUpdate() {
executeExecutable( "org.hibernate.test.instrument.cases.TestLazyBasicPropertyUpdateExecutable" );
}
@Test @Test
public void testSharedPKOneToOne() { public void testSharedPKOneToOne() {
executeExecutable( "org.hibernate.test.instrument.cases.TestSharedPKOneToOneExecutable" ); executeExecutable( "org.hibernate.test.instrument.cases.TestSharedPKOneToOneExecutable" );