Letting the presentation layer (JSF) handle business exceptions from service layer (EJB)

Create a custom service layer specific runtime exception which is annotated with @ApplicationException with rollback=true. @ApplicationException(rollback=true) public abstract class ServiceException extends RuntimeException {} Create some concrete subclasses for general business exceptions, such as constraint violation, required entity, and of course optimistic lock. public class DuplicateEntityException extends ServiceException {} public class EntityNotFoundException extends ServiceException {} public … Read more

Spring MVC: Validation, Post-Redirect-Get, Partial Updates, Optimistic Concurrency, Field Security

To partially update an entity, you should use @SessionAttributes to store the model in session between requests. You could use hidden form fields, but session is more secure. To use P/R/G with validation, use flashAttributes To secure fields use webDataBinder.setAllowedFields(“field1″,”field2”,…) or create a class specific to the form then copy values to your entity. Entities … Read more