Using: JPA 1 från Java EE 5:
My problem is as follows: I like to persist an Entity object containing a collection of numbers (Integer[]) with max lenght 3.
This solution works for Java EE 6: (annotation) ElementCollection private List productIds = new ArrayList();
What is the correct solution in Java EE5 and JPA 1. I have been told to use hibernate specific annotations, but this technique is new to me.
I have tried with (annotation) CollectionOfElements, org.hibernate.annotations.CollectionOfElements, but the Array is saved as serialized object and not readable in the database.
Grateful for any answer that lead me in the right direction!
Since
ElementCollection
was introduced in JPA 2 to overcome the problem of mapping a colletion of primitive datatypes, usingCollectionOfElements
for a Hibernate-specific solution is basically fine.If you want to have it stored in a relational way, you might either go and have 3 columns (in case this is fix), or have another table mapped with usual One-To-Many relation and wrap your primitive type into a specific class.