org.babyfish.jimmer.sql.fetcher.impl.FetchingCache 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.runtime.DraftContext;
import org.babyfish.jimmer.runtime.DraftSpi;
import org.babyfish.jimmer.runtime.ImmutableSpi;
import org.babyfish.jimmer.sql.fetcher.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public class FetchingCache {
private static final Object NULL = new Object();
private final Map> map = new HashMap<>();
public Object createKey(Field field, ImmutableSpi owner) {
ImmutableProp prop = field.getProp();
if (prop.isColumnDefinition()) {
Object fk = Ids.idOf((ImmutableSpi) owner.__get(prop.getId()));
DraftContext ctx = owner instanceof DraftSpi ?
((DraftSpi) owner).__draftContext() :
null;
return new ForeignKey(fk, ctx);
}
return Ids.idOf(owner);
}
public Object get(Field field, Object key) {
Map