org.babyfish.jimmer.sql.fetcher.impl.FetcherUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
package org.babyfish.jimmer.sql.fetcher.impl;
import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.ImmutableType;
import org.babyfish.jimmer.runtime.DraftSpi;
import org.babyfish.jimmer.runtime.Internal;
import org.babyfish.jimmer.sql.ast.Selection;
import org.babyfish.jimmer.sql.fetcher.Fetcher;
import org.babyfish.jimmer.sql.runtime.JSqlClientImplementor;
import org.jetbrains.annotations.Nullable;
import java.sql.Connection;
import java.util.*;
import java.util.function.Function;
public class FetcherUtil {
private FetcherUtil() {}
@SuppressWarnings("unchecked")
public static void fetch(
JSqlClientImplementor sqlClient,
Connection con,
List> selections,
List> rows
) {
if (rows.isEmpty()) {
return;
}
Map> columnMap = new LinkedHashMap<>();
for (int i = 0; i < selections.size(); i++) {
Selection> selection = selections.get(i);
if (selection instanceof FetcherSelection>) {
FetcherSelection> fetcherSelection = (FetcherSelection>) selection;
Fetcher> fetcher = fetcherSelection.getFetcher();
if (!((FetcherImplementor>)fetcher).__isSimpleFetcher() ||
hasReferenceFilter(fetcher.getImmutableType(), sqlClient) ||
fetcherSelection.getConverter() != null) {
columnMap.put(i, new ArrayList<>());
}
}
}
if (columnMap.isEmpty()) {
return;
}
for (Object row : rows) {
for (Map.Entry> e : columnMap.entrySet()) {
int columnIndex = e.getKey();
List