Home > Software engineering >  Is there a way to name default constraint in hibernate ddl
Is there a way to name default constraint in hibernate ddl

Time:01-04

I am using annotations as below in my entity.

@javax.persistence.Basic
@javax.persistence.Column(nullable = false )
@javax.validation.constraints.NotNull
@org.hibernate.annotations.Type(type = "org.hibernate.type.BooleanType")
@org.hibernate.annotations.ColumnDefault(value = "1")
private boolean primitiveBoolean
                

Generated Hibernate DDL is as below.

[primitiveBoolean] BIT default 1 not null, 

Is there a way to give a constraint name when generating the default value in the generated DDL like below?

[primitiveBoolean]  BIT  NOT NULL CONSTRAINT [DF_TableName_PrimitiveBoolean] DEFAULT 1,

CodePudding user response:

I got an answer from Gavin King through the hibernate forum and posting it here for reference.

  • Related