Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] SQL arrays and EclipseLink

Arrays are not standard relational database types, and are not supported by
JPA.  EclipseLink supports them through the ArrayMapping.  You must define
the mapping through the code API, and use a DescriptorCustomizer in JPA to
add the mapping.  Your attribute type will be List<String>, and the
ArrayMapping is similar to the BasicCollection (DirectCollectionMapping).

EclipseLink's object relational data-type (Structs and Arrays) have
currently only been tested on Oracle, so you may require extra work to get
them working on PostgreSQL.  In theory reading should work but writing will
require extending the PostgreSQLPlatform similar to the Oracle8Platform (see
createArray method).

There is no example for the object relational data-types, but there is a
test model in the EclipseLink CVS repository that may be of use,
<EclipseLink>\foundation\eclipselink.core.test\src\org\eclipse\persistence\testing\models\insurance\objectrelational

You may wish to add an enhancement request to have JPA annotations for
ArrayMapping, and to have Array support added with PostgreSQL.


Miroslav Šulc wrote:
> 
> Hi,
> 
> I am very new to EclipseLink. I try to make it work on PostgreSQL table
> where I have arrays like "character varying(20)[]". These are standard
> arrays imo, just non-standard syntax. I can read these arrays through
> ResultSet.getArray().
> 
> I'd like to read and write these arrays using JPA and EclipseLink but I
> do not know how to do that. I have read something about ArrayMapping but
> my knowledge of EclipseLink is so poor that I do not know how to apply
> that to my code. I do not care if I store the array as String[] or
> List<String>, but it would be great if EclipseLink would read and
> persist these arrays for me :-)
> 
> Could someone plase explain me how I can make this work, or direct me to
> a documentation that is easy to apply for newcommers like me?
> 
> Thank you.
> 
> Miroslav
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/SQL-arrays-and-EclipseLink-tp20508852p20540645.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top