upSystem-level exceptions usually require the transaction to be rolled back. Often the container managing the bean does the rollback. Sometimes the client must roll back the transaction, though, especially if transactions are bean-managed. When an application-level exception occurs, the enterprise bean instance doesn't automatically roll back the client's transaction. The client now has the knowledge and the opportunity to evaluate the error message, take the necessary steps to correct the situation, and recover the transaction. Or the client can abort the transaction.
你说:
--解决的办法:在每次对数据库有操作前,都重新New一个Entity beans的实
--例,这样就可以保证每次的操作都会及时的反映到数据库中。我的问题并不是说操作不能及时反映到数据库中,而是事务不能回滚。
比如我用实体Bean的本地Home接口create两次(在一个事务中),前面的create成功,后面的create失败,于是我将事务回滚,可是前面的的create竟然还是写到数据库里了!我用JTA管理Session Bean里的事务时还跟踪了事务的状态,发现只要我一调用实体Bean的create方法,事务马上不见了!STATUS_NO_TRANSACTION!
deploy descriptor里面要声明!!要不,启动一个事务。但一般不这样做 。
具體的將,EntityBean的多個方法分別執行在自己的Transcation下,如果
某個方法執行過程中出了問題,那也智能回退到該方法執行前的狀態,而
不會影響其他方法執行產生的結果,因此如果你在SessionBean的某個方法
中調用了EntityBean 的多個方法(由不同的Ben instance提供),如果其中
某個方法發生了錯誤,你因該在你的SessionBean的方法中RollBack
具體的我沒有做過,只是喜歡Java,看過一些EJB的資料,如果我的理解錯了
還請包含!!!!!
Session EJB两种都可以。
但是用Weblogic必须用Tx的数据源。