Error Deleting Persisted Objects: Hibernate/MySQL
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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...)
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...)
You are what you know
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
This belongs in the ORM forum. Try setting the batch_size to 0.
posted 16 years ago
And that's where it's going right now.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
David Newton wrote:This belongs in the ORM forum.
And that's where it's going right now.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Phoenix Kilimba
Ranch Hand
Posts: 64
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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,
Thanks again,
You are what you know
posted 16 years ago
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.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
Rahul Babbar
Phoenix Kilimba
Ranch Hand
Posts: 64
posted 16 years ago
No I haven't... Still not sure what could have caused it.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
You are what you know
Rahul Babbar
Ranch Hand
Posts: 210
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
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.
Rahul Babbar
Phoenix Kilimba
Ranch Hand
Posts: 64
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks Rahul will try that. My db is MySQL by the way... if that makes a difference
You are what you know
Rahul Babbar
Ranch Hand
Posts: 210
posted 16 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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)
Hopefully, putting the two 'delete's in different Transactions might do the trick(although i am not very sure why)
Rahul Babbar
| I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |









