Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] PostgreSQL array mapping

If you use binding and in your converter convert the List back to an
Integer[] does it work?  Are you able to write the field directly through
JDBC, what do you need to bind in JDBC?

The StructureConverter is for data returned as instances of Struct from the
database, but this seems to be different, as you get an Integer[].



KARASZI Istvan-2 wrote:
> 
> hi!
> 
> I'm new on the list and I've tried to search for this problem without
> any luck. So sorry if this was discussed before.
> 
> 
> I'm trying to implement a class which uses a PostgreSQL integer[]
> field as data for an attribute. I've written a Converter (called
> ArrayConverter) which converts the data from the Data value to Object
> value and it's working very well, it looks like this:
> 
>        public Object convertDataValueToObjectValue(final Object from,
> final
> Session session) {
> 
>                if (from instanceof Integer[]) {
>                        final Integer[] to = (Integer[]) from;
>                        return Arrays.asList(to);
>                }
> 
>                throw new IllegalArgumentException("Unknown object type!");
>        }
> 
> But I could not write the Object value to Data value converter because
> I could not use any array data there. I've figured out that I cannot
> use:
> 
> - the psql writing "{ 1, 2, 3, 4 }" format because it'll fail with
> 'ERROR: column "data" is of type integer[] but expression is of type
> character varying' which is true of course because the result of the
> convertObjectValueToDataValue method will be a String in this case
> 
> - the "ARRAY[1, 2, 3, 4]" for the same reason
> 
> - I've tried multiple ways to call a stored function to create an
> ARRAY but I could not call any stored function from there. Is there a
> way to do it? Or any way to save array from EclipseLink to PostgreSQL?
> 
> I've found this thread:
> http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg01513.html
> but the test mentioned in the CVS unfortunately does not exist in SVN
> or I was enough stupid to not found it :(
> 
> thanks,
> -- 
> .: istvan karaszi :: raszi :: raszi@xxxxxxxxxxxxx :.
> 
> 


-----
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/PostgreSQL-array-mapping-tp25708155p25768702.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top