hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

HHH-14810 @NotBlank and @NotEmpty were used, "NOT NULL" option wasn't add in generated DDL.

Open include42 opened this issue 3 years ago • 5 comments

See Jira issue description at this link

If there are any mistakes on code, please comment. thanks :)

include42 avatar Sep 06 '21 16:09 include42

It's an interesting point but I suspect there are good reasons for this; sadly I don't remember the details other than having seen such conversations in the past - we need to ask @gsmet or @gunnarmorling .

Sanne avatar Sep 06 '21 17:09 Sanne

Thank you for your comments 👍 I was curious about what other contributors thought of this issue. I was also curious if this was intended. this is the answer I needed. :)

I'll wait for their answers. thanks a lot.

include42 avatar Sep 06 '21 23:09 include42

I think it makes sense for these two.

They are the exception to the rule that null is considered a valid value for most constraints. The only thing I'm unsure of is that @NotEmpty can be applied to lists, maps and collections too. I have no idea if it requires special handling on the Hibernate ORM side, but I will let you judge of that :).

gsmet avatar Sep 07 '21 15:09 gsmet

Note to self: If we decide to merge it (pending further testing on collections like @gsmet suggested) we're not going to backport it as the schema change would be annoying for very little gain.

And perhaps it should be a 6.0 exclusive.

Sanne avatar Sep 07 '21 15:09 Sanne

Hello, @gsmet! Thank you for the comments. In the code for @NotEmpty, I wrote only for the case of String. So I couldn't think about apply @NotEmpty to collections.(thanks for find it!)

However, I have no idea too if it requires special handling about that. I agree with your opinion because I couldn't find such a case. :)

include42 avatar Sep 08 '21 01:09 include42