HHH-13640 - Fix initialization of existing proxy association leaf subclass
(cherry picked from commit cec4228d70
)
This commit is contained in:
parent
8b855d631b
commit
a3ec300866
|
@ -306,12 +306,7 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
|
||||||
LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
|
LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
|
||||||
|
|
||||||
if ( li.isUnwrap() ) {
|
if ( li.isUnwrap() ) {
|
||||||
if ( entityMetamodel.hasSubclasses() ) {
|
LOG.debug( "Ignoring NO_PROXY to honor laziness" );
|
||||||
LOG.debug( "Ignoring NO_PROXY for to-one association with subclasses to honor laziness" );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return li.getImplementation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return persistenceContext.narrowProxy( proxy, persister, keyToLoad, null );
|
return persistenceContext.narrowProxy( proxy, persister, keyToLoad, null );
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.stat.Statistics;
|
import org.hibernate.stat.Statistics;
|
||||||
|
|
||||||
import org.hibernate.testing.FailureExpected;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
|
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
|
@ -155,7 +154,6 @@ public class LazyToOnesProxyWithSubclassesTest extends BaseNonConfigCoreFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpected( jiraKey = "HHH-13640" )
|
|
||||||
public void testExistingProxyAssociationLeafSubclass() {
|
public void testExistingProxyAssociationLeafSubclass() {
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
|
@ -187,6 +185,12 @@ public class LazyToOnesProxyWithSubclassesTest extends BaseNonConfigCoreFunction
|
||||||
// an uninitialized non-HibernateProxy proxy?
|
// an uninitialized non-HibernateProxy proxy?
|
||||||
assertEquals( 1, stats.getPrepareStatementCount() );
|
assertEquals( 1, stats.getPrepareStatementCount() );
|
||||||
|
|
||||||
|
Human human = otherEntity.getHuman();
|
||||||
|
human.getName();
|
||||||
|
assertEquals( 1, stats.getPrepareStatementCount() );
|
||||||
|
|
||||||
|
human.getSex();
|
||||||
|
assertEquals( 2, stats.getPrepareStatementCount() );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -239,6 +243,8 @@ public class LazyToOnesProxyWithSubclassesTest extends BaseNonConfigCoreFunction
|
||||||
@Table(name = "Human")
|
@Table(name = "Human")
|
||||||
public static class Human extends Primate {
|
public static class Human extends Primate {
|
||||||
|
|
||||||
|
private String sex;
|
||||||
|
|
||||||
public Human(String name) {
|
public Human(String name) {
|
||||||
this();
|
this();
|
||||||
setName( name );
|
setName( name );
|
||||||
|
@ -247,6 +253,14 @@ public class LazyToOnesProxyWithSubclassesTest extends BaseNonConfigCoreFunction
|
||||||
protected Human() {
|
protected Human() {
|
||||||
// this form used by Hibernate
|
// this form used by Hibernate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSex() {
|
||||||
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(String sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "OtherEntity")
|
@Entity(name = "OtherEntity")
|
||||||
|
@ -279,5 +293,13 @@ public class LazyToOnesProxyWithSubclassesTest extends BaseNonConfigCoreFunction
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Human getHuman() {
|
||||||
|
return human;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHuman(Human human) {
|
||||||
|
this.human = human;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue