Is using sub-select the only way to include view entities as member-entities?
I attempted to create a view entity using other view entities as member-entity, but the generated SQL resulted in expressions like subAlias.nestedAlias.fieldName
in the select and join clauses.
To address this, I made the following changes:
- Modified the
getBasicFieldColName
method inEntityDefinition.groovy
like this:
-
Modified the
makeFullColumnName
method:
-
Altered the
appendJoinConditions
method inEntityFindBuilder.java
to usealiasName
-
Adjusted the
makeSqlViewTableName
method to generateAS aliasName
for fields from view entities:
After these modifications, the generated SQL became correct as long as the query doesn’t include any econdition
.
However, there are still a few issues when including conditions:
makeSqlViewTableName
callsmakeSqlFromClause
recursively. InsidemakeSqlFromClause
, we collect used fields by adding all fields fromlocalWhereCondition
, which includes fields unrelated to the current nested view entity.- If we want to filter the
localWhereCondition
in the recursive calls, what would be the best way to track the field reference chain? - How should I handle the return value from
makeSqlFromClause
? It returns anoutWhereCondition
.
I still don’t fully understand the logic behind the SQL generation in EntityFindBuilder
.