ComboBox null validation

Hi,

I have a form bound to a bean to create new items in the database. In that form I have a ComboBox bound to a property of type “long”. That property has a @NotNull annotation to add validation. This is working perfectly in other kinds of fields, but in this one the “may not be null” error is not showing at all because instead of having null as the blank value, it has a 0.

How can I make this field have the red mark showing that something is wrong?

Thank you!

If the field type really is “long” (a primitive type), it cannot be null and thus @NotNull doesn’t really make sense for it - at least with respect to Java side validation (it is conceivable that some persistence layers performing the checks outside of the JVM might not make a difference between a null and a zero).

You could use e.g. @Min(1) to make sure the value is positive if that is what you want to check for.

Thank you Henri… I was afraid I would get this answer.
So I guess I could do two things:
1 - Use @Min(1) and change the message displayed for it to be the same as the not null one
2 - Change the
long
property for a
Long
one, but this class was autogenerated so I’ll have to find how