Skip to main content

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

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 :.


Back to the top