对于事务处理,我的印象中是在配置文件中设置的,可设为bean type,即你自己在bean里面控制,另外也可设为container type,即容器自动管理,一般都会设成container type(你可以好好看一下配置文件),你在程序里不用管。

解决方案 »

  1.   

    顺便补充一句:事务管理配置起来会有点复杂,特别对于entity Bean,2.0支持nest Transcation和多种transction type。这方面要肯多实践,多专研才有收获,听别人讲怎么也不会完全明白的。
    给个配置的大概样子:
    <assembly-descriptor>
    <!--
    This demonstrates setting a transaction attribute
    on every method on the bean class.
    -->
    <container-transaction>
    <method>
    <ejb-name>Employee</ejb-name>
    <method-name>*</method-name>
    </method>
    <!--
    Transaction attribute. Can be "NotSupported",
    "Supports", "Required", "RequiresNew",
    "Mandatory", or "Never".
    -->
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <!--
    You can also set transaction attributes on individual methods.
    -->
    <container-transaction>
    <method>
    <ejb-name>Employee</ejb-name>
    <method-name>setName</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <!--
    You can even set different transaction attributes on
    methods with the same name that take different parameters.
    -->
    <container-transaction>
    <method>
    <ejb-name>Employee</ejb-name>
    <method-name>setName</method-name>
    <method-param>String</method-param>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
      

  2.   

    这个我知道,我的意思是:
    begintran 
    save 1 //ok 主表
    save 2 //errro rollback 明细
    save 3  //明细
    commit tran这种情况下的,该如何使用bean(CMP2.0)来实现?
      

  3.   

    如果实在有问题,你不如通过session bean 来调用entity bean,transction起在session里面应该没问题吧.
      

  4.   

    是起在session bean 里面.写错了
      

  5.   

    entity bean里面只能用cmt
    想用bmt应该在session bean里面用
      

  6.   

    写一个entity 在写一个session,我的意思,可不可以用cmp的功能达到,自动的目的?
      

  7.   

    当然可以用CMP了~如果单纯的EntityBean就只能用CMP.