Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.hibernate.exception.ConstraintViolationException: could not execute JDBC batch update

 
Charles James
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a composition of entities A composing B composing C . When I use jpa/hibernate in a single thread they go in fine but when I use mutiple threads I get the exception in the subject.

I think the cause is hibernate is generating insert statements as opposed to update statements

and

putting them in the same JDBC update.

Any suggestions around this issue with some open source package which might be able to detect this.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are your multiple threads all using the same Hibernate transaction?
 
Charles James
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure since I am not sure what apache camel is doing on each jpa endpoint ? Will try finding out

But why would that be an issue. I think the issue is that threads which have a cloned copy of the pojo and while subsequent jpa/hibernate calls are supposed to generate update stmts, they are generating inserts
 
Charles James
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the pojo is pulled by a seperate thread with newer inputs it is committed in a seperate transaction ( all managed by camel ) .

Was wondering if the next time the same pojo with same primary key hits the endpoint then it should generate update stmts as opposed to insert stmts ....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic