views:

147

answers:

1

I know Hibernate calls setters when you lookup a bean.

But I recently noticed the setter was being called by Hibernate when we we were not doing any lookups. We had created our POJO's and then called save. Why would Hibernate call setters in this case?


Update: The setter call seems to be happening when we are actually calling delete() on a Hibernate entity. Why does Hibernate call the setter in this case?

+1  A: 

As far as I was aware, it should not.

Hibernate will call the setter for any generated fields, such as any generated IDs. Perhaps they extended this to cover all fields in case a field is updated by a trigger during the save or some such edge case.

Geoff