业务逻辑层JDBC模板代码(没有使用manager代理类)

 private FlowCardDao flowCardDao;  

public FlowCardManagerImpl() {  
        super();  
        this.flowCardDao = (FlowCardDao) BeanFactory.getInstance().getDaoObject(FlowCardDao.class);  
    }  
@Override
	public void addFlowCard(FlowCardMaster flowCardMaster)
			throws ApplicationException {
    // 设置手动提交事务
		ConnectionManager.manualCommitTransaction();
		
		// 添加 流向单
		try {
			String flowCardNO = flowCardDao.generateVouNO();
			flowCardDao.addFlowCardMaster(flowCardNO, flowCardMaster);
			flowCardDao.addFlowCardDetail(flowCardNO,
					flowCardMaster.getFlowCardDetails());
			
			// 添加成功,提交事务
			ConnectionManager.commitTransaction();
			
			// 调用dao层发生异常(DaoException), 事务回滚
		} catch (DaoException e) {
			e.printStackTrace();
			ConnectionManager.rollbackTransaction();
			throw new ApplicationException("添加流向单失败!");
			
			// 最终重置事务,关闭 connection
		} finally {
			ConnectionManager.resetConnection();
			ConnectionManager.closeConnection();
		}
} 

 
阅读更多
文章标签: manager jdbc dao string
个人分类: Manager
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭