HHH-14390 : StackOverflowError with @Fetch(FetchMode.SELECT) mapped for entity with an ID that is a bidirectional one-to-one eager association
This commit is contained in:
parent
611796c0fc
commit
8a01b4dab4
|
@ -237,14 +237,15 @@ public class OneToOneSecondPass implements SecondPass {
|
||||||
boolean referenceToPrimaryKey = referencesDerivedId || mappedBy == null;
|
boolean referenceToPrimaryKey = referencesDerivedId || mappedBy == null;
|
||||||
value.setReferenceToPrimaryKey( referenceToPrimaryKey );
|
value.setReferenceToPrimaryKey( referenceToPrimaryKey );
|
||||||
|
|
||||||
// If the other side is a derived ID, and both sides are eager using FetchMode.JOIN,
|
// If the other side is an entity with an ID that is derived from
|
||||||
// prevent an infinite loop of attempts to resolve identifiers by making
|
// this side's owner entity, and both sides of the association are eager,
|
||||||
// this side use FetchMode.SELECT.
|
// then this side must be set to FetchMode.SELECT; otherwise,
|
||||||
|
// there will be an infinite loop attempting to load the derived ID on
|
||||||
|
// the opposite side.
|
||||||
if ( referencesDerivedId &&
|
if ( referencesDerivedId &&
|
||||||
!value.isLazy() &&
|
!value.isLazy() &&
|
||||||
value.getFetchMode() == FetchMode.JOIN &&
|
value.getFetchMode() == FetchMode.JOIN &&
|
||||||
!otherSideProperty.isLazy() &&
|
!otherSideProperty.isLazy() ) {
|
||||||
otherSideProperty.getValue().getFetchMode() == FetchMode.JOIN ) {
|
|
||||||
value.setFetchMode( FetchMode.SELECT );
|
value.setFetchMode( FetchMode.SELECT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ public class OneToOneEagerDerivedIdFetchModeSelectTest extends BaseCoreFunctiona
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-14390")
|
@TestForIssue(jiraKey = "HHH-14390")
|
||||||
@FailureExpected(jiraKey = "HHH-14390")
|
|
||||||
public void testQuery() {
|
public void testQuery() {
|
||||||
|
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
|
@ -52,7 +51,6 @@ public class OneToOneEagerDerivedIdFetchModeSelectTest extends BaseCoreFunctiona
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-14390")
|
@TestForIssue(jiraKey = "HHH-14390")
|
||||||
@FailureExpected(jiraKey = "HHH-14390")
|
|
||||||
public void testQueryById() {
|
public void testQueryById() {
|
||||||
|
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
|
@ -82,7 +80,6 @@ public class OneToOneEagerDerivedIdFetchModeSelectTest extends BaseCoreFunctiona
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-14390")
|
@TestForIssue(jiraKey = "HHH-14390")
|
||||||
@FailureExpected(jiraKey = "HHH-14390")
|
|
||||||
public void testFindByPrimaryKey() {
|
public void testFindByPrimaryKey() {
|
||||||
|
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
|
|
Loading…
Reference in New Issue