org.babyfish.jimmer.sql.ast.impl.Variables 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
The newest version!
package org.babyfish.jimmer.sql.ast.impl;
import org.babyfish.jimmer.impl.util.Classes;
import org.babyfish.jimmer.meta.EmbeddedLevel;
import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.TargetLevel;
import org.babyfish.jimmer.runtime.ImmutableSpi;
import org.babyfish.jimmer.sql.ast.impl.util.ArrayUtils;
import org.babyfish.jimmer.sql.collection.TypedList;
import org.babyfish.jimmer.sql.exception.ExecutionException;
import org.babyfish.jimmer.sql.meta.SingleColumn;
import org.babyfish.jimmer.sql.meta.Storage;
import org.babyfish.jimmer.sql.runtime.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Array;
import java.sql.Timestamp;
import java.time.*;
import java.util.Collection;
import static org.babyfish.jimmer.sql.ScalarProviderUtils.getSqlType;
import static org.babyfish.jimmer.sql.ScalarProviderUtils.toSql;
public class Variables {
public static Object process(
@Nullable Object value,
@NotNull ImmutableProp prop,
@NotNull JSqlClientImplementor sqlClient
) {
return process(value, prop, true, sqlClient);
}
@SuppressWarnings("unchecked")
public static Object process(
@Nullable Object value,
@NotNull ImmutableProp prop,
boolean applyScalarProvider,
@NotNull JSqlClientImplementor sqlClient
) {
if (value instanceof DbLiteral) {
return value;
}
if (prop.isReference(TargetLevel.ENTITY)) {
if (value != null) {
value = ((ImmutableSpi) value).__get(prop.getTargetType().getIdProp().getId());
}
prop = prop.getTargetType().getIdProp();
}
if (prop.isEmbedded(EmbeddedLevel.SCALAR)) {
return new DbLiteral.DbValue(prop, handleDateTime(value, sqlClient.getZoneId()), false);
}
if (applyScalarProvider) {
ScalarProvider