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