Skip to content

Commit

Permalink
Improved generated queries when fetching entities over a one-to-many …
Browse files Browse the repository at this point in the history
…relation
  • Loading branch information
hylkevds committed Feb 23, 2024
1 parent 12c405b commit 9a2da38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**New Features**

**Internal changes & Bugfixes**
* Improved generated queries when fetching entities over a one-to-many relation.


## Release version 2.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,10 @@ public TableRef queryEntityType(PathElementEntityType pe, Id targetId, TableRef
}

if (targetId != null) {
Object id = targetId.asBasicPersistenceType();
queryState.setSqlWhere(queryState.getSqlWhere().and(result.getTable().getId().eq(id)));
final Object id = targetId.asBasicPersistenceType();
final Field lastId = result.getTable().getId();
final Field optimisedLastId = result.getJoinEqual(lastId);
queryState.setSqlWhere(queryState.getSqlWhere().and(optimisedLastId.eq(id)));
}

if (mainTable == null) {
Expand Down

0 comments on commit 9a2da38

Please sign in to comment.