Hello,
I have a suggestion for a possible new feature of Hibernate that
I think is integratable with the current system architecture, is not
that "large" of a change but that would require small changes to
several different files/documents.
I propose a new value for the "sort" tag:
<set
sort = "unsorted" | "natural" | className | "use_current"
/>
During the creation of a new persistent object, the
sort value is used to assign a comparator in the construction
of the new SortedSet. For a statically assigned comparator
the previously created instance is retrieved; for the natural
ordering no comparator is used, as is currently done. In
the case of the "use_current" option, the set object can
return its comparator, which can then be used to create
the new persistent SortedSet. For retrieval from the database,
the containing class table would need an extra column
containing the name of the comparator class -- this would
allow an entity to contain multiple sets each with a different
comparator. For consistency with the current architecture,
I'm not sure if this extra column has many other implications.
It seems as though the comparator-name column could be
populated at the same time that the set is populated, without
affecting much other code.
I would love to make a patch and give a demonstration,
but it will take a while because I don't currently have very
much free time -- I'm posting this here because I think more
comments on the feasibility and the architectural implications
are necessary and because perhaps someone else who is
interested in this sort of support may have a lot more
free time than me. *smile*. I hope that the comments I
do get on this proposal help me better design a planned
patch.
Thanks for your time,
Jennifer Bevan
|