Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Persisting PGgeomerty with custom SRID
Persisting PGgeomerty with custom SRID [message #649533] Wed, 19 January 2011 10:32 Go to next message
Eclipse UserFriend
Hello,

I'm using eclipselink 2.1.0, Tomcat 6.0.14, with Posgtresql 8.4 for spatial operations in my project. So far I've managed to create a spatially enabled Entity. My entity seems pretty much like that


@Entity
@Converter(name="geoConverter", convertClass=MyGeoConverter.class)
public class Coverage {

@Convert(geoConverter)
@Column(columnDefiniton = "Geometry")
private Rectangle location;
.
..
}




and here is the Converter class..

public class MyGeoConverter implements Converter {

   public Rectangle convertDataValueToObjectValue(Object dataValue, Session s) {
   .
   ..
   }

   public PGgeometry convertDataValueToObjectValue(Object objectValue, Session s) {
          ........
         PGgeometry geo = new PGgeometry(wkt);
        
          geo.getGeometry().setSrid(4326);

           return geo;
   }

   public void initialize(DatabaseMapping m, Session s) {
              m.getFİeld().setSqlType(Types.OTHER);
   }

   public boolean isMutable() {
     return false;
   }
}




The problem is; when I create the Coverage entity and persist it, the SRID is always -1 for all the entries but the Coordinates are all OK. It seems like eclipselink is ignoring the SRID when genereting the SQL insert statement, or most probably I'm just missing something.. Any ideas ?

Thank in advance for any suggestions..
Re: Persisting PGgeomerty with custom SRID [message #649766 is a reply to message #649533] Thu, 20 January 2011 09:50 Go to previous messageGo to next message
Eclipse UserFriend
Please include the full code for your converter.

convertDataValueToObjectValue is used when reading from the database.

convertObjectValueToDataValue is used when writing to the database. Ensure you are setting everything required.
Re: Persisting PGgeomerty with custom SRID [message #649783 is a reply to message #649533] Thu, 20 January 2011 10:26 Go to previous message
Eclipse UserFriend
Sorry folks it was my bad.. Instead of returning the PGgeomery isntance that has the correct SRID, I was creating a new one and returning it with the wrong SRID at the end of the convertObjectValueToDataValue() method.. . Embarrassed

Anyway thanks for sparing time for it ..
Previous Topic:Dynamic updateble attribute
Next Topic:optional vs nullable attributes
Goto Forum:
  


Current Time: Sun Jul 06 11:27:20 EDT 2025

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

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

Back to the top