The answer depends on what you understand with "validation". I guess you mean business rule validation (class invariants). An example of such a rule could be that the shipping date of a customer order must be future time compared to order creation date.
The ejbStore seem to be a natural place for such rules. It is a container event that is called at a time when it would be ideal to validate the state of an entity, to assure that only valid entities are persisted. Unfortunately this is not within the use-model of entity beans. There are some reasons why you should search for other patterns: - The container will usually call ejbStore at the end of the transaction, meaning that you cannot catch the exception within a session facade. - You cannot throw application exceptions in ejbStore. Runtime exceptions (including subclasses of EJBException) are considered system exceptions. System exceptions should only be used to report technical problems. Validation exceptions are usually exceptions that report user-generated problems and as such parts of the core business logic. - Throwing a system exception within an ejb will cause the container to discard the instance, which would not be the case for an application exception thrown by a business method. I would say that the architecture of CMP entity beans calls for a use-model where the state of entity beans is ALWAYS valid at the return of an entity business method. Deferring the validation to ejbStore could create situations when a finder could return an entity with invalid state, which could then cause problems to other parts of the application. /Johan Den 02-09-19 01.30, skrev "Slinkster" <[EMAIL PROTECTED]>: > Is it a legal and appropriate use of ejbStore for it to perform validation on > an CMP 2.0 entity bean, and throw a RuntimeException if validation fails? > > Thanks, > > JWS > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff EJB-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
