有的话好一点.
既然myeclipse生成了,有它的理由.
myeclipse还卖给很多开发者,能卖的动,说明它的需求是合理的!呵呵

解决方案 »

  1.   

    dao如果有异常,一般都是挺严重的,
    超出了jvm的控制范围.用try catch捕获,反馈异常,也只能做这点了,呵呵
      

  2.   

    spring的异常是运行时异常,不用捕捉,而且spring声明式事务(默认)是不回滚check异常的。The final facet of the transaction pentagon is a set of rules that define what exceptions
    prompt a rollback and which ones do not. By default, transactions are rolled
    back only on runtime exceptions and not on checked exceptions. 
    (This behavior
    is consistent with rollback behavior in EJBs.)所有在做事务处理时要注意下顺便
       
      

  3.   

    那事务不回滚的话,即使捕捉到异常,可能有些操作已经进行了
    不回滚,那就破坏了ACID原则
      

  4.   

    spring默认是发生RuntimeException时回滚,其他的Exception则不会滚,比如IOException
    <tx:method name="get*" read-only="false" rollback-for="IOException"/>
    意思是:RuntimeException及其子异常回滚,IOException回滚,其他异常不回滚可以根据自己的业务需要配置哪些异常需要回滚
    Spring的DataAccessException是运行时异常,无需try catch  或 throw,他会自动抛出
    如果想拦截,只需要在action中catch或者配置异常类,然后统一转向到一个错误页面即可。
      

  5.   


    spring声明式事务有5个属性:
    Rollback rules 这个属性就是指定异常的回滚条件(上面只是说的是缺省的情况下)<tx:attributes>
    <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
    </tx:attributes>
    这样无论什么异常都会回滚