Deserializing my Spatial Objects

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Deserializing my Spatial Objects

Rainer Dreyer
Hi folks

I know a similar error has been on this list before, but I simply can't find my problem.

I'm using postgis and hibernate spatial, and I can successfully query tables I have created using a OpenStreetMap tool. I can also create my own SpatialObjects and hibernate spatial saves them fine.

When I try a simple query, I get the following error, though:

Hibernate: insert into Pub (geom, name, id) values (?, ?, ?) //works
Hibernate: select pub0_.id as id0_, pub0_.geom as geom0_, pub0_.name as name2_ from Pub pub0_
Exception in thread "main" org.hibernate.type.SerializationException: could not deserialize
        at org.hibernate.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)

I also tried manually writing queries on my pub table using pgAdmin3, but ST_AsText is failing, probably because it seems like Hibernate Spatial doesn't automatically add my geometry column in "pub" to the PostGIS "geometry_columns" table. 

My honours project code is public at https://github.com/rdrey/LoBGaSP in case you want to check it out.

Thanks for the help!

--
Rainer Dreyer

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: Deserializing my Spatial Objects

Jan Boonen
Hi Rainer,

As far as I know the SerializationException occurs when Hibernate cannot
read the properties of your entity correctly from the database. Can you
figure out if any database exceptions occur (perhaps post the full
stacktrace). It would also be helpful if you post the annotated entity
and the DDL of the table that is causing trouble.

Cheers,

Jan

On 15-8-2011 4:13, Rainer Dreyer wrote:

> Hi folks
>
> I know a similar error has been on this list before, but I simply
> can't find my problem.
>
> I'm using postgis and hibernate spatial, and I can successfully query
> tables I have created using a OpenStreetMap tool. I can also create my
> own SpatialObjects and hibernate spatial saves them fine.
>
> When I try a simple query, I get the following error, though:
>
> Hibernate: insert into Pub (geom, name, id) values (?, ?, ?) //works
> Hibernate: select pub0_.id as id0_, pub0_.geom as geom0_, pub0_.name
> as name2_ from Pub pub0_
> Exception in thread "main" org.hibernate.type.SerializationException:
> could not deserialize
>         at
> org.hibernate.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)
>
> I also tried manually writing queries on my pub table using pgAdmin3,
> but ST_AsText is failing, probably because it seems like Hibernate
> Spatial doesn't automatically add my geometry column in "pub" to the
> PostGIS "geometry_columns" table.
>
> My honours project code is public at https://github.com/rdrey/LoBGaSP 
> in case you want to check it out.
>
> Thanks for the help!
>
> --
> Rainer Dreyer
> http://about.me/rdrey
>
>
>
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: Deserializing my Spatial Objects

Samuel Gendler
When I first started using hibernate spatial, I had some problem related to using the most recent hibernate release with the most recent release of hibernate spatial.  I had to grab the hibernate spatial head from trunk to get code that worked with hibernate 3.6 (or was it 3.5?)  I wish I could remember more, but it has been a long time since I set my environment up and I'd have to go find very old notes to track down the details.  Anyway, I thought it was worth mentioning, in case that's the problem.  I haven't been paying attention to official releases for either project in quite some time.



On Sun, Aug 14, 2011 at 11:58 PM, Jan Boonen <[hidden email]> wrote:
Hi Rainer,

As far as I know the SerializationException occurs when Hibernate cannot read the properties of your entity correctly from the database. Can you figure out if any database exceptions occur (perhaps post the full stacktrace). It would also be helpful if you post the annotated entity and the DDL of the table that is causing trouble.

Cheers,

Jan


On 15-8-2011 4:13, Rainer Dreyer wrote:
Hi folks

I know a similar error has been on this list before, but I simply can't find my problem.

I'm using postgis and hibernate spatial, and I can successfully query tables I have created using a OpenStreetMap tool. I can also create my own SpatialObjects and hibernate spatial saves them fine.

When I try a simple query, I get the following error, though:

Hibernate: insert into Pub (geom, name, id) values (?, ?, ?) //works
Hibernate: select pub0_.id as id0_, pub0_.geom as geom0_, pub0_.name as name2_ from Pub pub0_
Exception in thread "main" org.hibernate.type.SerializationException: could not deserialize
       at org.hibernate.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)

I also tried manually writing queries on my pub table using pgAdmin3, but ST_AsText is failing, probably because it seems like Hibernate Spatial doesn't automatically add my geometry column in "pub" to the PostGIS "geometry_columns" table.

My honours project code is public at https://github.com/rdrey/LoBGaSP in case you want to check it out.

Thanks for the help!

--
Rainer Dreyer
http://about.me/rdrey



_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users


_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: Deserializing my Spatial Objects

Darren Seeto
As mentioned the problem is with Hibernate not knowing how to serialize the geometries that hibernate spatial allows you to use.

To solve that problem I annotated the code to tell hibernate what type to use with the type annotation     @Type(type = "org.hibernatespatial.GeometryUserType")

Something like this:

    @Column(name = "LOCATION")
    @Type(type = "org.hibernatespatial.GeometryUserType")
    public Point getLocation() {
        return location;
    }

On 15/08/11 08:20, Samuel Gendler wrote:
When I first started using hibernate spatial, I had some problem related to using the most recent hibernate release with the most recent release of hibernate spatial.  I had to grab the hibernate spatial head from trunk to get code that worked with hibernate 3.6 (or was it 3.5?)  I wish I could remember more, but it has been a long time since I set my environment up and I'd have to go find very old notes to track down the details.  Anyway, I thought it was worth mentioning, in case that's the problem.  I haven't been paying attention to official releases for either project in quite some time.



On Sun, Aug 14, 2011 at 11:58 PM, Jan Boonen <[hidden email]> wrote:
Hi Rainer,

As far as I know the SerializationException occurs when Hibernate cannot read the properties of your entity correctly from the database. Can you figure out if any database exceptions occur (perhaps post the full stacktrace). It would also be helpful if you post the annotated entity and the DDL of the table that is causing trouble.

Cheers,

Jan


On 15-8-2011 4:13, Rainer Dreyer wrote:
Hi folks

I know a similar error has been on this list before, but I simply can't find my problem.

I'm using postgis and hibernate spatial, and I can successfully query tables I have created using a OpenStreetMap tool. I can also create my own SpatialObjects and hibernate spatial saves them fine.

When I try a simple query, I get the following error, though:

Hibernate: insert into Pub (geom, name, id) values (?, ?, ?) //works
Hibernate: select pub0_.id as id0_, pub0_.geom as geom0_, pub0_.name as name2_ from Pub pub0_
Exception in thread "main" org.hibernate.type. SerializationException: could not deserialize
       at org.hibernate.util. SerializationHelper. doDeserialize( SerializationHelper.java:262)

I also tried manually writing queries on my pub table using pgAdmin3, but ST_AsText is failing, probably because it seems like Hibernate Spatial doesn't automatically add my geometry column in "pub" to the PostGIS "geometry_columns" table.

My honours project code is public at https://github.com/rdrey/ LoBGaSP in case you want to check it out.

Thanks for the help!

--
Rainer Dreyer
http://about.me/rdrey



______________________________ _________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial. org/cgi-bin/mailman/listinfo/ hibernatespatial-users

______________________________ _________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial. org/cgi-bin/mailman/listinfo/ hibernatespatial-users

_______________________________________________ hibernatespatial-users mailing list [hidden email] http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
 

http://www.bbc.co.uk
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: Deserializing my Spatial Objects

Jan Boonen
As an addition to Darren's answer the following: I quickly looked into
your code at github and it seems that you are mixing annotations on
properties and fields. As a rule, you should use annotations on either
the fields or the getters. I prefer setting them on my getters (as in
Darren's example).

On 15-8-2011 11:21, Darren Seeto wrote:

> As mentioned the problem is with Hibernate not knowing how to
> serialize the geometries that hibernate spatial allows you to use.
>
> To solve that problem I annotated the code to tell hibernate what type
> to use with the type annotation     @Type(type =
> "org.hibernatespatial.GeometryUserType")
>
> Something like this:
>
>     @Column(name = "LOCATION")
>     @Type(type = "org.hibernatespatial.GeometryUserType")
>     public Point getLocation() {
>         return location;
>     }
>
> On 15/08/11 08:20, Samuel Gendler wrote:
>> When I first started using hibernate spatial, I had some problem
>> related to using the most recent hibernate release with the most
>> recent release of hibernate spatial.  I had to grab the hibernate
>> spatial head from trunk to get code that worked with hibernate 3.6
>> (or was it 3.5?)  I wish I could remember more, but it has been a
>> long time since I set my environment up and I'd have to go find very
>> old notes to track down the details.  Anyway, I thought it was worth
>> mentioning, in case that's the problem.  I haven't been paying
>> attention to official releases for either project in quite some time.
>>
>>
>>
>> On Sun, Aug 14, 2011 at 11:58 PM, Jan Boonen <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     Hi Rainer,
>>
>>     As far as I know the SerializationException occurs when Hibernate
>>     cannot read the properties of your entity correctly from the
>>     database. Can you figure out if any database exceptions occur
>>     (perhaps post the full stacktrace). It would also be helpful if
>>     you post the annotated entity and the DDL of the table that is
>>     causing trouble.
>>
>>     Cheers,
>>
>>     Jan
>>
>>
>>     On 15-8-2011 4:13, Rainer Dreyer wrote:
>>
>>         Hi folks
>>
>>         I know a similar error has been on this list before, but I
>>         simply can't find my problem.
>>
>>         I'm using postgis and hibernate spatial, and I can
>>         successfully query tables I have created using a
>>         OpenStreetMap tool. I can also create my own SpatialObjects
>>         and hibernate spatial saves them fine.
>>
>>         When I try a simple query, I get the following error, though:
>>
>>         Hibernate: insert into Pub (geom, name, id) values (?, ?, ?)
>>         //works
>>         Hibernate: select pub0_.id as id0_, pub0_.geom as geom0_,
>>         pub0_.name as name2_ from Pub pub0_
>>         Exception in thread "main" org.hibernate.type.
>>         SerializationException: could not deserialize
>>                at org.hibernate.util. SerializationHelper.
>>         doDeserialize( SerializationHelper.java:262)
>>
>>         I also tried manually writing queries on my pub table using
>>         pgAdmin3, but ST_AsText is failing, probably because it seems
>>         like Hibernate Spatial doesn't automatically add my geometry
>>         column in "pub" to the PostGIS "geometry_columns" table.
>>
>>         My honours project code is public at
>>         https://github.com/rdrey/ LoBGaSP
>>         <https://github.com/rdrey/LoBGaSP> in case you want to check
>>         it out.
>>
>>         Thanks for the help!
>>
>>         --
>>         Rainer Dreyer
>>         http://about.me/rdrey
>>
>>
>>
>>         ______________________________ _________________
>>         hibernatespatial-users mailing list
>>         hibernatespatial-users@lists. hibernatespatial.org
>>         <mailto:[hidden email]>
>>         http://www.hibernatespatial. org/cgi-bin/mailman/listinfo/
>>         hibernatespatial-users
>>         <http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users>
>>
>>
>>     ______________________________ _________________
>>     hibernatespatial-users mailing list
>>     hibernatespatial-users@lists. hibernatespatial.org
>>     <mailto:[hidden email]>
>>     http://www.hibernatespatial. org/cgi-bin/mailman/listinfo/
>>     hibernatespatial-users
>>     <http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users>
>>
>>
>>
>> _______________________________________________
>> hibernatespatial-users mailing list
>> [hidden email]
>> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
>
> http://www.bbc.co.uk
> This e-mail (and any attachments) is confidential and may contain
> personal views which are not the views of the BBC unless specifically
> stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in
> reliance on it and notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
>
>
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Reply | Threaded
Open this post in threaded view
|

Re: Deserializing my Spatial Objects

Rainer Dreyer
In reply to this post by Rainer Dreyer
Hi everyone!

I didn't have time to work on this yesterday, so some of the other suggestions might have also helped, but Jan's suggestion solved my issue in a single copy-paste (moving the geom Annotations to my getter).

Thanks so much for looking at my code and spotting my issue! (I was going to follow other suggestions and try out some different versions of hibernate & hibernate-spatial and eventually even start from scratch with the tutorial code and slowly building the framework from the tutorial code.)

Greetings from Cape Town,
--
Rainer Dreyer

_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users