项目中的异常处理2

功能:通过seqno查找记录,可能为空,所以要判断。在try块中抛出的异常可以由catch块抓取。

/**
 * 根據seqno查詢臨時表的待審核記錄
 * 
 * 
@param  seqno
 *            序號
 * 
@param  locale
 *            String
 * 
@return  List
 * 
@throws  BusiException
 
*/
public  List qryBySeqno( long  seqno, String locale)  throws  BusiException {

    ArrayList al 
=   null ;
    
if  (LOG.isDebugEnabled()) {
        LOG.debug(
" [AccountYmService] "
                
+   " [FUNCTION:qryAccountYmData][Param seqno: "   +  seqno
                
+   " ][begin] " );
    }

    EntityManager mgr 
=  initiate();
    AccountYmTempDao ayTempDao 
=  AccountYmTempDao.getInstance(mgr);

    EntityTransaction tx 
=   null ;
    
try  {
        AccountYmVO accountYmVO;
        tx 
=  mgr.beginTransaction();

        List list;
        
try  {
            list 
=  ayTempDao.selectBySeqno(seqno);
        } 
catch  (DbAccessException e) {
            LOG.error(
" [FUNCTION:qryBySeqno()] "   +   " [DbAccessException] " , e);
            tx.rollback();
            
throw   new  BusiException(
                    ExceptionConstant.DATABASE_ACCESS_EXCEPTION, 
"" ,
                    locale, ExceptionConstant.INFO_TYPE);
        }

        
if  (list  !=   null   &&  list.size()  >   0 ) {
            
if  (LOG.isDebugEnabled()) {
                LOG.debug(
" [FUNCTION:qryBySeqno()] "
                        
+   " select list success! " );
            }

            al 
=   new  ArrayList();

            AccountYmTemp accountYmTemp;
            
for  ( int  i  =   0 ; i  <  list.size(); i ++ ) {
                accountYmVO 
=   new  AccountYmVO();
                accountYmTemp 
=  (AccountYmTemp) list.get(i);
                BeanUtils.copyProperties(accountYmVO, accountYmTemp);
                BeanUtils
                        .copyProperties(accountYmVO, accountYmTemp.getId());

                al.add(accountYmVO);
            }

        } 
else  {
            
throw   new  BusiException(
                    ExceptionConstant.NOT_FOUND_SEQNO_IN_TEMP, 
"" , locale,
                    ExceptionConstant.INFO_TYPE);
        }
        tx.commit();
    } 
catch  (InvocationTargetException e) {
        LOG.error(
                
" [FUNCTION:qryBySeqno()] "   +   " [InvocationTargetException] " ,
                e);
        tx.rollback();
        
throw   new  BusiException(
                ExceptionConstant.INVOCATION_TARGET_EXCEPTION, 
"" , locale,
                ExceptionConstant.INFO_TYPE);
    } 
catch  (IllegalAccessException e) {
        LOG
                .error(
" [FUNCTION:qryBySeqno()] "
                        
+   " [IllegalAccessException] " , e);
        tx.rollback();
        
throw   new  BusiException(ExceptionConstant.ILLEGAL_ACCESS_EXCEPTION,
                
"" , locale, ExceptionConstant.INFO_TYPE);
    } 
catch  (BusiException e) {
        
throw  e;
    }
    
return  al;
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值