Re: How do you make JDBC and EJB in same Transaction?
Further pursuing this problem... We thought our problem was fixed but it wasn't really. We changed the isolation level by setting the entity isolation property in the orion-ejb-jar.xml to 'committed'. It appeared to have solved the problem. Perhaps the jdbc driver / database combo we were using had a default isolation that was causing problems. Not sure though. We will run some more tests and will post with the conclusion.
Re: How do you make JDBC and EJB in same Transaction?
Upgrading to 1.5.1 fixed the problem. We no longer have the deadlock in the database. I would still like to know if this was a bug in Orion or if it was a limitation of ejb 1.1 - Eduardo Estefano Integrated Information Systems 480.317.8549
Re: How do you make JDBC and EJB in same Transaction?
Hi, > I have the following in the same method inside a session bean > > 1 - Get a datasource using the EJB Datasource lookup This is the correct way to do it. Are your ejb's using the EJB Datasource lookup? Check in you orion-ejb.xml > What is happening is that the JDBC call is not using the same transaction as > the Entity bean and this is causing a deadlock. The Entity bean call is > waiting on the JDBC statements to be commited. But these statements will not > be commited until the entity bean finishes the delete. I do something similar. I have an session bean that 'Requires' a transaction, and my EJB's are set to 'Supports'. Within that transaction, I do an insert using jdbc, I stuff around with some entity beans, and then I stuff around with the jdbc connection some more. What's even cooler is in another method I process some credit cards, and if this fails we throw the appropriate exception. Effectively the whole transaction gets rolled back. > I thought that since both session bean and entity bean are declared as > REQUIRE for transaction in the ejb-jar.xml that they would automatically be > inside the same transaction. That's correct, so it should work. Just double check that your EJB's and the JDBC are using the same datasource. > Is this a bug or is there something that I am missing? Good luck :) > Eduardo > > -- Adam Cassar Technical Development Manager ___ NetRegistry http://www.netregistry.au.com Tel: +61 2 9641 8609 | Fax: +61 2 9699 6088 PO Box 270 Broadway NSW 2007 Australia
How do you make JDBC and EJB in same Transaction?
I have the following in the same method inside a session bean 1 - Get a datasource using the EJB Datasource lookup 2 - Get a connection using this datasource 3 - Write a JDBC query to delete some rows 4 - Call the remove method in an Entity bean What is happening is that the JDBC call is not using the same transaction as the Entity bean and this is causing a deadlock. The Entity bean call is waiting on the JDBC statements to be commited. But these statements will not be commited until the entity bean finishes the delete. I thought that since both session bean and entity bean are declared as REQUIRE for transaction in the ejb-jar.xml that they would automatically be inside the same transaction. Is this a bug or is there something that I am missing? Eduardo