[postgis-users] RE: RE: PostGIS - hibernate - EJB3

Daniel Martinez dmtz98 at yahoo.com
Mon Sep 11 09:45:50 PDT 2006


Christian,
  I'm using the 'DriverWrapper' in the org.postgis package instead of the regular 'org.postgresql.Driver'. So in my postgres-ds.xml I have:
   
  <driver-class>org.postgis.DriverWrapper</driver-class>
   
  Also, after creating my 'Geometry' object I was required to set the 'srid' field, like this:
   
  double x = 10.50;
double y = 8.20;
Geometry geometry = new org.postgis.Point(x,y);
geometry.setSrid(4326);
   
  Otherwise, I kept getting errors when trying to persist the object into the database. 
   
  I hope this helps.
   
  Thanks,
  Daniel


coster <christian.osterrieder at salzburgresearch.at> wrote:  
Hallo Daniel,
thank you for your solution, it works fine for me.

But there is another problem:
If I try to store my geometry data I get the following error:
Caused by: org.postgresql.util.PSQLException: Unzulässiger Wert für den Typ
int : 010100000000000000000025406666666666662040.
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2507)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getInt(AbstractJdbc2ResultSet.java:1994)
at org.postgresql.jdbc3.Jdbc3ResultSet.getBlob(Jdbc3ResultSet.java:54)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getBlob(AbstractJdbc2ResultSet.java:323)
at
org.jboss.resource.adapter.jdbc.WrappedResultSet.getBlob(WrappedResultSet.java:378)
at
at.srfg.dataAccessLayer.persistance.hibernate.GeometryType.nullSafeGet(GeometryType.java:63)

I use a simple Point for testing it:
double x = 10.50;
double y = 8.20;
Geometry geometry = new org.postgis.Point(x,y);

Thank you for your help,
Christian.


D. Martinez wrote:
> 
> Hello, 
> I implemented Norman's solution and got the same problem, with the column
> getting defined as 'oid' instead of 'geometry'. 
> I finally found a fix that worked for me. It's actually very simple. All I
> do is set a 'columnDefinition' for the field in the EJB entity bean. Like
> this. 
> 
> @Type(type="mycode.ejb.par.GeometryType") 
> @Column(name="LOCATION",columnDefinition="geometry") 
> public org.postgis.Geometry getPoint() { 
> return _point; 
> } 
> 
> I set the 'columnDefinition' to 'geometry', and it seems to work. The
> column gets created as type 'geometry'. 
> 
> Hope this helps. 
> 
> Norman, thanks for your solution! 
> 
> Daniel 
> 
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Get on board. You're invited to try the new Yahoo! Mail.
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 

-- 
View this message in context: http://www.nabble.com/PostGIS---hibernate---EJB3-tf2064211.html#a6244904
Sent from the PostGIS - User forum at Nabble.com.

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


 		
---------------------------------
Stay in the know. Pulse on the new Yahoo.com.  Check it out. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060911/5ec7d8e7/attachment.html>


More information about the postgis-users mailing list