Problem saving list <String> via JPA?
I've already seen
How to save a property of type List <String> in JPA?
and
Match a list of strings with JPA / Hibernate annotations
==================================================== =============================
I'm trying to save
List<String> through JPA. I found out that JPA 1.0 has no way to preserve the collection of non-entities, but JPA 2.0 included the @CollectionOfElements annotation.
First off, I'm not sure which version of JPA 2.0 to use. I used toplink-essentials before, but it has no @CollectionOfElements annotation.
I downloaded eclipse-link but did not find jar files in it.
So my question is what implementation of JPA 2.0 to use that provides jar files so that I can include these banks in my project, as was done for important links.
First off, I'm not sure which version of JPA 2.0 to use. I used toplink-essentials before, but it has no @CollectionOfElements annotation.
TopLink-Essential is not a JPA 2.0 implementation. And as James noted, note that the JPA 2.0 annotation @ElementCollection , @CollectionOfElements is a Hibernate annotation that is now deprecated in favor of the JPA annotation.
I downloaded eclipse-link but did not find jar files in it.
What did you download? EclipseLink 2.1.1 Installer Zip (28 MB), which you can get from the download page , contains an all-in-one jar in the jlib directory.
So my question is what implementation of JPA 2.0 to use that provides jar files so that I can include these banks in my project, as was done for important links.
Any of them. I personally used Hibernate 3.5.x or EcliseLink 2.x, which you can get accordingly from
- https://sourceforge.net/projects/hibernate/files/hibernate3/3.5.5-Final
- http://www.eclipse.org/eclipselink/downloads/
Link
- JPA 2.0 Specification
- Section 11.1.12 "Annotation of the ElementCollection"
Note that JPA 2.0 defines @ElementCollection, not @CollectionOfElements. It can be used to store the list. @CollectionOfElements is an extension of Hibernate.
In TopLink Essentials (JPA 1.0), you can still match this, but you will need to use the DescriptorCustomizer to define DirectCollectionMapping in your code.
In EclipseLink 1.0, it was defined as @BasicCollection, and in JPA 2.0 and EclipseLink> = 1.2 it was defined as @ElemenetCollection.