As far as I can tell from the userguide and writing some test code,
mybatis has no exception handling.
E.g:
SqlSession session = SqlSessionFactory.openSession();
PlayerMapper mapper = session.getMapper(PlayerMapper.class);
player = mapper.select(id);
Neither the getMapper, select, openSession throw any checked exception
accroding to eclipse, or the einterface definition.
What happens if you have a sql error? What happens if you lose
connection to the DB? Surely at least commit() should throw a sql
exception if the resource is busy for example? how would you detect
this case, and retry later, or tell the user who is locking the
resource?
Are all the exceptions throw converted to RuntimeException? If so,
are they documented anywhere?
Doing a grep for "catch" in the userguide doesnt find anyting, and
doing a grep for "exception" doesnt show anyting useful. Trolling
though the source, it would appear that IbatisException is a
RuntimeException, which would seem sacrelige. see:
http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/essential/exceptions/runtime.html
i.e. if they are runtime, its not possible to know what excptions are
thrown by a method, toensure that they are dealt with appropriately.
I would argue sql exceptions are VERY important at the DAO layer -
e.g. to know if a commit failed because resource is in use requires
either 1) retrying a number of times 2) teling the user to try again
later 3) telling the user who is locking the resource etc. If I
search expecting say one row, and get multiple, I dont want an
uncaught RuntimeExcpeiton killing the whole app, I want to deal with
it whenever it can occur and inform the user.
If mybatis has no checked exceptions, this is a showstopper for me.
Has anyone tried hacking the code to make all excpetions non-
runtime?
Does Hibernate have the same problem?