Spring did not supply any integration for MyBatis, so we are developping some integration mechanism.
If you don't plan to use Spring or Guice, then I would create the SqlSession instance in my service class and pass it to DAO as a parameter. Since the DAO did not create the SqlSession instance, the DAO should never call commit or rollback. It's the service's job!
Christian
-----Original Message-----
From: mybati...@googlegroups.com [mailto:mybati...@googlegroups.com] On Behalf Of Simon
Sent: Monday, August 16, 2010 9:29 AM
To: mybatis-user
Subject: Re: will nested sessions work? I.e. will a child session commit be auto-ignored?
Class<? extends Provider<TransactionFactory>> txFactoryProviderClass = [...];
1) a small working example can be found on the test[1] source code, it
will show you how to configure the module. PS don't take this code as
the absolute reference, you could load configurations from properties
file as well
2) AbstractTransactionalDao implementations are multi-threaded-safety
classes, you can reuse the same singleton instance to serve all the
requests.
IMHO MyBatis is a killer framework because doesn't require any
dependency at all; the Guice integration was thought to satisfy Guice
users (including myself :P ) to fill the missing integration between
both framework.
Feel free to ask more questions for every aspect is not clear!
All the best, good luck!
Simo
[1] http://code.google.com/p/ibaguice/source/browse/tags/1.0/samples/src/main/java/com/googlecode/ibaguice/samples/AbstractContactDao.java
[2] http://code.google.com/p/ibaguice/source/browse/tags/1.0/core/src/main/java/com/googlecode/ibaguice/core/dao/AbstractTransactionalDao.java
http://people.apache.org/~simonetripodi/
http://www.99soft.org/
DAO's are dead. Part of the rewrite of MyBatis was to get rid of the
idea of a DAO and our old DAO framework. A mapper is really your dao.
DAO's when used should be a single unit of work. If you find yourself
calling one from the other you have done something wrong and rethink
it. If it is hard to unit test rethink it :)
Use a service layer class when you need to combine multiple units of
work together. Given your example I would create a AccountService
class that would use both the AccountMapper and the PlayerMapper.
Hand the transaction there.
DI is your friend. USE IT
Nathan
Christian
-----Original Message-----
From: mybati...@googlegroups.com [mailto:mybati...@googlegroups.com] On Behalf Of Nathan Maves
Sent: Monday, August 16, 2010 6:40 PM
To: mybati...@googlegroups.com
Subject: Re: will nested sessions work? I.e. will a child session commit be auto-ignored?
http://people.apache.org/~simonetripodi/
http://www.99soft.org/