Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Autocommit in a stateless session bean  RSS feed

 
Ravi Danum
Ranch Hand
Posts: 154
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

How can I turn on autocommit in a stateless session bean. I'm using toplink JPA.

Thanks for any help.

Ravi
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi,

Look into bean managed transactions and application managed entity managers.

Regards,
Reza
 
Ravi Danum
Ranch Hand
Posts: 154
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using Toplink JPA. I don't see a way through the EntityManager or the EntityTransaction to set autocommit on or off. I am wondering if I need to resort to writing JDBC in a bean managed session bean.

Your comments are greatly appreciated.

Ravi
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi,

You are right, you can't auto-commit with JPA, but you can use local transactions.

What are you trying to accomplish? Why is auto-commit important? If you are looking for reduced code, JTA/CMT is a better option? Are you worried about JTA overhead? If so, belive me, it's very trivial compared to the other sources of performnace problems that you ca get from the persistence tier...

Regards,
Reza
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi,

What are you trying to accomplish with auto-commit? It's generally not a good practice in a distributed application. I can understand if you are worried about overhead with JTA (although that's very minor too), BMT will let you use local transactions...

Regards,
Reza
 
Ravi Danum
Ranch Hand
Posts: 154
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Reza,

It was suggested in a design meeting that I use autocommit instead of the transaction handling supplied by the container.

If you say the overhead of starting and ending a transaction using the container managed, I may just stick with container managed. Otherwise, its like fitting a square peg in a round hole.

I only want to insert one record into a table. That's it. Since it was only one step, autocommit was suggested.

Thanks so much for help. It is greatly appreciated.

Ravi


 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi,

No problem...I honestly think the auto-commit route is a dead-end.

Cheers,
Reza
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!