A frequently asked question is how to implement data validation with JDO. Before looking into a possible technique based on JDO instance callbacks, it is important to briefly think about the layer of an application at which data validation could take place:
At the persistent object level.
Before accessing the persistent objects, in a business-logic method or at UI level (simple validations can sometimes be delegated to UI clients, e.g., Web browsers with Java scripts, or Swing clients).
Datastore level, e.g., using SQL constraints such as NOT NULL, and so on.
While some fervently argue in favor of only one of these options, e.g., “validate at the UI layer only,” it often makes sense to place validation logic at several layers. ...