If DB schema forbids certain table columns to hold null is there a way to mark corresponding entity class property with @org.jetbrains.annotations.NotNull (or any other JSR-305 compliant annotation) to provide more information for nullity inference by IDEA inspection (or other static analysis tool)?
When i try to do this inspection reports that property marked with @NotNull must be initialized in class initializer. I guess given this fact it's impossible to achive what i've mentioned above? Anyway JPA provider will create entity class object with uninitialized properties and only fill it with DB data aftewards so from point of view of static analysis tool all properties are always nullable?
Thanks in advance.
I'd use
@NotNullmainly in APIs to clearly express design intentions. In your case, the ORM is responsible for creating and assembling entities, so you don't really have a way of of altering its mechanisms - just let it do its job and use@NotNull-s where they make sense.