Skip to content

[BUG] - Optimistic locking is not disabled when version property is unloaded #957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
belovaf opened this issue Mar 17, 2025 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@belovaf
Copy link
Contributor

belovaf commented Mar 17, 2025

Jimmer Version

0.9.64

JDK Version

23

Database

PostgreSQL, H2

OS

Mac

Expected behavior

If version property is unloaded Jimmer should not try to use optimistic locking. Jimmer should use single upsert statement when save entity.

Actual behavior

Jimmer uses optimistic locking when version property is unloaded. Jimmer executes select + update.

Description

Optimistic locking is not disabled when version property is unloaded.

Reproduction steps

sql.save(A {
    name = "new_name"
    s1 = "new_value"
})

Generated SQL

select + update

Relation Model

@entity
@KeyUniqueConstraint
interface A : SerialId {

@Version
val version: Int

@Key
val name: String

@Default("q1")
val s1: String

@Default("q2")
val s2: String

}

Screenshots

No response

Logs

No response

@belovaf belovaf added the bug Something isn't working label Mar 17, 2025
@babyfish-ct
Copy link
Owner

Is it out control of UnloadedVersionBehavior?

@belovaf
Copy link
Contributor Author

belovaf commented Mar 18, 2025

UnloadedVersionBehavior is working correctly.

The problem is that jimmer always uses optimistic locking even when version property is unloaded.
And jimmer always executes 2 queries (select + update) instead of a single merge/upsert.

babyfish-ct added a commit that referenced this issue Mar 18, 2025
babyfish-ct added a commit that referenced this issue Mar 18, 2025
@babyfish-ct
Copy link
Owner

Try 0.9.68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants