-
Notifications
You must be signed in to change notification settings - Fork 368
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
@Version attribute isn't set as 0 when creating a new entity #608
Comments
You will need to create a replicating test case to demonstrate the issue. Use the existing test cases as a reference. I'll check it out afterwards. |
Hi @vladmihalcea , Thank you for your quick reply. I just figured out which case causes a problem.
Here is my test case: After finishing a test, the console log shows what Hibernate did:
I also try to test another case of Map. By modifying bookDetails as a Map with String keys and Publisher values as below:
Then run a test without any error. Here is the console log shows what Hibernate did:
It didn't try to update a new record in DB. This is a comparison between com.vladmihalcea:hibernate-types-55 I updated my quick demo on github (https://github.com/dyleph/books-demo/commits/main). Could you please help to take a look? |
@dyleph I won't have the time to investigate it since we're celebrating Easter, but most likely the problem is caused by the lack of equals and hashCode in all the Objects you store in that Map (keys and values). |
Sorry @vladmihalcea about asking you in Easter time. |
In the meantime, you need to provide a Pull Request into this project that contains a test case demonstrating the issue. There are test cases that assert the number of executed SQL statements. You need to use those too. So, you need to adapt your example into this project so that it becomes a test that will run automatically. |
Hi @vladmihalcea , |
You need to fork the repository and push to your fork. Then, you can send the Pull Request. |
Here is the pull request. I put it here as we can keep track. #619 |
Hi team,
I am upgrading
com.vladmihalcea:hibernate-types-55
from2.17.3
to2.21.1
, and get some failing tests due to @Version attribute value is not as expected.The test is about creating a new entity and check its version is
0
.But actually the version is
1
, which is not as expected.I tried to test on several versions between
2.17.3
and2.21.1
. It seems that since2.20.0
, the issue starts happening.Could you please help to check if is there any change about the default value of @Version attribute? Thank you :)
The text was updated successfully, but these errors were encountered: