功能:通过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;
}
* 根據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;
}