Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » PostgreSQL/PostGIS stored function + Eclipselink converter problem
PostgreSQL/PostGIS stored function + Eclipselink converter problem [message #653082] Tue, 08 February 2011 12:09 Go to next message
Tamas J is currently offline Tamas JFriend
Messages: 4
Registered: January 2011
Junior Member

I use PostgreSQL with PostGIS and Eclipselink. In the Postgres database I have some stored functions, as I know with Postgres stored functions + Eclipselink doesn't work the @NamedStoredProcedureQuery annotation, StoredProcedureCall and StoredFunctionCall methods, therefore i use @NamedNativeQuery.
I wrote a GeometryConverter, that works fine when I persist

my entity, and with
@NamedNativeQuery(name = "getEntity", query = "SELECT * FROM GET_ENTITY(?)", resultClass = Entity.class)

Here is my GeometryConverter:
       public Geometry convertDataValueToObjectValue(Object dataValue, Session session) {
		if (dataValue == null) {
			return null;
		} else if (dataValue instanceof PGgeometry) {
			return ((PGgeometry) dataValue).getGeometry();
		} else {
			log.severe("dataValue not instance of PGgeometry");
			return null;

	public PGgeometry convertObjectValueToDataValue(Object objectValue, Session session) {
		if (objectValue == null) {
			return null;
//		} else if (objectValue instanceof Geometry) {
//	    	return new PGgeometry((Geometry)objectValue);
	    } else if (objectValue instanceof Point) {
	    	return new PGgeometry((Point)objectValue);
	    } else if (objectValue instanceof MultiPoint) {
	    	return new PGgeometry((MultiPoint)objectValue);
	    } else if (objectValue instanceof LineString) {
	    	return new PGgeometry((LineString)objectValue);
	    } else if (objectValue instanceof MultiLineString) {
	    	return new PGgeometry((MultiLineString)objectValue);
	    } else if (objectValue instanceof Polygon) {
	    	return new PGgeometry((Polygon)objectValue);
	    } else if (objectValue instanceof MultiPolygon) {
	    	return new PGgeometry((MultiPolygon)objectValue);
	    } else if (objectValue instanceof GeometryCollection) {
	    	return new PGgeometry((GeometryCollection)objectValue);
	    } else {
	    	log.severe("objectValue not instance of Geometry");
	    	return new PGgeometry();

	public void initialize(DatabaseMapping dm, Session session) {

But when I want to use this stored function
@NamedNativeQuery(name = "getEntityGeom", query = "SELECT * FROM GET_ENTITY_GEOM(?)") 

the ? parameter is a Postgis/Postgresql geometry type, throw the following exception:
Internal Exception: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgis.MultiLineString. Use setObject() with an explicit Types value to specify the type to use.

I can see that the converter doesn't convert the org.postgis.MultiLineString to org.postgis.PGgeometry. What should I set to work my converter?

Thanks for your help!
Tamas J

[Updated on: Tue, 08 February 2011 12:11]

Report message to a moderator

Re: PostgreSQL/PostGIS stored function + Eclipselink converter problem [message #653132 is a reply to message #653082] Tue, 08 February 2011 15:38 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

See, s-stored-function-eclipselink-converter-problem

James : Wiki : Book : Blog : Twitter
Previous Topic:How to call Oracle function from eclipselink
Next Topic:deadlock on select
Goto Forum:

Current Time: Sun Apr 05 18:38:16 GMT 2020

Powered by FUDForum. Page generated in 0.01886 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top