Skip to content

Commit

Permalink
0.7.121
Browse files Browse the repository at this point in the history
  • Loading branch information
babyfish-ct committed Jul 17, 2023
1 parent 0057083 commit 3d70e8c
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion project/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
allprojects {
group = "org.babyfish.jimmer"
version = "0.7.120"
version = "0.7.121"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class JimmerVersion {

public static final JimmerVersion CURRENT =
new JimmerVersion(0, 7, 120);
new JimmerVersion(0, 7, 121);

private final int major;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.babyfish.jimmer.sql.dialect.Dialect;
import org.babyfish.jimmer.sql.event.TriggerType;
import org.babyfish.jimmer.sql.runtime.DatabaseValidationMode;
import org.babyfish.jimmer.sql.runtime.TargetForeignKeyCheckingLevel;
import org.babyfish.jimmer.sql.runtime.IdOnlyTargetCheckingLevel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.boot.context.properties.ConfigurationProperties;
Expand Down Expand Up @@ -40,7 +40,7 @@ public class JimmerProperties {
private final TriggerType triggerType;

@NotNull
private final TargetForeignKeyCheckingLevel targetForeignKeyCheckingLevel;
private final IdOnlyTargetCheckingLevel idOnlyTargetCheckingLevel;

@NotNull
private final int transactionCacheOperatorFixedDelay;
Expand Down Expand Up @@ -77,7 +77,7 @@ public JimmerProperties(
@Deprecated @Nullable DatabaseValidationMode databaseValidationMode,
@Nullable DatabaseValidation databaseValidation,
@Nullable TriggerType triggerType,
@Nullable TargetForeignKeyCheckingLevel targetForeignKeyCheckingLevel,
@Nullable IdOnlyTargetCheckingLevel idOnlyTargetCheckingLevel,
@Nullable Integer transactionCacheOperatorFixedDelay,
@Nullable EnumType.Strategy defaultEnumStrategy,
@Nullable Integer defaultBatchSize,
Expand Down Expand Up @@ -157,10 +157,10 @@ public JimmerProperties(
);
}
this.triggerType = triggerType != null ? triggerType : TriggerType.BINLOG_ONLY;
this.targetForeignKeyCheckingLevel =
targetForeignKeyCheckingLevel != null ?
targetForeignKeyCheckingLevel :
TargetForeignKeyCheckingLevel.NONE;
this.idOnlyTargetCheckingLevel =
idOnlyTargetCheckingLevel != null ?
idOnlyTargetCheckingLevel :
IdOnlyTargetCheckingLevel.NONE;
this.transactionCacheOperatorFixedDelay =
transactionCacheOperatorFixedDelay != null ?
transactionCacheOperatorFixedDelay :
Expand Down Expand Up @@ -232,8 +232,8 @@ public TriggerType getTriggerType() {
}

@NotNull
public TargetForeignKeyCheckingLevel getTargetForeignKeyCheckingLevel() {
return targetForeignKeyCheckingLevel;
public IdOnlyTargetCheckingLevel getIdOnlyTargetCheckingLevel() {
return idOnlyTargetCheckingLevel;
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private static void preCreateSqlClient(

builder.setDialect(dialect != null ? dialect : properties.getDialect());
builder.setTriggerType(properties.getTriggerType());
builder.setTargetForeignKeyCheckingLevel(properties.getTargetForeignKeyCheckingLevel());
builder.setIdOnlyTargetCheckingLevel(properties.getIdOnlyTargetCheckingLevel());
builder.setDefaultEnumStrategy(properties.getDefaultEnumStrategy());
builder.setDefaultBatchSize(properties.getDefaultBatchSize());
builder.setDefaultListBatchSize(properties.getDefaultListBatchSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ interface KRepository<E: Any, ID: Any> : PagingAndSortingRepository<E, ID> {

fun <S: E> save(entity: S, mode: SaveMode): KSimpleSaveResult<S> =
save(entity) {
setAutoIdOnlyTargetCheckingAll()
setMode(mode)
}

Expand All @@ -123,7 +122,6 @@ interface KRepository<E: Any, ID: Any> : PagingAndSortingRepository<E, ID> {

fun <S : E> saveAll(entities: Iterable<S>, mode: SaveMode): KBatchSaveResult<S> =
saveAll(entities) {
setAutoIdOnlyTargetCheckingAll()
setMode(mode)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public <S extends E> SimpleSaveResult<S> save(@NotNull S entity, SaveMode mode)
return sqlClient
.getEntities()
.saveCommand(entity)
.configure(cfg -> cfg.setAutoIdOnlyTargetCheckingAll().setMode(mode))
.setMode(mode)
.execute();
}

Expand All @@ -260,7 +260,7 @@ public <S extends E> BatchSaveResult<S> saveAll(@NotNull Iterable<S> entities, S
return sqlClient
.getEntities()
.batchSaveCommand(Utils.toCollection(entities))
.configure(cfg -> cfg.setAutoIdOnlyTargetCheckingAll().setMode(mode))
.setMode(mode)
.execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ class KSqlClientDsl internal constructor(
javaBuilder.ignoreBuiltInFilters()
}

fun set(checkingLevel: TargetForeignKeyCheckingLevel) {
javaBuilder.setTargetForeignKeyCheckingLevel(checkingLevel)
fun setIdOnlyTargetCheckingLevel(checkingLevel: IdOnlyTargetCheckingLevel) {
javaBuilder.setIdOnlyTargetCheckingLevel(checkingLevel)
}

fun addDraftInterceptor(interceptor: DraftInterceptor<*>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ interface Builder {
Builder addDisabledFilters(Collection<? extends Filter<?>> filters);

@OldChain
Builder setTargetForeignKeyCheckingLevel(TargetForeignKeyCheckingLevel checkingLevel);
Builder setIdOnlyTargetCheckingLevel(IdOnlyTargetCheckingLevel checkingLevel);

@OldChain
Builder addDraftInterceptor(DraftInterceptor<?> interceptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class JSqlClientImpl implements JSqlClientImplementor {

private final FilterManager filterManager;

private final TargetForeignKeyCheckingLevel targetForeignKeyCheckingLevel;
private final IdOnlyTargetCheckingLevel idOnlyTargetCheckingLevel;

private final DraftInterceptorManager draftInterceptorManager;

Expand Down Expand Up @@ -122,7 +122,7 @@ private JSqlClientImpl(
BinLog binLog,
FilterManager filterManager,
TransientResolverManager transientResolverManager,
TargetForeignKeyCheckingLevel targetForeignKeyCheckingLevel,
IdOnlyTargetCheckingLevel idOnlyTargetCheckingLevel,
DraftInterceptorManager draftInterceptorManager,
String microServiceName,
MicroServiceExchange microServiceExchange
Expand Down Expand Up @@ -159,7 +159,7 @@ private JSqlClientImpl(
this.binLog = binLog;
this.filterManager = filterManager;
this.transientResolverManager = transientResolverManager;
this.targetForeignKeyCheckingLevel = targetForeignKeyCheckingLevel;
this.idOnlyTargetCheckingLevel = idOnlyTargetCheckingLevel;
this.draftInterceptorManager = draftInterceptorManager;
this.microServiceName = microServiceName;
this.microServiceExchange = microServiceExchange;
Expand Down Expand Up @@ -406,7 +406,7 @@ public JSqlClientImplementor caches(Consumer<CacheDisableConfig> block) {
binLog,
filterManager,
transientResolverManager,
targetForeignKeyCheckingLevel,
idOnlyTargetCheckingLevel,
draftInterceptorManager,
microServiceName,
microServiceExchange
Expand Down Expand Up @@ -444,7 +444,7 @@ public JSqlClientImplementor filters(Consumer<FilterConfig> block) {
binLog,
cfg.getFilterManager(),
transientResolverManager,
targetForeignKeyCheckingLevel,
idOnlyTargetCheckingLevel,
draftInterceptorManager,
microServiceName,
microServiceExchange
Expand Down Expand Up @@ -477,7 +477,7 @@ public JSqlClientImplementor disableSlaveConnectionManager() {
binLog,
filterManager,
transientResolverManager,
targetForeignKeyCheckingLevel,
idOnlyTargetCheckingLevel,
draftInterceptorManager,
microServiceName,
microServiceExchange
Expand All @@ -500,8 +500,8 @@ public Filters getFilters() {
}

@Override
public TargetForeignKeyCheckingLevel getTargetForeignKeyCheckingLevel() {
return targetForeignKeyCheckingLevel;
public IdOnlyTargetCheckingLevel getIdOnlyTargetCheckingLevel() {
return idOnlyTargetCheckingLevel;
}

@Override
Expand Down Expand Up @@ -586,8 +586,8 @@ public static class BuilderImpl implements JSqlClient.Builder {

private boolean ignoreBuiltInFilters = false;

private TargetForeignKeyCheckingLevel targetForeignKeyCheckingLevel =
TargetForeignKeyCheckingLevel.NONE;
private IdOnlyTargetCheckingLevel idOnlyTargetCheckingLevel =
IdOnlyTargetCheckingLevel.NONE;

private final List<DraftInterceptor<?>> interceptors = new ArrayList<>();

Expand Down Expand Up @@ -928,10 +928,10 @@ public Builder ignoreBuiltInFilters() {
}

@Override
public Builder setTargetForeignKeyCheckingLevel(TargetForeignKeyCheckingLevel checkingLevel) {
targetForeignKeyCheckingLevel = checkingLevel != null ?
public Builder setIdOnlyTargetCheckingLevel(IdOnlyTargetCheckingLevel checkingLevel) {
idOnlyTargetCheckingLevel = checkingLevel != null ?
checkingLevel :
TargetForeignKeyCheckingLevel.NONE;
IdOnlyTargetCheckingLevel.NONE;
return this;
}

Expand Down Expand Up @@ -1166,7 +1166,7 @@ public JSqlClient build() {
binLog,
filterManager,
transientResolverManager,
targetForeignKeyCheckingLevel,
idOnlyTargetCheckingLevel,
new DraftInterceptorManager(interceptors),
microServiceName,
microServiceExchange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.ImmutableType;
import org.babyfish.jimmer.meta.TargetLevel;
import org.babyfish.jimmer.meta.spi.ImmutablePropImplementor;
import org.babyfish.jimmer.sql.DissociateAction;
import org.babyfish.jimmer.sql.ast.mutation.DeleteMode;
import org.babyfish.jimmer.sql.event.TriggerType;
import org.babyfish.jimmer.sql.event.Triggers;
import org.babyfish.jimmer.sql.ast.mutation.AbstractEntitySaveCommand;
import org.babyfish.jimmer.sql.ast.mutation.SaveMode;
import org.babyfish.jimmer.sql.runtime.TargetForeignKeyCheckingLevel;
import org.babyfish.jimmer.sql.runtime.JSqlClientImplementor;

import java.sql.Connection;
Expand Down Expand Up @@ -126,7 +124,10 @@ public Set<ImmutableProp> getKeyProps(ImmutableType type) {
}

public boolean isAutoCheckingProp(ImmutableProp prop) {
switch (sqlClient.getTargetForeignKeyCheckingLevel()) {
if (autoUncheckingSet.contains(prop)) {
return false;
}
switch (sqlClient.getIdOnlyTargetCheckingLevel()) {
case ALL:
return true;
case FAKE:
Expand All @@ -135,7 +136,7 @@ public boolean isAutoCheckingProp(ImmutableProp prop) {
}
break;
}
return (autoCheckingAll || autoCheckingSet.contains(prop)) && !autoUncheckingSet.contains(prop);
return autoCheckingAll || autoCheckingSet.contains(prop);
}

public boolean isAppendOnly(ImmutableProp prop) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.babyfish.jimmer.sql.runtime;

public enum TargetForeignKeyCheckingLevel {
public enum IdOnlyTargetCheckingLevel {
NONE,
FAKE,
ALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public interface JSqlClientImplementor extends JSqlClient {

Class<? extends TransientResolverProvider> getResolverProviderClass();

TargetForeignKeyCheckingLevel getTargetForeignKeyCheckingLevel();
IdOnlyTargetCheckingLevel getIdOnlyTargetCheckingLevel();

DraftInterceptor<?> getDraftInterceptor(ImmutableType type);

Expand Down

0 comments on commit 3d70e8c

Please sign in to comment.