Skip to main content
added 147 characters in body
Source Link

If you have a column with UNIQUEIDENTIFIER type and default generation needed on insert but column is not PK

@Generated(GenerationTime.INSERT) @Column(nullable = false , columnDefinition="UNIQUEIDENTIFIER") private String uuidValue; 

In db you will have

CREATE TABLE operation.Table1 ( Id INT IDENTITY (1,1) NOT NULL, UuidValue UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL) 

In this case you will not define generator for a value which you need (It will be automatically thanks to columnDefinition="UNIQUEIDENTIFIER"). The same you can try for other column types

If you have a column with UNIQUEIDENTIFIER type and default generation needed on insert but column is not PK

@Generated(GenerationTime.INSERT) @Column(nullable = false , columnDefinition="UNIQUEIDENTIFIER") private String uuidValue; 

In db you will have

CREATE TABLE operation.Table1 ( Id INT IDENTITY (1,1) NOT NULL, UuidValue UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL) 

The same you can try for other column types

If you have a column with UNIQUEIDENTIFIER type and default generation needed on insert but column is not PK

@Generated(GenerationTime.INSERT) @Column(nullable = false , columnDefinition="UNIQUEIDENTIFIER") private String uuidValue; 

In db you will have

CREATE TABLE operation.Table1 ( Id INT IDENTITY (1,1) NOT NULL, UuidValue UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL) 

In this case you will not define generator for a value which you need (It will be automatically thanks to columnDefinition="UNIQUEIDENTIFIER"). The same you can try for other column types

Source Link

If you have a column with UNIQUEIDENTIFIER type and default generation needed on insert but column is not PK

@Generated(GenerationTime.INSERT) @Column(nullable = false , columnDefinition="UNIQUEIDENTIFIER") private String uuidValue; 

In db you will have

CREATE TABLE operation.Table1 ( Id INT IDENTITY (1,1) NOT NULL, UuidValue UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL) 

The same you can try for other column types