Now there's the concise explanation I was looking for!
The discussion on the Hibernate forums is pretty confusing in this respect,
mostly because there seem to be a lot of people who object to the idea of
using 'natural keys'... Personally, I don't blame them, but if that's the
way Hibernate works then it should be easy enough to implement.
I've already done this with the relevant object for my PropertySelection and
it does, indeed, work like a charm.
Thanks much,
-Jason
On Thursday 12 January 2006 00:44, Richard Clark wrote:
> Hibernate does not guarantee the same object will be returned when
> you get the same record out of the database twice. You will get the
> same object if retrieved twice in the same session because the first
> object is placed into the session cache and Hibernate looks in the
> cache before creating a new object.
>
> The Hibernate documentation recommends overriding equals() (and
> hashCode(), of course) to determine equality. (Ch. 24 of the
> Hibernate 3 manual: "Identify natural keys for all entities, and map
> them using <natural-id>. Implement equals() and hashCode() to compare
> the properties that make up the natural key.") There are folks in the
> user community who believe you should just compare on the database
> ID, though the documentation (and Hibernate In Action) recommends
> against that.
>
> As a stopgap, you may want to mark your classes for caching (in
> EHCache); this cache will get checked before instantiating an object.
>
> ...Richard
>
--
Emperor Palpatine:
Soon the Rebellion will be crushed and young Skywalker
will be one of us!
--------------
Jason Dyer
BlueTarp Financial, inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]