Jan 16th, 2007, 12:04 PM
ObjectNotFoundException on migration from spring 1.2.8 to 2.0.2
Hi. My web application works fine with spring 1.2.8 and hibernate 3.1.3.
When I upgrade to spring 2.0.2 and hibernate 3.2.1.ga (just update jars with maven2), I got ObjectNotFoundException when i load profile object after update it.
Profile class has one-to-many relationship with Permission class. The database is updated right, but hibernate throws exception about permission of the profile when i try to load profile from database!
What is wrong? I look forward your answer and thanks in advance!
obs. iīm using ehcache
Jan 16th, 2007, 03:38 PM
Its hard to know what the problem is without seeing the stacktrace.
Jan 17th, 2007, 08:54 AM
Follows the stacktrace and pojos and hbms.
Jan 17th, 2007, 10:14 AM
I would have thought this is related to Hibernate rather than Spring. The exception says it can't find a specific item in the database e.g. Permission 735. I know it might be a stupid question, but does this item actually exist?
Jan 17th, 2007, 12:55 PM
When hibernate update profile object, old permissions are deleted and new permissions are created at the database. It seems cache problem, because when i try to load the profile again, hibernate try to load old permissions, thatīs the error ObjectNotFoundException.
When i restart the application, updated profile object references new permissions and hibernate loads ok!
I didnīt change any code, just hibernate and springframework jars!
Jan 17th, 2007, 02:48 PM
I would first turn caching off, just to take that out of the equation. Is it possible to see the code that is causing the error? It would be good if you could give me a step-by-step description of how you get the error, or a test case.
Jan 22nd, 2007, 07:56 AM
I turn caching off and it works! Well, now we know where the problem is with caching!
Let me post a stey-by-step description when the cache is on:
1 - using the web app (myfaces + spring + hibernate), I access the page to update a profile bean. I set new permissions and submit the page. It works ok and the profile bean has new permissions (profile table and permission table are updated ok).
2 - i access another page to list profile. the page reloads all profiles, including the updated profile. Here, there is no problem because the permissions are not loaded yet.
3 - when i try to access the profile view page, the error occurs!
Iīm posting the code of remaining classes and spring transaction configuration. I cut the classes and xml because upload size file limit, but the method name are preserved!
Is there any new cache parameter to set or any new behaviour?
Thanks in advance!
Jan 31st, 2007, 07:31 AM
The problem is with hibernate 3.2.1ga !!!
I tested with hibernate 3.2.0ga and hibernate 3.2.2 ga (recently released) and it works!
There was no problem with spring! I could upgrade fine!
Thanks in advance!
Jan 31st, 2007, 07:33 AM
Mmmmm interesting. Did you find a bug report that pointed you to this solution, or did you just try it?
Jan 31st, 2007, 07:45 AM
Just some tries:
I tried to upgrade spring 1.2.8 to 2.0.2 first. It worked!
After, I tried to upgrade hibernate 3.1.3 to 3.2.0.ga and it worked too! When I tried to upgrade to 3.2.1.ga, it failed. Today, when i visited hibernate home page, i saw 3.2.2.ga release (not at maven repository yet!). I downloaded it, tested and it worked!