public void create(final Canal canal) {
        Assert.assertNotNull(canal);
        transactionTemplate.execute(new TransactionCallbackWithoutResult() {

            protected void doInTransactionWithoutResult(TransactionStatus status) {

                try {
                    CanalDO canalDO = modelToDo(canal);
                    canalDO.setId(0L);
                    if (!canalDao.checkUnique(canalDO)) {
                        String exceptionCause = "exist the same repeat canal in the database.";
                        logger.warn("WARN ## " + exceptionCause);
                        throw new RepeatConfigureException(exceptionCause);
                    }
                    canalDao.insert(canalDO);
                    canal.setId(canalDO.getId());
                } catch (RepeatConfigureException rce) {
                    throw rce;
                } catch (Exception e) {
                    logger.error("ERROR ## create canal has an exception!");
                    throw new ManagerException(e);
                }
            }
        });
    }
public void create ( final Canal canal ) { Assert . assertNotNull ( canal ) ; transactionTemplate . execute ( new TransactionCallbackWithoutResult ( ) { protected void doInTransactionWithoutResult ( TransactionStatus status ) { try { CanalDO canalDO = modelToDo ( canal ) ; canalDO . setId ( 0L ) ; if ( ! canalDao . checkUnique ( canalDO ) ) { String exceptionCause = "exist the same repeat canal in the database." ; logger . warn ( "WARN ## " + exceptionCause ) ; throw new RepeatConfigureException ( exceptionCause ) ; } canalDao . insert ( canalDO ) ; canal . setId ( canalDO . getId ( ) ) ; } catch ( RepeatConfigureException rce ) { throw rce ; } catch ( Exception e ) { logger . error ( "ERROR ## create canal has an exception!" ) ; throw new ManagerException ( e ) ; } } } ) ; }
添加