users@glassfish.java.net

Glassfish Issue# 3240 / PostGis + ToplinkEssentials

From: <glassfish_at_javadesktop.org>
Date: Mon, 08 Oct 2007 01:18:51 PDT

Is there any Progress on Issue# 3240 [Using PostgreGIS's PGobject types does not work in v2]?

I tried the workaround from pkrogh (last comment) and set the Converter in the (PGgeomerty)-Mapping to null. But i ran into some other Problem, when using Lazy-Loading. So I tried out to build my own Converter and I wanted to know, if my solution fits into the ToplinkEssential Framework, since I'm pretty new to ToplinkEssentials JPA, but I really want to make use of the JPA Framework with PostGis.

I am using now the Type org.postgis.Geometry as Class for the persisting attributes (since org.postgis.PGgeometry contains the not-serializable BinaryParser) in the Entities and I am assigning the following Converter to all PostGis Mappings:


public class GeometryObjectConverter implements Converter {

        private final DatabaseMapping mapping;

        /**
         * @param mapping DatabaseMapping
         */
        public GeometryObjectConverter(DatabaseMapping mapping) {
                this.mapping = mapping;
        }

        @Override
        public Object convertDataValueToObjectValue(Object dataValue,
                        Session session) {
                if (dataValue instanceof PGobject) {
                        try {
                                return new PGgeometry(((PGobject) dataValue).getValue()).getGeometry();
                        } catch (SQLException e) {
                                throw ConversionException.couldNotBeConverted(mapping, PGgeometry.class, e);
                        }
                }
                return dataValue;
        }

        @Override
        public Object convertObjectValueToDataValue(Object objectValue,
                        Session session) {
                if (objectValue instanceof Geometry) {
                        return new PGgeometry((Geometry)objectValue);
                }
                return objectValue;
        }

        @Override
        public void initialize(DatabaseMapping mapping, Session session) {}

        @Override
        public boolean isMutable() {
                return true;
        }
}


The Workaround works with with Eager-/Lazy-Loading and Glassfish Version v2ur1-b03.

Might this be a solution for Issue# 3240 or do I work on a obsolete Problem and there is already an other/better workaround/solution?
[Message sent by forum member 'stni' (stni)]

http://forums.java.net/jive/thread.jspa?messageID=238886