Id of entity with UUID type instead of Number not working
See original GitHub issueWhen I define my model in TypeORM as:
@Entity()
export class User {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ default: false })
isActivated: boolean;
}
I can use POST
without any problem. However when I use PATCH
it is expecting the id
to be a numeric string:
{
"statusCode": 400,
"error": "Bad Request",
"message": "Validation failed. Param 'id': numeric string is expected"
}
The body I’ve sent is:
{
"id": "6aca65b8-ac87-4db8-a492-f4461655b5fa",
"isActivated": true
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Unable to generate UUID id for my entities - Stack Overflow
For ID field I used Postgres uuid type and I set as default value uuid_generate_v4() . All works correctly when I generate a...
Read more >How to generate UUIDs as primary keys with Hibernate
If you decide to use UUIDs as primary keys, Hibernate can generate them based on IETF RFC ... But that doesn't mean that...
Read more >The Ultimate Guide on Client-Generated IDs in JPA Entities
Conclusion: UUID is a good choice for surrogate IDs if we don't want or cannot use a database for ID generation. It is...
Read more >Hibernate and UUID identifiers - Vlad Mihalcea
Learn how the UUID entity attributes are persisted when using JPA and Hibernate for both assigned and auto-generated identifiers.
Read more >How to use String UUID in Hibernate with MySQL | Codementor
Using a unique ID for columns in a table is important. Besides the auto-increment option, we can use the Java UUID column, however, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
New version configuration is like this:
so in your case, you should add this to the
CrudOptions
: