Preface this by saying I'm new to Hibernate, but I've been reading everything I can get my hands on for the last month and solving problems as they come up in my coding efforts. Read thru chapter 5 on Hibernate in Action so far. :) BTW, very well written Christian/Gavin.
Anyway, I'm working on a newer version of our persistence layer that uses Hibernate (we've custom DAO framework currently). One thing I've not been able to solve has to do with mapping our existing POJOs which make extensive use of List properties for relations. <set> does not work as these are List properties. And I cannot use <list> because our tables do not have an indexed property.
Changing the POJOs to use Set is _not_ an option at this point. That would be a massive undertaking in many parts of our application. Just do not have the time or man power to do it.
What I'd like would be to use <set> in the .hbm, but have the implementation be with List. Is this possible? (Yes, I know a Set and List are different semantics, but a List can at least be fairly easiliy constrained to Set semantics if you use it properly).
I could also try <bag>, which maps to List in POJOs? But I'm wary of this because of Hibernate's adherence to the semantics. At this point I don't know what headaches might arise later due to that choice.
I've read section 6.2 in the Hibernate (
http://www.hibernate.org/hib_docs/refer ... ns-mapping). It which has:
Quote:
If your relational model doesn't have an index column, e.g. if you're working with legacy data, use an unordered Set instead. This seems to put people off who assume that List should just be a more convenient way of accessing an unordered collection.
I understand the argument and agree with it, but I don't see anything here that helps me when I don't have a choice to use Set.
Suggestions? Anyone else worked thru this?
Any help is greatly appreciated.
--gus