• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Standard JPA and dead locks

 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My app is using Struts2 + Spring + JPA (Standard). Currently the struts actions access service classes which return entities. All my service classes have Spring's @Transactional annotation on them. When more than one person uses the app lots of dead lock conflicts occur. This is really not cool.

I have tried changing the isolation levels for the transaction but I get an error saying that Standard JPA does not allow custom settings of isolation levels.

I have tried removing the annotation, which I really don't need but the quickstart app I based this one off of had it so I continued with it. Removing the annotation generated errors.

I tried removing the Spring bean for the transation manager. Surprise!... errors.

I don't really need transactions on these service classes. But I have not been able to find an alternative annotation. How is this supposed to be done in Standard JPA?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like your database is defaulting to a serializable transaction isolation level, as you have noticed this is not good. You best solution is most likely to change you database transaction isolation default on your database (consult your database documentation or DBA). You may also be able to configure the default transaction isolation in your data-source configuration (in Spring or your JEE server if you are using one).

Otherwise what JPA implementation are you using? JPA does provide a <non-jta-data-source> element in the persistence.xml, on some JPA implementations, this may help. Some JPA implementations also provide a way to set the transaction isolation level.
 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah. I am using OpenJPA. I was not able to find any way to set it. Also, the way this is set up persistance.xml is not used.

I ran out of time looking for a solution, so I just slapped synchronize on to the methods and called it good for now. This is not a high traffic app, so that will hold for now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic