refactor: deduplicate shared logic and remove dead code across modules - #526
Merged
Conversation
| } | ||
| }, getMaxShapes(), new SeqUpdateKey()).forEach(partition -> { | ||
| switch (partition.key()) { | ||
| case SeqNoOpKey ignore -> result.addAll(partition.chunk().stream().map(E::id).toList()); |
| }, getMaxShapes(), new SeqUpdateKey()).forEach(partition -> { | ||
| switch (partition.key()) { | ||
| case SeqNoOpKey ignore -> result.addAll(partition.chunk().stream().map(E::id).toList()); | ||
| case SeqUpsertKey ignore -> result.addAll(upsertPartition.apply(partition.chunk(), entityCache)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behavior-preserving cleanup across the repository: duplicated logic collapses into shared helpers, dead code goes, and redundant dialect overrides are dropped. 91 files, net −1,299 lines. No public API is added; the JPMS surface only narrows.
storm-core
OnConflictEntityRepositoryImplholds theINSERT ... ON CONFLICTupsert machinery previously duplicated between the PostgreSQL and SQLite repositories; the version-column timestamp resolves throughdialect().currentTimestamp(), which renders the same literal PostgreSQL previously hardcoded.EntityRepositoryImplgains the id-returning upsert loop (upsertAndFetchIdsPartitioned+upsertPartitionAndFetchIds+ theSeqPartitionKeytypes) previously copied into the PostgreSQL, MariaDB, and MSSQL repositories, andinsertAndFetchIdReturningfor theINSERT ... RETURNINGsingle-insert PostgreSQL and MariaDB shared verbatim.MergeEntityRepositoryImpl.doUpsert/doUpsertBatchdelegate to their id-returning twins;EntityRepositoryImpl.update(List, PreparedQuery, cache)delegates toupdateAndFetchIds, and the insert pair shares anexecuteInsertBatchprologue. No subclass splits any of these pairs, so dispatch is unchanged (MySQL, whose pair is split by MariaDB, is untouched).SqlTemplateImpl's twin shape/compilation key builders sharebuildKey; the join/WHERE rendering flaggedDuplicatedCodeinDeleteBuilderImpl/SelectBuilderImplmoves toQueryBuilderImpl.appendJoinsAndWhere;TemplateProcessorbinds through onebindAll;TemplatePreparationgainswhereOrParamandresolveFromAlias;RecordMappergainspkColumnOffset;SqlInterceptorManager's four lock bodies share add/remove helpers;Providers.getSqlDialectoverloads sharesqlDialectFor.BaseRefcarries the state and accessorsRefImplandScalarRefImplduplicated;AbstractRefkeeps the cached row identity,ScalarRefImplstays cache-free.QueryBuilder.asMetamodels,setObjectOr, twoREFLECTIONconstants,PredicateBuilderFactory.createRefWithId, the unreachablekClass.isData()re-check).Dialect modules
DefaultSqlDialectare removed: quote-literal/identifier/valid-identifier pattern constants,supportsDeleteAlias/supportsMultiValueTuples,forUpdateLockHint, and the redundantimplements SqlDialectclause. Genuinely divergent code (SQLite's quote regex, MySQL/MSSQL identifier patterns, everyforShareLockHint) stays.requires org.jetbrains.annotations;; the Oracle dialect's mangled license header is restored; SQLite's quote-literal javadoc no longer claims backslash handling its regex does not do.storm-kotlin
RepositoryLookup.ktroute through the typedselect<T>()/selectRef<T>()helpers plus a new@PublishedApi internal selectCount<T>(); every erased cast in those functions is gone and the compiler now checks the chains.ORMTemplateImpl's twin repository scanners sharecreateRepositoryFor;QueryBuilder.kt's three column-list loops sharecolumnList;TransactionCallbackssettles through onefire.storm-spring and starters
exports st.orm.spring.implis now qualified tostorm.kotlin.springand the Spring modules that reflectively instantiate the auto-configuration, registrar, and runtime-hints classes, matching the sealing of storm-core's impl packages.EntityCachesdedupes the entity-cache methods ofSpringTransactionContextandSpringLinkedTransactionContext;PerformanceLogowns thest.orm.sql.perflogger both boundaries previously created;SpringTransactionContextshares its deadline and timeout-translation logic; theDataStormTestcontext key comparesannotationStatedirectly instead of building throwaway filters.Metamodel processors
renderMetamodelClassSource; interfaces sharewriteMetamodelInterface; every generation site useswriteSourceFile;rootIsSameBodyandreportInlineKeyAnnotationsare single-sourced. Regenerating storm-core's 264 generated metamodel files produces byte-identical output.renderResolvedKotlinName,primitiveEq,reportInlineKeyAnnotations, anddependenciesOfcollapse the equivalent copies.Test support
TestSpringConnectionProvider, previously copied into all seven dialect modules, lives once in storm-test underst.orm.test.spring. The package is deliberately not exported: the dialect suites run classpath-mode, where theirMETA-INF/servicesregistration reaches it. spring-jdbc joins storm-test in provided scope, so nothing leaks transitively.IntegrationConfigstays per module on purpose:@EntityScan/@EnableJpaRepositoriesscan from the annotated class's package, so each copy does different work.Verification