This is probably an easy one but here goes. Say I have a bean in a tranaction. From that bean I call a regular vanilla java class that is located in the classpath and resides in the same jvm as the ejb container. From this java class I perform some functioning and eventually receive a connection to the DB from the JNDI tree and call a stored proc that is suppose to create a record in the db. Now suppose that after the call to the DB from the java class but within the same tranaction on the same call stack an exception of some sort occurs. Will new record be in the data base or not?
To sum up, do all points of access to the database in a J2EE application need to be ejbs?
Additionally while I'm here I just had another question pop into mind. Again the same ejb running in an transaction writes to a file on the file system. An error occurs after the write, what happens to the file.
What's a good resource on tranactions with ejb to read?
Thanks,
Matt
-
EJB Transaction Management (3 messages)
- Posted by: Matthew Cox
- Posted on: May 18 2001 11:08 EDT
Threaded Messages (3)
- EJB Transaction Management by Vijay Challa on May 18 2001 15:59 EDT
- EJB Transaction Management by qing yan on May 19 2001 19:27 EDT
- EJB Transaction Management by Robert Baty on May 21 2001 17:18 EDT
-
EJB Transaction Management[ Go to top ]
- Posted by: Vijay Challa
- Posted on: May 18 2001 15:59 EDT
- in response to Matthew Cox
As far as my knowledge goes, a transaction context is not propogated to non-ejb objects running in a container. Therefore, if you have to use transactions within ur java classes u have to lookup for a UserTransaction and then proceed along.
Now, to answer your question since a problem occurred when the database was being updated, it would never be updated, but in a case where the EJB is updating some data and then the java class is doing some further updates, and if the failure occurs when the java class is updating...the data updated by the EJB will be there and not so for the java class. This is because the same transaction context is not being propogated.
Coming to the points of access to a database, sure u need EJBs when u want to use transactions...but in case u dont need any transaction but want to just do with some selects, a java class can do the job for you. -
EJB Transaction Management[ Go to top ]
- Posted by: qing yan
- Posted on: May 19 2001 19:27 EDT
- in response to Matthew Cox
do all points of access to the database in a J2EE >application need to be ejbs?
Not necessary, transaction context is associated with the
thread.
>transaction writes to a file on the file system. An error
File IO is not transactional. -
EJB Transaction Management[ Go to top ]
- Posted by: Robert Baty
- Posted on: May 21 2001 17:18 EDT
- in response to Matthew Cox
To sum up, do all points of access to the database in a J2EE application need to be ejbs?
No, using a J2EE application you can access a database through RSPs or direct JDBC. When invoking a Legacy RSP a messaging protocol such as JMS or MQSeries is very effective.
rjb