• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Autocommit in a stateless session bean

 
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ravi,

Look into bean managed transactions and application managed entity managers.

Regards,
Reza
 
Ravi Danum
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 165
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ravi,

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

Cheers,
Reza
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic