Given this hierarchy:
Code: Select all
public abstract class Rider
{
public long Id { get; private set; }
}
public class BeastRider : Rider
{
public Beast Beast { get; private set; }
public BeastRider(Beast beast) : base()
{
Beast = beast;
}
}
public class Beast : ValueObject
{
public string Name { get; private set; }
public EquineBeast Type { get; private set; }
public Beast(string name, EquineBeast type)
{
Name = name;
Type = type;
}
protected override IEnumerable<object> GetEqualityComponents()
{
yield return Name;
yield return Type;
}
}
Code: Select all
SELECT
"r".ID,
"r".DISCRIMINATOR,
"t".ID AS ID1,
"t".BEAST_NAME,
"t".BEAST_TYPE
FROM RIDER "r"
LEFT JOIN (
SELECT
"b.Beast".*
FROM RIDER "b.Beast"
WHERE "b.Beast".DISCRIMINATOR = 'BeastRider'
)
"t" ON "r".ID = "t".ID
WHERE "r".DISCRIMINATOR = 'BeastRider'
FETCH FIRST 1 ROWS ONLY
When using an owned entity type on a regular entity (not in an inheritance hierarchy), this join is not generated. This is demonstrated in the sample repository below with the "OtherBeastRider" entity. Querying this entity generates the following SQL:
Code: Select all
SELECT
"o".ID,
"o".ID AS ID1,
"o".BEAST_NAME,
"o".BEAST_TYPE
FROM OTHER_RIDER "o"
FETCH FIRST 1 ROWS ONLY
A repository reproducing the issue can be found here: https://github.com/LBRitsSES/devart-efc ... -bug-repro