HHH-13875 : Optional one-to-one does not always join the associated entity table when querying
(cherry picked from commit a7261ad053
)
This commit is contained in:
parent
8b21120e95
commit
b6ccfa531b
|
@ -391,11 +391,14 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec
|
||||||
|
|
||||||
if ( isDotNode( parent ) ) {
|
if ( isDotNode( parent ) ) {
|
||||||
// our parent is another dot node, meaning we are being further dereferenced.
|
// our parent is another dot node, meaning we are being further dereferenced.
|
||||||
// thus we need to generate a join unless the parent refers to the associated
|
// thus we need to generate a join unless the association is non-nullable and
|
||||||
// entity's PK (because 'our' table would know the FK).
|
// parent refers to the associated entity's PK (because 'our' table would know the FK).
|
||||||
parentAsDotNode = (DotNode) parent;
|
parentAsDotNode = (DotNode) parent;
|
||||||
property = parentAsDotNode.propertyName;
|
property = parentAsDotNode.propertyName;
|
||||||
joinIsNeeded = generateJoin && !isReferenceToPrimaryKey( parentAsDotNode.propertyName, entityType );
|
joinIsNeeded = generateJoin && (
|
||||||
|
entityType.isNullable() ||
|
||||||
|
!isReferenceToPrimaryKey( parentAsDotNode.propertyName, entityType )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if ( !getWalker().isSelectStatement() ) {
|
else if ( !getWalker().isSelectStatement() ) {
|
||||||
// in non-select queries, the only time we should need to join is if we are in a subquery from clause
|
// in non-select queries, the only time we should need to join is if we are in a subquery from clause
|
||||||
|
|
Loading…
Reference in New Issue