|
From: Timo V. <sic...@gm...> - 2003-08-08 08:41:41
|
Hi all!
I think I finally have a solution to the hashCode/equals problems!
In every table I have a field/property named "created" of type datetime,
which may not be null. My domain objects hence all have a "created"
property, which is initialized with the current time on instantiation
("new java.util.Date()"). Other applications using the database
directly MUST supply values for "created" (be they bogus or not).
"created" may not be altered once set, which could even be enforced
with the use of triggers/permissions on the DB side and a private
setCreated() method on the Java side.
Now I "calculate" hashCode() based on the "created" property (invoke
getCreated().hashCode()) and equals() still based on ID.
This should solve all problems issued before!
Opinions? Have I missed anything?
Regards,
Timo
|