HHH-11903 : @OneToOne Derived ID is null when returned by query when bidirectional
This commit is contained in:
parent
1cd56964c6
commit
4741fa4f33
|
@ -13,6 +13,7 @@ import javax.persistence.JoinColumn;
|
|||
import javax.persistence.JoinColumns;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.annotations.LazyGroup;
|
||||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
|
@ -235,10 +236,15 @@ public class OneToOneSecondPass implements SecondPass {
|
|||
boolean referenceToPrimaryKey = referencesDerivedId || mappedBy == null;
|
||||
value.setReferenceToPrimaryKey( referenceToPrimaryKey );
|
||||
|
||||
// If the other side is a derived ID, prevent an infinite
|
||||
// loop of attempts to resolve identifiers.
|
||||
if ( referencesDerivedId ) {
|
||||
( (ManyToOne) otherSideProperty.getValue() ).setReferenceToPrimaryKey( false );
|
||||
// If the other side is a derived ID, and both sides are eager using FetchMode.JOIN,
|
||||
// prevent an infinite loop of attempts to resolve identifiers by making
|
||||
// this side use FetchMode.SELECT.
|
||||
if ( referencesDerivedId &&
|
||||
!value.isLazy() &&
|
||||
value.getFetchMode() == FetchMode.JOIN &&
|
||||
!otherSideProperty.isLazy() &&
|
||||
otherSideProperty.getValue().getFetchMode() == FetchMode.JOIN ) {
|
||||
value.setFetchMode( FetchMode.SELECT );
|
||||
}
|
||||
|
||||
String propertyRef = value.getReferencedPropertyName();
|
||||
|
|
|
@ -25,9 +25,7 @@ import org.junit.Test;
|
|||
|
||||
public class OneToOneWithDerivedIdentityTest extends BaseCoreFunctionalTestCase {
|
||||
@Test
|
||||
//@TestForIssue(jiraKey = "HHH-5695")
|
||||
@TestForIssue(jiraKey = "HHH-11903")
|
||||
@FailureExpected(jiraKey = "HHH-11903")
|
||||
public void testInsertFooAndBarWithDerivedId() {
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
|
|
Loading…
Reference in New Issue