[ http://issues.apache.org/jira/browse/IBATIS-58?page=history ]
Clinton Begin closed IBATIS-58:
-------------------------------
Assign To: Clinton Begin
Resolution: Won't Fix
We've made a consious decision to use RuntimeExceptions at the DAO level, which
is consitent with other modern frameworks such as Spring.
As for the exception hierarchy, I would never implement such logic in the
DAOTemplate. It will simply create a nightmare of nested conditional logic and
a number of database specic dependencies. Together they will cause the
framework to behave inconsistently accross databases.
If you do want such a feature, Spring's DAO framework is very good and has
implemented it using a configurable error-code to translator factory
(configured with XML).
> Improve DaoException
> --------------------
>
> Key: IBATIS-58
> URL: http://issues.apache.org/jira/browse/IBATIS-58
> Project: iBatis for Java
> Type: Improvement
> Versions: 2.0.9
> Reporter: Siveton Vincent
> Assignee: Clinton Begin
>
> Actually, in resume, SqlMapDaoTemplate throws a DaoException (a
> NestedRuntimeException subclass) if any SQLException is caught by insert,
> update or delete methods.
> The GeneralStatement class catch SQLException e and wrap it in a
> new NestedSQLException(errorContext.toString(), e.getSQLState(),
> e.getErrorCode(), e);
> I think it is the DAO layer role to catch the sqlexception and give more
> information about this exception, like a schema integrity exception or a DB
> server exception.
> In the SqlMapDaoTemplate class, we can have for example:
> public Object insert / update / delete(String id, Object parameterObject)
> throws DaoException, DatabaseSchemaIntegrityException,
> DatabaseServerException;
> public Object execute* (String id, Object parameterObject)
> throws DaoException, DatabaseServerException;
> This idea is very easy to implement and improve (for me) the development: it
> s only parsing the sqlstate or the sqlerrorcode.
> What does the iBatis team think about that?
> Check these documentation:
> http://www.postgresql.org/docs/current/static/errcodes-appendix.html
> http://dev.mysql.com/doc/mysql/en/Error-handling.html
> For example, we can have this exception hierarchy:
> DatabaseSchemaIntegrityViolationException hierarchy can be
> |--ForeignKeyViolationException
> "23503".equals(se.getSQLState()) if postgresql
> 1216 == se.getErrorCode() if mysql
> |--NotNullViolationException
> "23502".equals(se.getSQLState()) if postgresql
> 1048 == se.getErrorCode() if mysql
> |--UniqueKeyViolationException
> "23505".equals(se.getSQLState()) if postgresql
> 1062 == se.getErrorCode() if mysql
> |--UniqueTableViolationException
> "42P07".equals(se.getSQLState()) if postgresql
> 1050 == se.getErrorCode() if mysql
> DatabaseServerException hierarchy is
> |--LostConnectionException
> "08003".equals(se.getSQLState()) if postgresql
> "08003".equals(se.getSQLState()) if mysql
> |--CommunicationFailureException
> "08S01".equals(se.getSQLState()) if postgresql
> 1043 OR 1053 OR 1081 OR 1154 == se.getErrorCode() if mysql
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira