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
getBasicFieldColNamemethod inEntityDefinition.groovylike this:
-
Modified the
makeFullColumnNamemethod:
-
Altered the
appendJoinConditionsmethod inEntityFindBuilder.javato usealiasName
-
Adjusted the
makeSqlViewTableNamemethod to generateAS aliasNamefor 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:
makeSqlViewTableNamecallsmakeSqlFromClauserecursively. 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
localWhereConditionin 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.




