Hibernate Collection mapping, Refactoring
The title may not be very descriptive.
I have recently come across a problem with Hibernate many-to-many
collections using Link tables. In the application we were using List and
whenever we delete or insert an entry from the collection, hibernate
deletes all the entries from the link table and proceeds to add them back
(either with the inserted new entry or without the deleted entry). This as
you can see is a performance nightmare.
So I wanted to convert all these relationships to Set. I wanted to do that
without changing the interface (unfortunately the client code is
distributed across and method to Set is a no-no).
I tried changing the attributes to Set, without changing the signature of
the Getters and Setters (internally mapping list to set and vice-versa),
but hibernate still considers the mapping a bag (Which makes sense.)
Do anyone has an idea on how to solve this?
No comments:
Post a Comment