Hello Eduardo

No, the documentation states that it can be used for simple types also:
"Defines a collection of instances of a basic type or embeddable class" (
http://docs.oracle.com/javaee/6/api/javax/persistence/ElementCollection.html
).

This 2 links points that ElementCollection should be used with enums:
http://docs.oracle.com/javaee/6/api/javax/persistence/Enumerated.html
http://stackoverflow.com/questions/416208/jpa-map-collection-of-enums



On Fri, Aug 31, 2012 at 3:42 AM, Eduardo Perrino
<[email protected]>wrote:

> Hi Roberto,
>
> @ElementCollection annotation have to be used to contain embedded
> entities, therefore you're have to be sure that PositioningType class is
> annotated with @Embeddable.
>
>  The next example works fine for me:
>
> //Class Product
> @ElementCollection(fetch = FetchType.EAGER)
>  public Set<Rate> rates;
>
> //Class Rate
> @Embeddable
> public class Rate {
>    public String name;
> }
>
>
> Regards.
>
>
> 2012/8/30 roberto_sc <[email protected]>
>
>> No opinions at all? Does it look like that I'm doing the right thing?
>> I just found out that it also doesn't work for a list of integers,
>> possibly any collection of any simple type:
>>
>> @ElementCollection
>> @Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
>>
>> //private List<PositioningType> bestPositionings = new 
>> ArrayList<PositioningType>();
>> private List<Integer> bestPositionings;
>>
>>
>> Results in:
>>
>> Caused by: org.datanucleus.exceptions.NucleusUserException: The MetaData for 
>> the element class "java.lang.Integer" of the collection field 
>> "com.olympya.datamodel.model.Player.bestPositionings" was not found.
>>
>>
>> at 
>> com.google.appengine.datanucleus.scostore.AbstractFKStore.<init>(AbstractFKStore.java:120)
>>
>>
>> at 
>> com.google.appengine.datanucleus.scostore.FKListStore.<init>(FKListStore.java:83)
>>
>>
>> at 
>> com.google.appengine.datanucleus.DatastoreManager.newFKListStore(DatastoreManager.java:472)
>>
>>
>> at 
>> org.datanucleus.store.mapped.MappedStoreManager.getBackingStoreForCollection(MappedStoreManager.java:798)
>>
>>
>> at 
>> org.datanucleus.store.mapped.MappedStoreManager.getBackingStoreForField(MappedStoreManager.java:709)
>>
>>
>> at org.datanucleus.store.types.sco.backed.ArrayList.<init>(ArrayList.java:99)
>>
>>
>> :(
>>
>> Em quarta-feira, 29 de agosto de 2012 13h46min03s UTC-3, roberto_sc
>> escreveu:
>>
>>>
>>> I'm moving from JPA 1 to JPA 2 in my Gooogle App Engine project, and for
>>> that I changed the annotations for collections of enums, like this case:
>>>
>>> //  @OneToMany(cascade = CascadeType.ALL) // JPA 1
>>>     @ElementCollection(targetClass**=PositioningType.class)
>>>
>>>
>>>     private List<PositioningType> bestPositionings;
>>>
>>>
>>> PositioningType is an enum that is not annotated.
>>>
>>> That code is giving me the following exception:
>>>
>>> javax.persistence.PersistenceE**xception: The MetaData for the element 
>>> class "com.olympya.datamodel.model.**PositioningType" of the collection 
>>> field "com.olympya.datamodel.model.**Player.bestPositionings" was not found.
>>>
>>>
>>> at 
>>> org.datanucleus.api.jpa.Nucleu**sJPAHelper.getJPAExceptionForN**ucleusException(NucleusJPAHelp**er.java:302)
>>>
>>>
>>> at 
>>> org.datanucleus.api.jpa.JPAEnt**ityTransaction.commit(JPAEntit**yTransaction.java:122)
>>>
>>>
>>> at com.olympya.Services.mergeUser**(Services.java:102)
>>>
>>> ...
>>> Caused by: org.datanucleus.exceptions.Nuc**leusUserException: The MetaData 
>>> for the element class "com.olympya.datamodel.model.**PositioningType" of 
>>> the collection field 
>>> "com.olympya.datamodel.model.**Player.bestPositionings" was not found.
>>>
>>>
>>> at 
>>> com.google.appengine.datanucle**us.scostore.AbstractFKStore.<i**nit>(AbstractFKStore.java:120)
>>>
>>>
>>> at 
>>> com.google.appengine.datanucle**us.scostore.FKListStore.<init>**(FKListStore.java:83)
>>>
>>>
>>> at 
>>> com.google.appengine.datanucle**us.DatastoreManager.newFKListS**tore(DatastoreManager.java:472**)
>>>
>>>
>>> at 
>>> org.datanucleus.store.mapped.M**appedStoreManager.getBackingSt**oreForCollection(MappedStoreMa**nager.java:798)
>>>
>>>
>>> at 
>>> org.datanucleus.store.mapped.M**appedStoreManager.getBackingSt**oreForField(MappedStoreManager**.java:709)
>>>
>>>
>>> at 
>>> org.datanucleus.store.types.sc**o.backed.ArrayList.<init>(Arra**yList.java:99)
>>>
>>>
>>> at sun.reflect.NativeConstructorA**ccessorImpl.newInstance0(Nativ**e Method)
>>>
>>> ...
>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/google-appengine/-/M9bihLLrsTAJ.
>>
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to