You try to re-use the integrity constraints of your database for user input validation checks, right? In reality, you can't do that for several reasons:
1. Business constraints on data can be much more complex than you may be able to declare in SQL databases. You would need an additional layer "in front" of the database for validation anyway.
2. There is no way to distinquish error messages from SQL DBMSs, they are vendor dependent. Hibernate can actually not really help here.
3. A programming language is what you usually require for business constraint validation, plain SQL (or datatype, column and table constraints) may not be enough anyway.
For these reasons, it is common to implement user input validation in the presentation (or business) layer of an application. The constraints in the database are of course also important: They at least guarantee the integrity of the data in the database, using the "internal" semantics of the database, instead of the "external" semantics of the more complex business model.
This is of course not a perfect solution, but thats the way it is today with the current SQL databases.
_________________ JAVA PERSISTENCE WITH HIBERNATE http://jpwh.org Get the book, training, and consulting for your Hibernate team.
|