Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
babyfish-ct committed Nov 10, 2024
1 parent ac1d73f commit bff2f0e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

class JTransactionalSqlClient extends AbstractJSqlClientDelegate {

private static final EntityManager EMPTY_ENTITY_MANAGER = new EntityManager();

@Override
protected JSqlClientImplementor sqlClient() {
JSqlClient sqlClient = JimmerTransactionManager.sqlClient();
Expand All @@ -19,4 +21,12 @@ protected JSqlClientImplementor sqlClient() {
}
return (JSqlClientImplementor) sqlClient;
}

@Override
public void initialize() {}

@Override
public EntityManager getEntityManager() {
return EMPTY_ENTITY_MANAGER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ final QueryReason queryReason(boolean hasId, Collection<DraftSpi> drafts) {
return QueryReason.INTERCEPTOR;
}
JSqlClientImplementor sqlClient = ctx.options.getSqlClient();
if (!hasId && ctx.options.getMode() != SaveMode.UPDATE_ONLY) {
SaveMode saveMode = ctx.options.getMode();
if (!hasId && saveMode != SaveMode.UPDATE_ONLY) {
IdGenerator idGenerator = ctx.options.getSqlClient().getIdGenerator(ctx.path.getType().getJavaClass());
if (idGenerator == null) {
ctx.throwNoIdGenerator();
Expand All @@ -309,15 +310,16 @@ final QueryReason queryReason(boolean hasId, Collection<DraftSpi> drafts) {
}
}
if (!hasId && ctx.options.isInvestigateKeyBasedUpdate() &&
ctx.options.getMode() != SaveMode.INSERT_ONLY &&
ctx.options.getMode() != SaveMode.INSERT_IF_ABSENT) {
saveMode != SaveMode.INSERT_ONLY &&
saveMode != SaveMode.INSERT_IF_ABSENT) {
return QueryReason.PREPARE_TO_INVESTIGATE_KEY_BASED_UPDATE;
}
if (ctx.options.getMode() == SaveMode.UPSERT) {
if (saveMode != SaveMode.INSERT_ONLY && saveMode != SaveMode.UPDATE_ONLY) {
if (!sqlClient.getDialect().isUpsertSupported()) {
return QueryReason.UPSERT_NOT_SUPPORTED;
}
if (!sqlClient.getDialect().isUpsertWithOptimisticLockSupported()) {
if (saveMode != SaveMode.INSERT_IF_ABSENT &&
!sqlClient.getDialect().isUpsertWithOptimisticLockSupported()) {
UserOptimisticLock<?, ?> userLock = ctx.options.getUserOptimisticLock(ctx.path.getType());
boolean useOptimisticLock =
userLock != null ||
Expand Down

0 comments on commit bff2f0e

Please sign in to comment.