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

Entity Manager and updateExecute  RSS feed

 
Cem Koc
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Krum Bakalsky
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!