Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Manually starting transaction  RSS feed

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a remote client, is it possible to start the transaction before calling any EJBs?

For instance, writing junit tests.

setUp(){
ut = getUserTransaction(); //remotely
}

testXXX(){
Connection c = dataSource.getConnection()
// do sql stuffs
// finally
c.close();

// do more EJB stuffs
}

tearDown(){
ut.rollback(); // rolls back both SQL and EJB changes
}

That's what I've written, but WebLogic server claims there is a connection leak. (DB connections are properly managed with try finally statements)
[ October 13, 2006: Message edited by: Chu Tan ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really. Because the Transaction won't go over the wire, and on the server-side they will be making a new transaction(if demarked) and won't use your local one.

I am sure with time you could probably come up with a hack. But for Unit Tests without a container you usually have to stub out the remote stuff.

Mark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!