#Springboot GenerationType.UUID not working

13 messages · Page 1 of 1 (latest)

serene ledge
#
@Table(name = "Product")
public class Product {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private UUID id;

On create drop the sql field becomes:

id uuid not null primary key,

upon inserting a row without specifying my Id field i get the error:

[23502] ERROR: null value in column "id" of relation "product" violates not-null constraint
fierce houndBOT
#

This post has been reserved for your question.

Hey @serene ledge! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

tall elm
#

Hey Edd,
you need to call myProduct.setId(UUID.randomUUID()); before saving to the database.

forest jasper
forest jasper
#

or, extend AbstractPersistable<UUID>, and remove all id related stuff from your own entity

long ferry
#

@serene ledge can you try String instead of UUID

#

Wait, do you have another relationships in your entity?

#

It can be throw for another reason

#

Because your implementation is right for me, because we used this way

fierce houndBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.