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

coster christian.osterrieder at salzburgresearch.at
Tue Sep 12 04:00:44 PDT 2006


Daniel, thank you for your help.

Now I can persist the geometry data, but I get the same error when I try to
read the data from the database:
Caused by: org.postgresql.util.PSQLException: Unzulässiger Wert für den Typ
int : 0101000020E610000000000000000025406666666666662040.
	at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.toInt(AbstractJdbc2ResultSet.java:2515)
	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 found the same problem on another forum:
http://www.laliluna.de/231.html

Is it necassary to change the GeometryType method 
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner)
to solve this problem? 

What versions of postgres driver do you use?

Thank you again,
Christian.


D. Martinez wrote:
> 
> 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. 
> _______________________________________________
> 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#a6263764
Sent from the PostGIS - User forum at Nabble.com.




More information about the postgis-users mailing list