how to catch staleobjectexception?
In my application I am trying to flush a transaction and tries to call same method in dao layer twice in a span of half a second. I am getting staleobjectexception. I am unable to catch above mentioned exception. Please advise
You can always catch an exception. The only reason you wouldn’t be able to catch it is if it’s not thrown inside your try/catch. You’re probably putting the try/catch around some persistence operations, expecting it to be thrown there, when persistence exceptions don’t actually happen until the transaction is committed. You’ll need to find where the transaction commits and make sure to put your try/catch around that. You can use the exception stacktrac to trace back to where it’s thrown from.