We do have a Web application using JPA with an Oracle database. In many occassions the tables are defined with NOT NULL clauses for some fields. Sometimes we use the JPA @NotNull annotation. We realized that the code for the entities does not match 100% in all cases with the DB tables using the NOT NULL clauses (our DB is changing quite often and then it is not 100% synced with the code in this aspect).
We realized that using @NotNull has good advantages for controlling for example validation in JSF, however it could also have many side effects.
In our project our entities are organized as a hierarchy of classes sharing common fields. With this settings in mind, imagine someone is changing one field in a base entity to @NotNull. This little change will affect many screens and those failures will only be detected at execution time (unless you have an exhaustive testing approach in place).
Now, the question is, what is the suggested way for handling this issue? Is it better to use JPA entities without any kind of hierarchy, even though many fields must be coded again and again?