-
1. Re: how to catch org.hibernate.StaleObjectException
bigm25 May 9, 2005 2:16 PM (in response to bigm25)Sorry, subject was truncated, so i'm posting the question again, with some clarifications:
Is there a way to know when the EntityManager is internally "discarding" a merge (due to a version conflict), so we could show the user that his last action failed and he should reload???
Right now there's just an exception trace getting logged, but catched internally (not in our code) so we can't catch anything while doing "entityManager.merge(...). -
2. Re:
epbernard May 13, 2005 4:01 AM (in response to bigm25)If the exception is really catched internally, open a bug in JIRA please.
-
3. Re: If you cannot catch a Hibernate exception
pomeloverde Apr 17, 2006 7:25 PM (in response to bigm25)If you are trying to catch a Hibernate exception and you have failed, remember to flush() the Session inside your method:
myMethod() {
try {
...
Session.saveorUpdate(...);
Session.flush();
} catch (StaleObjectException ex) {
...
}
}
If you don't make a explicit call to flush(), then Hibernate will flush the Session automatically, but after your method call ends, so you will cannot trap the exceptions. Normally this is the case when you use Hibernate from the EntityManager.
Best regards