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
Add support for querying by the embedded MonetaryAmount attributes #497
Comments
Fixed. |
I am running kotlin spring boot, with a simple JpaRepository, and since this fix im getting this error
when running
Here is an example on a test:
Any thoughts? |
@viktorvoltaire Most likely, it's thrown from this method, but you will have to debug and see why that one got called in your case while the existing test cases in this repository work just fine. Doing a comparative debug between your code and the integration tests in this repository will surely help you find the problem. Looking forward to seeing what you found during your investigation. |
Tbh im not sure, prior to bumping to version Once bumping to version Hence the |
Try to debug the |
I guess its because |
According to the Hibernate API spec:
Now, it could be a wrong assumption, but it's curious why it works in the official tests? And, without it, you won't be able to query by its internal attributes. |
Interesting, we are not working with EntityManager the same way you are, basically we are just calling an Interface that implements a JpaRepository, and then we run save on that. The types we use for MonetaryAmount in our postgres db is
Other than that we have followed your guide https://vladmihalcea.com/monetaryamount-jpa-hibernate/ on how to implement it |
Could it be because hibernate is invoking merge, based on how we create the entity |
It's not Hibernate, it's Spring then. Check out this article about the Spring save anti-pattern. However, you could try to provide a replicating test case for merge in this repo, and I'll create an issue if you can replicate it. |
I will have a look when I have time, here is a bit more from the stacktrace. As you pointed out its
|
I did some more testing, and by adding a version to the entity
makes the isNew true, causing the entityManager to run persist rather than merge
We use a UUID as the ID on the table, so
will always make |
@viktorvoltaire I changed the test cases to include The problem is, most likely, called by the Spring |
Yeah you are right @vladmihalcea thanks for all the assist! |
@viktorvoltaire You're welcome. |
This will allow us to run queries like the following one:
The text was updated successfully, but these errors were encountered: