Community
Participate
Working Groups
The default type of collections defined by the editor should be specifiable by the user. Currently all collections are defined as type "Collection". JPA supports Collection, List, and Set.
Created attachment 187732 [details] patch
Patch committed ...
I found a bug coming with this patch. 1. Open Eclipse IDE with clean workspace 2. Create JPA project in it 3. Open diagram and create two entities 4. Create Many-to-many relation between the entities Result: Inspect the code and you will see that the relation attributes are of type java.util.Set instead of java.util.Collection although the default prefs/props haven't been changed
This is not a bug or at least it doesn't come with this bug. I noticed, that it has been already implemented that when a Many-to-Many bidirection/unidirectinal relation is created, its attributes will be of type java.util.Set. So I thought that there is something specific for that relation and that's way I didn't change it...
(In reply to comment #4) > This is not a bug or at least it doesn't come with this bug. Ops I ment it doesn't come with this patch...
There is nothing specific about it. I don't remember why it was 'java.util.Set' initially, but now it should be fixed because it's not consistent with your patch. Could you please provide one more patch for this, Petya?
Created attachment 187810 [details] additional patch
Created attachment 187811 [details] patch for tests
The patch is committed, but I have a question: Petya pointed out that actually specification allows also java.util.Map to be a type of a relationship attribute. Shaun, did you omit the 'Map' type intentionally for some reason? If not, perhaps we should implement this too?
I didn't mean to leave out Map intentionally. I should have gone "..." or etc. so we cover all supported collection types. Can you clarify what the default behavior is when creating a *ToMany relationship and how the collection class default can be specified? I, and I think most JPA developers, use List as their default so I'd want to be able to set this as my preference.
Created attachment 193259 [details] Adds java.util.Map support
(In reply to comment #10) > ... Can you clarify what the default behavior is when creating a *ToMany > relationship and how the collection class default can be specified? I, and I > think most JPA developers, use List as their default so I'd want to be able to > set this as my preference ... "... The most common collection type used in associations is the standard Collection superinterface ..." Pro JPA 2 Mastering the Java™ Persistence API (Mike Keith and Merrick Schincariol) ------------------------------------------------------ So, I'm going to leave the default type to be Collection, but if you insist I'll change it to List
One more comment. According to the same book the most common usage for java.util.Map in ...ToMany relations is when the Map is being keyed by an attribute from the the opposite entity. Turns out that from these cases the most common is the one where the key attribute is the id of the (opposite) entity. This case is so common that when we use it we don't need the @MapKey annotation. That's the case I've implemented in this patch.
Appears, I've missed something here. The @MapKey is still required although the name (in it) is not necessary
Fixed