-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Hibernate dialect "Incorrect string value" when using UUID as @Id #14569
Comments
Non id UUID fields uses |
@mshima UUID is useful in a microservice stack, where you want to reference another microservice's object id. |
Hello, sorry I didn't have time to work on this, will try to do the PR soon. Regarding how to solve it, in my project I decided to go with So, I think |
I don’t usually use UUID and I use Postgres so I don’t have a preference.
Go for it. |
The more annoying thing with the current UUID support is that the app currently assumes, that the ID is generated by database(or hibernate) - so if the entity does not have an ID, it is not persisted yet, and if it has, it came from the database. So in a microservice environment, the clients couldn't create an ID by itself. |
Yes, it's wont be hard, but we need to change at least:
So Spring Data could know if it should call entityManager.persist(...) for the new entities or entityManager.merge(...) for the updates. |
I usually do not mix technical id (database key) and functional id (used to be referenced by this id from anywhere else). So I systematically have one ID field and one uuid for uService reference. however, if you think it's a good idea... |
This issue is stale because it has been open 30 days with no activity. |
With my already merged pull request (see link above) this should also be covered, since I also adjusted it for the non-reactive stack... So with the latest jhipster version (starting 7.8.0), it is supposed to be fixed. |
Overview of the issue
When creating a entity to use UUID as @id column, the entity will fail on save with a "Incorrect string value" exception.
JDL
Entity JSON
Area.java
Motivation for or Use Case
It is not possible to save entities when using UUID to save new entities, even having utf8mb4 as character encoding in MySQL server.
Reproduce the error
Related issues
#13258
Suggest a Fix
Define the id column with the type of BINARY(16) in MySQL or it's equivalent in other SQL implementations. In my case I replaced this line on
master.xml
An alternative, that I didn't tested, seems to be add
@Type(type="uuid-char")
annotation to useVARCHAR(36)
JHipster Version(s)
7.0.0
JHipster configuration
Browsers and Operating System
Linux Mint 20
The text was updated successfully, but these errors were encountered: