In java persistence with hibernate, gavin suggests that we use business key for equality comparison. Business keys can not only involve multiple field comparisons, but there is no guarantee that the "perfect" business key's semantics will not change in future. We live in non ideal world and business requirements and laws change very frequently. In such case we will be left with data in db stored with multiple business key semantics. I want to break problem into 2 parts 1. When we strictly deal with persistent or detached objects. 2. When we deal with transient objects.
I still don't see any downside on using a surrogate key for equality and hashcode if we are dealing with persistent and detached objects. 2 persistent objects or detached are equals if they same primary key . Is this wrong to assume ?
When we deal with transient objects, we can use the business key semantics to compare objects and have a merge strategy available if you try to persist 2 transient objects with same business key but different values in remainder attribute
In read heavy applications, where most of the transactions are read/update, this strategy should yeild a better performance. As, i am new to hibernate, any suggestions are appreciated.