日期:2014-05-20 浏览次数:20746 次
userMapper userDao=getSession().getMapper(UserMapper.class);
userDao.select();
...
public void doxxxxx(){
TransactionFactory transactionFactory = new JdbcTransactionFactory();
userMapper userDao=getSession().getMapper(UserMapper.class);
Transaction newTransaction=transactionFactory.newTransaction(getSession().getConnection());
try {
userDao.insert(xxx);
userDao.update(xxx);
} catch (Exception e) {
newTransaction.rollback();
e.printStackTrace();
} finally {
newTransaction.close();
}
}
pubic class BaseServiceImp
{
static {
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Transaction newTransaction=transactionFactory.newTransaction(getSession().getConnection());
}
}
public class userServiceImp extends BaseServiceImp
{
public void doxxxxx(){
userMapper userDao=getSession().getMapper(UserMapper.class);
try {
userDao.insert(xxx);
userDao.update(xxx);
} catch (Exception e) {
newTransaction.rollback();
e.printStackTrace();
} finally {
newTransaction.close();
}
}
}