#2184 - Fix for findNative() with fetch() - convert fetch to fetchQuery with nativeSql

When using nativeSql (think of it as the "root query") we can't use "fetch joins" (FetchConfig.ofDefault()) as that means to prefer to use a SQL JOIN. In this nativeSql case we need to effectively automatically convert fetch() to fetchQuery()
This commit is contained in:
Robin Bygrave
2021-03-02 15:47:07 +13:00
parent 2cbbbc4419
commit 81e445e386
2 changed files with 9 additions and 3 deletions
@@ -1441,6 +1441,10 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
@Override
public Query<T> fetch(String path, String properties, FetchConfig config) {
if (nativeSql != null && (config == null || config.isJoin())) {
// can't use fetch join with nativeSql (as the root query)
config = FETCH_QUERY;
}
return fetchInternal(path, properties, config);
}