I have already seen
How to persist a property of type List<String> in JPA?
and
Map a list of strings with JPA/Hibernate annotations
=============================================================================
I am trying to save
List<String>
through JPA. I came to know that JPA 1.0 doesn't have any way to persist collection of non-entity classes but JPA 2.0 have included @CollectionOfElements
annotation.
First, I am not sure which JPA 2.0 implementation to use. Earlier I was using toplink-essentials but it doesn't have @CollectionOfElements
annotation.
I downloaded eclipse-link but didn't find any jar files inside it.
So my question is to which JPA 2.0 implementation to use which provides jar files so that I can include those jars in my project as I have done for toplink-essentials.
First, I am not sure which JPA 2.0 implementation to use. Earlier I was using toplink-essentials but it doesn't have @CollectionOfElements annotation.
TopLink-Essential is not a JPA 2.0 implementation. And as pointed out by James, note that the JPA 2.0 annotation is @ElementCollection
, @CollectionOfElements
is the Hibernate specific annotation which is now deprecated in favor of the JPA annotation.
I downloaded eclipse-link but didn't find any jar files inside it.
What did you download? The EclipseLink 2.1.1 Installer Zip (28 MB) that you can get from the download page contains an all-in-one jar in the jlib directory.
So my question is to which JPA 2.0 implementation to use which provides jar files so that I can include those jars in my project as I have done for toplink-essentials.
Any of them. I would personally use Hibernate 3.5.x or EcliseLink 2.x that you can get respectively from
Note that JPA 2.0 defines @ElementCollection not @CollectionOfElements. It can be used to store List. @CollectionOfElements is a Hibernate extension.
In TopLink Essentials (JPA 1.0) you could still map this, but would need to use a DescriptorCustomizer to define a DirectCollectionMapping in code.
In EclipseLink 1.0, this was defined as a @BasicCollection, and in JPA 2.0 and EclipseLink >= 1.2 this was defined as @ElemenetCollection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With