Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Error Deleting Persisted Objects: Hibernate/MySQL

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sirs et Madames,
I have some java code which is trying to delete a list of users. However I get an error which I have yet to work out what it means, am hoping someone can shed some light? I have java code as follows:



The server log seems to point at line 37 on my IDE which is the line on here. Here is the error log:




Thanking you kindly in advance, I hope the details I have given above are enough (and hopefully not overkill with the error log...)

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This belongs in the ORM forum. Try setting the batch_size to 0.
 
Sheriff
Posts: 21941
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

David Newton wrote:This belongs in the ORM forum.


And that's where it's going right now.
 
Phoenix Kilimba
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry guys for posting in the wrong section. Thanks for moving it for me. David, where do I set batch_size = 0? hibernate config file? Plus I love to know how to solve the problem, but would be really satisfying to know why, it helps me figure out things better when I know why. What does batch_size = 0 do?

Thanks again,
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Phoenix Kilimba wrote:



This should ring some bells.
It seems your application is not able to obtain a lock on the row(to be deleted) because some other transaction is already locking it...or not committing it..

This could be because of various factors, the most common of them being using some Oracle Clients and not committing the transactions there.

Do you happen to have any other Oracle Client(like SQLPlus, TOAD etc)/application and you have done some update on the same row/table and not committed there.

If this is the case, issue "commit" or "rollback" command there.
 
Phoenix Kilimba
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Do you happen to have any other Oracle Client(like SQLPlus, TOAD etc)/application and you have done some update on the same row/table and not committed there.



No I haven't... Still not sure what could have caused it.
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Are you getting the same message in the exception("Lock wait timeout exceeded; try restarting transaction")

If you are, i can suggest you two changes

1) delete only one record in each Transaction. For this you will need to 'start the transaction' in the for loop, and 'commit' the transaction after session.delete(userEntity).
Most probably, it should work.

2. If it does not, try to find out the locks that have been caused in your Database. If your DB is Oracle, you can use the query at Oracle Locks query.

Let me know what is the result.
 
Phoenix Kilimba
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rahul will try that. My db is MySQL by the way... if that makes a difference
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, i am not aware of how to find the locks in MySQL.
Hopefully, putting the two 'delete's in different Transactions might do the trick(although i am not very sure why)
 
Everybody's invited. Even this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic