diff --git a/project/build.gradle.kts b/project/build.gradle.kts index 4a28204a95..65d32b6e54 100644 --- a/project/build.gradle.kts +++ b/project/build.gradle.kts @@ -1,4 +1,4 @@ allprojects { group = "org.babyfish.jimmer" - version = "0.7.120" + version = "0.7.121" } diff --git a/project/jimmer-core/src/main/java/org/babyfish/jimmer/JimmerVersion.java b/project/jimmer-core/src/main/java/org/babyfish/jimmer/JimmerVersion.java index bc401aeda2..a27f9f23b9 100644 --- a/project/jimmer-core/src/main/java/org/babyfish/jimmer/JimmerVersion.java +++ b/project/jimmer-core/src/main/java/org/babyfish/jimmer/JimmerVersion.java @@ -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; diff --git a/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/cfg/JimmerProperties.java b/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/cfg/JimmerProperties.java index fda531ded8..8c86ecc66e 100644 --- a/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/cfg/JimmerProperties.java +++ b/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/cfg/JimmerProperties.java @@ -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; @@ -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; @@ -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, @@ -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 : @@ -232,8 +232,8 @@ public TriggerType getTriggerType() { } @NotNull - public TargetForeignKeyCheckingLevel getTargetForeignKeyCheckingLevel() { - return targetForeignKeyCheckingLevel; + public IdOnlyTargetCheckingLevel getIdOnlyTargetCheckingLevel() { + return idOnlyTargetCheckingLevel; } @NotNull diff --git a/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/cfg/SqlClientConfig.java b/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/cfg/SqlClientConfig.java index 4369bcec32..4fc242d1c4 100644 --- a/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/cfg/SqlClientConfig.java +++ b/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/cfg/SqlClientConfig.java @@ -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()); diff --git a/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/repository/KRepository.kt b/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/repository/KRepository.kt index 3dd802a946..1315aa3fc1 100644 --- a/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/repository/KRepository.kt +++ b/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/repository/KRepository.kt @@ -109,7 +109,6 @@ interface KRepository : PagingAndSortingRepository { fun save(entity: S, mode: SaveMode): KSimpleSaveResult = save(entity) { - setAutoIdOnlyTargetCheckingAll() setMode(mode) } @@ -123,7 +122,6 @@ interface KRepository : PagingAndSortingRepository { fun saveAll(entities: Iterable, mode: SaveMode): KBatchSaveResult = saveAll(entities) { - setAutoIdOnlyTargetCheckingAll() setMode(mode) } diff --git a/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/repository/support/JRepositoryImpl.java b/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/repository/support/JRepositoryImpl.java index e86d0cad0b..56936b18fb 100644 --- a/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/repository/support/JRepositoryImpl.java +++ b/project/jimmer-spring-boot-starter/src/main/java/org/babyfish/jimmer/spring/repository/support/JRepositoryImpl.java @@ -238,7 +238,7 @@ public SimpleSaveResult save(@NotNull S entity, SaveMode mode) return sqlClient .getEntities() .saveCommand(entity) - .configure(cfg -> cfg.setAutoIdOnlyTargetCheckingAll().setMode(mode)) + .setMode(mode) .execute(); } @@ -260,7 +260,7 @@ public BatchSaveResult saveAll(@NotNull Iterable entities, S return sqlClient .getEntities() .batchSaveCommand(Utils.toCollection(entities)) - .configure(cfg -> cfg.setAutoIdOnlyTargetCheckingAll().setMode(mode)) + .setMode(mode) .execute(); } diff --git a/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/cfg/KSqlClientDsl.kt b/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/cfg/KSqlClientDsl.kt index f2470d6307..e43eb40e89 100644 --- a/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/cfg/KSqlClientDsl.kt +++ b/project/jimmer-sql-kotlin/src/main/kotlin/org/babyfish/jimmer/sql/kt/cfg/KSqlClientDsl.kt @@ -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<*>) { diff --git a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClient.java b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClient.java index ddda2e4546..42f9bbad96 100644 --- a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClient.java +++ b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClient.java @@ -326,7 +326,7 @@ interface Builder { Builder addDisabledFilters(Collection> filters); @OldChain - Builder setTargetForeignKeyCheckingLevel(TargetForeignKeyCheckingLevel checkingLevel); + Builder setIdOnlyTargetCheckingLevel(IdOnlyTargetCheckingLevel checkingLevel); @OldChain Builder addDraftInterceptor(DraftInterceptor interceptor); diff --git a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClientImpl.java b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClientImpl.java index 937ccf2ba9..15fe426a7e 100644 --- a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClientImpl.java +++ b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClientImpl.java @@ -89,7 +89,7 @@ class JSqlClientImpl implements JSqlClientImplementor { private final FilterManager filterManager; - private final TargetForeignKeyCheckingLevel targetForeignKeyCheckingLevel; + private final IdOnlyTargetCheckingLevel idOnlyTargetCheckingLevel; private final DraftInterceptorManager draftInterceptorManager; @@ -122,7 +122,7 @@ private JSqlClientImpl( BinLog binLog, FilterManager filterManager, TransientResolverManager transientResolverManager, - TargetForeignKeyCheckingLevel targetForeignKeyCheckingLevel, + IdOnlyTargetCheckingLevel idOnlyTargetCheckingLevel, DraftInterceptorManager draftInterceptorManager, String microServiceName, MicroServiceExchange microServiceExchange @@ -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; @@ -406,7 +406,7 @@ public JSqlClientImplementor caches(Consumer block) { binLog, filterManager, transientResolverManager, - targetForeignKeyCheckingLevel, + idOnlyTargetCheckingLevel, draftInterceptorManager, microServiceName, microServiceExchange @@ -444,7 +444,7 @@ public JSqlClientImplementor filters(Consumer block) { binLog, cfg.getFilterManager(), transientResolverManager, - targetForeignKeyCheckingLevel, + idOnlyTargetCheckingLevel, draftInterceptorManager, microServiceName, microServiceExchange @@ -477,7 +477,7 @@ public JSqlClientImplementor disableSlaveConnectionManager() { binLog, filterManager, transientResolverManager, - targetForeignKeyCheckingLevel, + idOnlyTargetCheckingLevel, draftInterceptorManager, microServiceName, microServiceExchange @@ -500,8 +500,8 @@ public Filters getFilters() { } @Override - public TargetForeignKeyCheckingLevel getTargetForeignKeyCheckingLevel() { - return targetForeignKeyCheckingLevel; + public IdOnlyTargetCheckingLevel getIdOnlyTargetCheckingLevel() { + return idOnlyTargetCheckingLevel; } @Override @@ -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> interceptors = new ArrayList<>(); @@ -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; } @@ -1166,7 +1166,7 @@ public JSqlClient build() { binLog, filterManager, transientResolverManager, - targetForeignKeyCheckingLevel, + idOnlyTargetCheckingLevel, new DraftInterceptorManager(interceptors), microServiceName, microServiceExchange diff --git a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/mutation/AbstractEntitySaveCommandImpl.java b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/mutation/AbstractEntitySaveCommandImpl.java index ed422ed1b1..4ed855cb36 100644 --- a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/mutation/AbstractEntitySaveCommandImpl.java +++ b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/mutation/AbstractEntitySaveCommandImpl.java @@ -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; @@ -126,7 +124,10 @@ public Set 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: @@ -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) { diff --git a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/TargetForeignKeyCheckingLevel.java b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/IdOnlyTargetCheckingLevel.java similarity index 62% rename from project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/TargetForeignKeyCheckingLevel.java rename to project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/IdOnlyTargetCheckingLevel.java index b93ad24b69..01818dbd2f 100644 --- a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/TargetForeignKeyCheckingLevel.java +++ b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/IdOnlyTargetCheckingLevel.java @@ -1,6 +1,6 @@ package org.babyfish.jimmer.sql.runtime; -public enum TargetForeignKeyCheckingLevel { +public enum IdOnlyTargetCheckingLevel { NONE, FAKE, ALL diff --git a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/JSqlClientImplementor.java b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/JSqlClientImplementor.java index afe87d9395..7f7192f7bd 100644 --- a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/JSqlClientImplementor.java +++ b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/JSqlClientImplementor.java @@ -57,7 +57,7 @@ public interface JSqlClientImplementor extends JSqlClient { Class getResolverProviderClass(); - TargetForeignKeyCheckingLevel getTargetForeignKeyCheckingLevel(); + IdOnlyTargetCheckingLevel getIdOnlyTargetCheckingLevel(); DraftInterceptor getDraftInterceptor(ImmutableType type);