That's a SQL/JDBC problem, really - a unique constraint doesn't give you much in terms of customizing the message. I guess if you wanted to, you could look at the message and try to map it to a nicer message...but iBATIS isn't going to do that for you. It would be infeasible to map any database error message to custom exceptions.
Larry On Dec 28, 2007 10:59 PM, yuan gogo <[EMAIL PROTECTED]> wrote: > Hi, all. > I'm new to iBatis, and wonder how to get custom data exception in the > web application. > > Say, I have a database table Users (id, username, password), the username > is UNIQUE. > While insert new user data with a duplicated username , a data exception > will be thrown from jdbc indicate constraint conflict on some datafileds. > But I personally think throw a custom exception like > UsernameExistedException will be a better way for other layer to log or > notify user. > > How can I do it? > > Ps : I use Tapestry 5 + spring 2.5M + iBatis 2 + postgresql 8.3 beta + > tomcat 6.0.14 for evaluation. > > Thanks! > > gogoyuan [_at_] gmail.com >
