When I create a new entity class and want to have more than one List in it, Xpert.ivy says: "If an entity class has more than one collection you have to use 'Set' instead of 'List' as type." I think the JEE Persistence API does not have this limitation. asked 14.08.2014 at 11:32 HaraldWeber |
The JPA itself also has this limitation if the list's are eagerly fetched (which is like this in ivy). Eager means also all entries in the list's are fetched/loaded if the main entity is loaded. If there is more than one list, all relations are loaded with a big join (bad performance) and then jpa (hibernate) has to find the entries for each list, but then this list would have multiple entries of the same id because of the big join, so it is necessary that the type is Set. The advice is to use no mapped by relations if not relay necessary, because this results in very bad performance. Example:
IF you now load just one employee (e.g. answered 18.08.2014 at 12:41 Christian St... ♦ |
This does not solve your problem but is some information to understand your problem:
In JPA there is no such restriction but: When defining entities you should use 'set' instead of 'list' for collections. This follows the exact same rules as using different collection types anywhere else throughout your code. You could use Object or Collections for all your references, yet in most cases you use more concrete types. For example, when I see a List, I know it comes sorted in some way, and that duplicates are either acceptable or irrelevant for this case. When I see a Set, I usually expect it to have no duplicates and no specific order (unless it's a SortedSet). When I see a Collection, I don't expect anything more from it than to contain some entities. Solution: Change all collections to sets when used in a domain-class. answered 14.08.2014 at 13:38 Daniel Oechslin Its a bit strange..
The method
(14.08.2014 at 14:12)
HaraldWeber
Well that's a good question. Maybe ivy wants it as easy as possible so they tried not to confuse a user with different collections. We should wait for an ivy-team asnwer...
(14.08.2014 at 16:51)
Daniel Oechslin
|
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 14.08.2014 at 11:32
Seen: 2,811 times
Last updated: 18.08.2014 at 12:41