Using the above code even if I do not change ANYTHING in the object it will execute the following sql code:
Code:
Hibernate: update marketingProspect set version=?, assets=?, assignedRep=?, attentionPriority=?, customerId=?, federal=?, lastActivityDate=?, lastActivityType=?, members=?, name=?, ncuaId=?, nextActivityDate=?, nextActivityType=?, note=?, phone=?, website=?, salesRegion=? where id=? and version=?
Hibernate: update marketingActivity set version=?, date=?, description=?, activityType_id=?, prospect_id=? where id=? and version=?
Hibernate: update marketingActivity set version=?, date=?, description=?, activityType_id=?, prospect_id=? where id=? and version=?
Hibernate: update marketingActivity set version=?, date=?, description=?, activityType_id=?, prospect_id=? where id=? and version=?
Am I calling something incorrectly in my code that is forcing it to update even if nothing has changed?
I guess the underlying problem is this: I load my object from a session, then the session gets closed, the object gets passed through an html form and either modified or left alone, then I open a new session and have no way to tell if that object has been changed or not, so I call saveOrUpdate() on it. And it is currently disassociated with any session, but it still contains its ID value so Hibernate knows that it has been previously saved, but I think it is forcing an update on the DB even if it hasnt been modifed. Is there someway to re-associate it with the persistance layer without hibernate loading values into the object? I just don't want my changes to be overwritten before they get persisted to the db. Did that make any sense? :)
Thanks,
David