Hi!
I'm creating a proof of concept for a first web app completely based on
JPA and Glassfish.
This app will relay heavy on CRUD operations, so first decision was
design database first or entity beans (and relay database creation to
persistence layer - Top Link, in this case). I choose create entities.
Until now, this was a wise choice.
Second decision is how many layers app will have, and what technologies
will be there. Decision was made to:
* View: JSP
* Controller: Servlet
* Model: Entities and specialized beans when necessary
* Business logic: Singleton classes
* High level persistence: Singleton broker classes
* Low level persistence: TopLink essentials through annotations
* Database: undefined. During development, JavaDB. For deployment,
Oracle and MS SQL Server.
In this architecture, all levels re-throw every exception to the
Controller, who register on the log and prepare message for presentation
(made by View layer).
The problem is: how could the Controller capture the error message from
persistence layer for treatment of, let's say, duplicate key?
TopLink capture database exceptions and transform them into common
"DuplicateKeyException"? Or I should deal with different error codes
from each database and do it myself?
Thanks,
Richter