'Hibernate @NotEmpty is deprecated

I am using 5.2.13.Final version of hibernate-core and 5.2.13.Final version of hibernate-validator.

@NotEmpty
@Column(name = "SSO_ID", unique = true, nullable = false)
private String ssoId;

@NotEmpty comes in picture when I need the following validation message from themessage.properties file when ssoId is empty:

NotEmpty.user.ssoId=SSO ID can not be blank.

But @NotEmpty is deprecated in the latest version. What is its equivalent?



Solution 1:[1]

Generally, as something is marked as deprecated in a javadoc, the javadoc explains also what is the alternative to.

The org.hibernate.validator.constraints.NotEmpty annotation javadoc states (emphasis is mine) :

Deprecated. use the standard javax.validation.constraints.NotEmpty constraint instead

Note that since Hibernate 5, Hibernate deprecated several of its specific validation constraint classes in favor to standard JSR 380-bean validation classes.
Note also that the Hibernate Validator 6 library is actually the reference implementation of this JSR.

Here is an updated list of deprecated API for Hibernate validator.

Solution 2:[2]

Use import javax.validation.constraints.NotBlank; instead of import org.hibernate.validator.constraints.NotBlank;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 rMonteiro