473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

TransactionScope Class - Is there an equivalent in JAVA?

JT
In .NET I have been using the TransactionScope class to wrap my unit tests
into a transaction and roll back any database changes after I have completed
my unit test. Now I am dealing with some JAVA developers and looking for a
similar way for them to be able to do this from their JAVA code and not at
the database level. Is there and equivalent to this in JAVA? Thanks.
Nov 2 '07 #1
4 3480
JT <JT@hotmail.comwrote:
In .NET I have been using the TransactionScope class to wrap my unit tests
into a transaction and roll back any database changes after I have completed
my unit test. Now I am dealing with some JAVA developers and looking for a
similar way for them to be able to do this from their JAVA code and not at
the database level. Is there and equivalent to this in JAVA? Thanks.
There are various transaction types available in Java (only the stock
ticker is capitalized btw). It depends on which framework you're using.
For instance, Spring provides its own transaction scoping objects, as
does J2EE IIRC.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 2 '07 #2
JT
They want to use EJB3 which I do not know anything about. Thanks.
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
JT <JT@hotmail.comwrote:
>In .NET I have been using the TransactionScope class to wrap my unit
tests
into a transaction and roll back any database changes after I have
completed
my unit test. Now I am dealing with some JAVA developers and looking for
a
similar way for them to be able to do this from their JAVA code and not
at
the database level. Is there and equivalent to this in JAVA? Thanks.

There are various transaction types available in Java (only the stock
ticker is capitalized btw). It depends on which framework you're using.
For instance, Spring provides its own transaction scoping objects, as
does J2EE IIRC.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Nov 2 '07 #3
JT <JT@hotmail.comwrote:
They want to use EJB3 which I do not know anything about. Thanks.
Okay - there's certainly the concept of transaction scopes within EJB3,
although I can't remember the details. If you show them your .NET code
and explain what it does, they should be able to do a similar thing in
Java.

Personally I don't do that though - I create appropriate conditions in
the unit test database at the start of each test, but don't remove
anything at the end. Each test needs to be able to set itself up
completely. This is less efficient, but does have the advantage that if
a test fails, you can see the state of the database at the point of
failure. It also means you can test code which *does* commit
transactions :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 2 '07 #4
Jon Skeet [C# MVP] wrote:
JT <JT@hotmail.comwrote:
>They want to use EJB3 which I do not know anything about. Thanks.

Okay - there's certainly the concept of transaction scopes within EJB3,
although I can't remember the details.
EJB certainly has transactions support, but EJB transactions
stuff (except for BMT) are much more like the stuff in
System.EnterpriseServices.

Arne

Nov 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Neil Zanella | last post by:
Hello, I would like to know whether it is possible to define static class methods and data members in Python (similar to the way it can be done in C++ or Java). These do not seem to be mentioned...
4
by: Rick_Kierner | last post by:
I am attempting to use the TransactionScope class to manage my transactions. I am running into an issue. My web server is in an NT work group. My SQL Server is in a domain. When my code...
0
by: ste | last post by:
Please bear with this post.. its abit long winded.. but i thought it was important to describe what i am trying to achieve before i ask the questions (at the bottom) Thanks.....in advance ...
6
by: Mukesh | last post by:
Hi, I am new to 2.0 framework. I am trying to use TransactionScope in the following code. I took four lables. Started TransactionScope scope. After setting values to three labels I throw an...
3
by: kikapu | last post by:
Hi to all folks, i am trying to understand the use of System.Transactions in general and TransactionScope particularly. What am i allowed to do in a using statement that wraps a...
4
by: hardieca | last post by:
Hi, I'd really like to use TransactionScope within the Business Layer of my web application. A book I'm reading makes a note that it should not be used in a shared web hosting environment...
0
by: RP | last post by:
I have a two classes, first named "ModCon" has procedures written for connections and the second named "ModRes" contains functions and procedures that can be reused. For my question it is important...
3
by: Aleksey Timonin | last post by:
Hi guys, I tried to use TransactionScope on to defferent TableAdapters like this: using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required)) {...
3
by: Michael Schöller | last post by:
Hello, First of all english is not my natural language so please fogive me some bad mistakes in gramatic and use of some vocables :). I have a great problem here. Well I will not use it...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.