mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Add STI Discrimination on Reference Associations (#2041)
* Update SqlTreeNodeBean#appendFromBaseTable to add discriminator values to the join * Update tests to reflect new generated SQL
This commit is contained in:
@@ -667,6 +667,9 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
*/
|
||||
SqlJoinType appendFromBaseTable(DbSqlContext ctx, SqlJoinType joinType) {
|
||||
SqlJoinType sqlJoinType = appendFromAsJoin(ctx, joinType);
|
||||
if (inheritInfo != null) {
|
||||
appendJoinDiscriminator(ctx);
|
||||
}
|
||||
if (desc.isSoftDelete() && temporalMode != SpiQuery.TemporalMode.SOFT_DELETED) {
|
||||
ctx.append("and ").append(desc.getSoftDeletePredicate(ctx.getTableAlias(prefix))).append(" ");
|
||||
}
|
||||
@@ -695,6 +698,12 @@ class SqlTreeNodeBean implements SqlTreeNode {
|
||||
return nodeBeanProp.addJoin(joinType, prefix, ctx);
|
||||
}
|
||||
|
||||
void appendJoinDiscriminator(DbSqlContext ctx) {
|
||||
if (inheritInfo.getWhere() == null) return;
|
||||
String alias = ctx.getTableAlias(prefix);
|
||||
ctx.append(" and ").append(alias).append(".").append(inheritInfo.getWhere());
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary description.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user