lovespring
lovespring

Reputation: 19579

How to avoid hibernate insert empty string to my feild?

I have a Mysql table with a field name "password", I have set this field is NOT NULL in mysql.

but hibernate always insert empty string to my table.

so, I wander if there is a way to config hibernate treat empty string as null and let mysql throw an error that the field is not allow to be NULL.

Upvotes: 0

Views: 1733

Answers (1)

kjosh
kjosh

Reputation: 587

Try adding a constraint to your password field by using the @NotBlank annotation.

Upvotes: 2

Related Questions