posted 15 years ago
Hi there,
This might be a really stupid questions, but its getting late here and I'm probably missing something obvious. I'm pretty new to hibernate, but the speed with which I've got my new webapp going is frightening - maybe that's the problem - I'm skipping along without getting all the details.
I'm writing a fairly simple MVC webapp. User logs in, user object retrieved from database and stored in HttpSession object. First page of app displays a list of activities stored in user object contains list of activities.
Functionality I've written currently happily adds a new activity directly to the database with a foreign key back to the logged in user.
However whenever I access the user object from HttpSession object, it's collection of activities never includes newly added activities. If I restart the app, or kill my session and log in again, the user object happily lists all the original + new activities.
Am I missing something hibernatey, or is the a fatal flaw in the design of my app?
I'm not actively putting the activity object into the collection of activities in the existing user object and then saving that. Instead, I'm creating a new activity, and adding the user object to it. Is that my problem? Should I be updating the user, rather than directly adding the activity?
After a quick google, I tried adding session.refresh to the end of the saveOrUpdate method of my GenericDAO, but that's done nothing.
Any help for a frazzled brain?