From: Gavin_King/Cirrus%<CI...@ci...> - 2002-08-22 04:55:44
|
Currently Hibernate treats Dates, Times and Timestamps as immutable types. In fact, java.util.Date has a single non-deprecated mutator method, setTime (). My understanding of common Java usage is that this method is rarely, if ever, used. There are fairly good performance reasons for continuing to treat dates/times as immutable; if we had to copy them each time we took a snapshot then we would also need to create two new java.util.Calendars each time we compared them (rather than using ==). Creating three objects (four including the Timezone) per date property per flush is an overhead I would rather avoid. I mean, its not going to bring the system to a halt but its still undesirable. If anyone uses setTime() commonly, or knows of a reason why it is useful, please let me know so I can change this implementation (or at least make it configurable). So far I don't know of anyone being tripped up by this which kinda confirms my impression that setTime() is not really useful... At the very least I need to document this particular "gotcha". Gavin |