Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Persisting PGgeomerty with custom SRID
Persisting PGgeomerty with custom SRID [message #649533] Wed, 19 January 2011 15:32 Go to next message
Mustafa  is currently offline Mustafa Friend
Messages: 4
Registered: January 2011
Junior Member
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 14:50 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.


James : Wiki : Book : Blog : Twitter
Re: Persisting PGgeomerty with custom SRID [message #649783 is a reply to message #649533] Thu, 20 January 2011 15:26 Go to previous message
Mustafa  is currently offline Mustafa Friend
Messages: 4
Registered: January 2011
Junior Member
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: Thu Apr 25 17:39:29 GMT 2024

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

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

Back to the top