emmanuel wrote:
you cannot mix @IndexColumn and @OrderBy, this does not make sense
Thanks for your help.
I didn't quite understood the meaning of @IndexColumn. I used it because the documentation was clear:
So specifically, java.util.List collections wo @OrderBy nor @org.hibernate.annotations.IndexColumn are going to be considered as bags.
http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#entity-mapping-association-collections
I tried them one at a time: @IndexColumn and @OrderBy, but didn't work too. @indexColumn is the index in the database that hibernate should use? I think I really didin't get this one. (I got @OrderBy, at least :)
I tried to use java.util.Set either, but guess what? Bag semantic again...
I just can't avoid Hibernate deleting my records and inserting everything again.
Am I right about that? Bag semantic will delete everything, and reinsert.
List, Set and Map semantics will insert and delete only the modified fields. Aint that right?
As I couldn't avoid delete, and I have a method that have access only to some items from the Bean List, and I needed to update the list, I created a workarround.
FYI, I created a method that: gets the list from the Bean, get a map from the servlet, remove the items from the Bean-list that are NULL in the servlet-map (key exists AND value are null), insert the items from the servlet-map that doesn't existis in the Bean-list, and let the items in the Bean-list, that doesn't existis in the Servlet-map's keys, unchanged.
It seams to work (after I changed the relationship in the Bean to FetchType.EAGER).
If anybody knows how tell hibernate to do this (or anything similar), please let me know.
Thanks,
Leonardo Barbosa