From: Karl K. <kk...@se...> - 2001-11-02 19:06:35
|
I am hoping to find a simple resolution to this problem. I am running JBoss 2.4.3 I have a SLSB that is used for persisting business objects implemented as simple java beans. These beans have "alter egos" as Entity Beans in the app server. (in fact, corresponding entity beans are simply facades for a copy of the java bean) The SLSB simply determines which class of Entity Bean to use, find it the instance nessecary, and set the underlying business object to that passed into the SLSB. The problem comes when passing a queue of business objects where later objects depend on side effects of the earlier objects within the database. According to the EJB 2.0 spec "The Bean Provider can control shareability of the connections acquired from the resource manager connection factory. By default, connections to a resource manager are shareable across other enterprise beans in the application that use the same resource in the same transaction context." "The sharing of connections to a resource manager allows the container to optimize the use of connections and enables the container's use of local transaction optimizations." (Section 20.4.1.1) From this I make the assumption (bad word I know) that, under a single (J2EE) transaction context, for the same resource, regardless of which instance of entity bean is being operated on, a connection will be re-used when requested more than once. I am not clear if this applies to multiple entity bean classes, since there references are in a difference namespace, but they do reference the same resource manager underneath everything. The following are snippets from my ejb-jar.xml and jboss.xml files: ejb-jar.xml <resource-ref> <res-ref-name>jdbc/jts.Connection</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Sharable</res-sharing-scope> </resource-ref> jboss.xml <resource-ref> <res-ref-name>jdbc/jts.Connection</res-ref-name> <resource-name>jts.sempraDev</resource-name> </resource-ref> <resource-manager res-class="org.jboss.ejb.deployment.JDBCResource"> <res-name>jts.sempraDev</res-name> <res-jndi-name>java:/jts.sempraDev</res-jndi-name> </resource-manager> All of my beans have a trans-attribute of Required for all methods that affect the state of objects and a default of Supports for everything else. What appears to be happening is that there is no guaruntee that the same db connection will be used throughout the context of a single transaction, even within the same entity bean class. This is causing changes to be performed under one db transaction and subsequent changes that depend on the db side effects of the earlier changes to be performed under a seperate db transaction. The subsequent db transactions cannot see the earlier changes to the db and fail, rolling back the entire set of db transactions. When the business objects are submitted one at a time from the client everything works fine. It is only when a queue of business objects are submitted that the problem exists. From what I have understood about JBoss, this part of the EJB 2.0 specification has been in place for some timel. Correct me if I am wrong. Any help/clarification would be appreciated. Karl Koster kk...@se... Sempra Energy Trading 203-355-5182 ********************************************************************** This e-mail contains privileged attorney-client communications and/or confidential information, and is only for the use by the intended recipient. Receipt by an unintended recipient does not constitute a waiver of any applicable privilege." Reading, disclosure, discussion, dissemination, distribution or copying of this information by anyone other than the intended recipient or his or her employees or agents is strictly prohibited. If you have received this communication in error, please immediately notify us and delete the original material from your computer." Sempra Energy Trading Corp. (SET) is not the same company as SDG&E or SoCalGas, the utilities owned by SET's parent company. SET is not regulated by the California Public Utilities Commission and you do not have to buy SET's products and services to continue to receive quality regulated service from the utilities." ********************************************************************** |