I'm using dropwizard-hibernate and postgres (hibernate version 5.3.7)
For my DTO i have a base DTO that contains an ID fields (all DTOS extend this class)
In the database schema the Id look like this
id uuid default gen_random_uuid() not null
My configuration for the ID is like this:
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid2")
private UUID id;
In theory this should work but every time that i try to persist an entity i get an error saying
ERROR: relation \"hibernate_sequence\" does not exist\
I've tried everything and nothing works.. i tried just with @Id and @GeneratedValue (according to the latest hibernate documentation that should be enough for the UUID config) and many other combination of annotations but every time I try to persist the entity i get the missing sequence issue.
I know I could "fix it" just adding the hibernate_sequence table in the database but I shouldn't need it at all.
I've used this & it's worked as expected:
@Column(name = "uid")
@Generated(GenerationTime.ALWAYS)
@Type(type = "pg-uuid")
private UUID uid;
I realize that @Generated
is a legacy annotation, but it seems to work.