Fornax-Platform
Forum

 « Return to Thread: Hibernate - Always generate List?

Hibernate - Always generate List?

by Tom85Ger :: Rate this Message:

Reply to Author | View in Thread

Hello,
the question probably sounds a bit weird, but is it possible to let the hibernate cartridge always generate Lists and never Sets? If the cartridge generates a Set, then I have to implement equals/hashCode. The problem is that I have classes that may be equal concerning their attributes, but actually they are not equal. In order to decide whether they are really different I would have to check lots of other associations to other classes. Therefore a simple equals/hashCode implementation is not possible. Due to this reason I wondered whether it would be able to always generate Lists.

My first thought was: Ok I look for the part of the xpt which creates the Set and there I change the code in that way that it always create Lists. Besides the fact that I'm not sure whether this really works its a bit ugly as I would have to change the files every time I'm upgrading to a new version of the cartridge. My next thought was: I do not change the extensions but instead I introduce a transformation, which assigns the ordered-Restriction to every affected association. As a consequence of this I do not have to specify "ordered" for every (affected) association.

Are there any other possiblities to solve this problem? Can you give me some hints on how to implement the mentioned transformation (if there is no easier solution).
I know that I could use the "ordered" for every assocation, but I'm searching for an alternative.

Thank you in advance.

Best regards,
Tom

 « Return to Thread: Hibernate - Always generate List?