• 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

Entity Manager and updateExecute

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to insert in my MySQL backended application some entities. But I do not want to utilize transaction. When I tried to use my code at below, it throws exception about executeUpdate should be bounded in a transaction.




I could not figure out how to add in a non-transactional context. How can I insert?

Thanks
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JPA 1.0 specification says that the executeUpdate() method of the Query API must be executed within a transaction (a JTA or a resource-local one).
Otherwise an exception is thrown.

Using transactions in a critical part of the whole JPA 1.0 design. You cannot make database insertions without a transaction, even if you use simple EntityManager.persist() invocations, instead of executing queries.

Just because of curiosity, have you ever succeeded to make database insertions from a Java code, without transactions ? I could hardly believe that this is possible.
 
Cem Koc
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Krum Bakalsky wrote:The JPA 1.0 specification says that the executeUpdate() method of the Query API must be executed within a transaction (a JTA or a resource-local one).
Otherwise an exception is thrown.

Using transactions in a critical part of the whole JPA 1.0 design. You cannot make database insertions without a transaction, even if you use simple EntityManager.persist() invocations, instead of executing queries.

Just because of curiosity, have you ever succeeded to make database insertions from a Java code, without transactions ? I could hardly believe that this is possible.



Hi,

I had also tried as you specified persist before, however the result was as you described.

My application is a part of one big monolithic ejb application. However my insertion codes raises a substantial number of duplicate entry exceptions in our master-master mysql database model. At first I thought this could be related to our transactions system and in order to get rid off those exceptions I intuitively tried to remove transaction parts from our application.

By the way I could not understand the point about insertion from java code part in your comment. Does this mean that jdbc based insertions or instead of utilizing container managed transactions, using something else?

thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic