@Size, using hibernate validator, acknowledges error in value that should pass validation

1

I have a Java SE application where I can not use the @size annotation. This annotation is handled by org.hibernate.validator.Size.

It has a user field in the template in which I do this:

@Size(min = 1, max = 30) @Column(name = "CAMPO") private String campo;

When trying to save an object it accuses an InvalidStateException, saying that the value of the String field, which received the value "3216549", should have size between 1 and 30. But the value should pass through validation.

I tried to use @length and did not accuse this error any more. Does anyone have any idea what might be happening with @size? I have read in some places that it is more recommended than @length, for compatibility issues and wanted to use it.

    
asked by anonymous 06.08.2015 / 20:16

1 answer

1

Basically, both are redundant according to Hibernate Documentation :

But note that in the case of Length, the field in the table will have the size set to Max, and this is only valid for Sctring.

Size, you can also define the size of other objects such as lists.

    
06.08.2015 / 20:55