0

I am new to the Spring framework. In my current project, I have a property of a class that requires the ID to have a minimum of six digits in length. All the id's must have six digits or more. I have tried to set the length of the Id to be six digits below.

@Length(min=6)
private Long Id;

However, it did not work. I got the following error

Error during managed flush [HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.Long'. Check configuration for 'HAWB']

Any help would be appreciated

ben brick
  • 31
  • 1
  • 7

2 Answers2

0

The Length annotation is for Strings. Try

@Min(100000)
private Long Id;

?

nvioli
  • 4,137
  • 3
  • 22
  • 38
0

As per hibernate documentation which I found here, @Length is used for strings and not long or int data types.
@Min can be used for your requirement as per Oracle docs.

VijayD
  • 826
  • 1
  • 11
  • 33