I've been reading through the forums, but didn't find anything related to the issue I would like to discuss...
In my application, which uses Hibernate 2.1.7, there are several ocassions where I need to save only the subset of a class. For example, imagine I have a User class, where apart from the usual data as name, address, etc., I have some fields with extra information about last date access, last IP used, etc.
This brings two possibilities for updating:
1) Only extra fields need to be updated, as a matter of some kind of auditing for example.
2) Only the "usual" fields need to be updated, as a matter of any user updating his profile (User class), for example.
So the problem I'm facing is about two different partial updates of the User object. I've been reading the documentation and the forums, but only found a post which suggests that a custom persister should be implemented. On the other way, maybe the use of Hibernate 3 and <sql-update> new feature could help, but I don't know if several different updates can be defined.
Can anyone please help me in this issue? I know Hibernate as an ORM is row-based, but in my opinion my post is a common issue in any web application, as always web forms do not have the complete information for the object, don't they?
Or maybe I have to load previously the object being updated, copy the properties that have been changed in my web form and then persist it again, everything in the same session... But isn't this a heavy approach with a lot of work?
Looking forward to hearing your comments ;-)
|