Can anybody explain me how to know if any java object gets updated/re-loaded.
Consider if i have java object which will be loaded only if it meets certain conditions. and i need to check if that object is actually updated or not.
@Ilias: Loaded from where? In any case, one of the easiest ways to detect changes would be to compute a hash code, store it, and check against it later. This, of course, depends on having a good hash function, and may not always be appropriate. You could also instrument getters/setters to set a "modified" flag if their values actually cause a change--there are a number of ways this could be implemented.
I'm not sure how Hibernate determines dirtiness, but you could look into that and see what their implementation does.
David Newton wrote:
@Ilias: Loaded from where? In any case, one of the easiest ways to detect changes would be to compute a hash code, store it, and check against it later. This, of course, depends on having a good hash function, and may not always be appropriate. You could also instrument getters/setters to set a "modified" flag if their values actually cause a change--there are a number of ways this could be implemented.
I'm not sure how Hibernate determines dirtiness, but you could look into that and see what their implementation does.
I have written code that will load the property file, which will load only time stamp of previous instance differs with current one. I want to know if the object has got updated of the said class or not.