Skip to content
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

Standard way to control initial value of @Version #600

Open
quaff opened this issue Mar 19, 2024 · 7 comments
Open

Standard way to control initial value of @Version #600

quaff opened this issue Mar 19, 2024 · 7 comments

Comments

@quaff
Copy link

quaff commented Mar 19, 2024

Test rely on version value assertion is failed when switch from Hibernate to EclipseLink, because Hibernate starts from 0 but EclipseLink starts from 1, It would be nice if the spec enforce it.
I'd like it starts from 1 because it's human readable then can be display in UI directly.

@quaff quaff changed the title Standardize the initial value of numeric version Standardize the initial value of integer version Aug 20, 2024
@gavinking
Copy link
Contributor

The most obvious way to do this is to let you write:

@Version
int version = 1;

and I have a feeling Hibernate already lets you do that.

@quaff
Copy link
Author

quaff commented Aug 21, 2024

@Version
int version = 1;

Both of Hibernate and EclipseLink works fine, perhaps we should repurpose the issue to make this feature official, any non-negative integer initial value will be the seed of version, negative or null initial value is considered as undefined and vendor is free to handle it.

@gavinking
Copy link
Contributor

Both of Hibernate and EclipseLink works fine, perhaps we should repurpose the issue to make this feature official

That sounds good to me.

any non-negative integer initial value will be the seed of version, negative or null initial value is considered as undefined and vendor is free to handle it.

Yes.

@quaff
Copy link
Author

quaff commented Aug 29, 2024

EclipseLink treats int version = 0 and Integer version = 0 as Integer version = null, so the word non-negative should be revised to positive.

@quaff
Copy link
Author

quaff commented Aug 29, 2024

Superseded by #649.

@quaff quaff closed this as completed Aug 29, 2024
@gavinking gavinking reopened this Aug 30, 2024
@gavinking gavinking changed the title Standardize the initial value of integer version Standard way to control initial value of integer @Version Aug 30, 2024
@quaff
Copy link
Author

quaff commented Aug 30, 2024

@gavinking timestamp version applies here too, think about

@Version
LocalDateTime version = LocalDateTime.of(...);

Which one should be the initial value, LocalDateTime.of(...) or LocalDateTime.now() ? Hibernate use the former, but I think now() is better.

@gavinking
Copy link
Contributor

timestamp version applies here too

Yes, sure, I know.

@quaff quaff changed the title Standard way to control initial value of integer @Version Standard way to control initial value of @Version Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants