hibernate-spatial-4.0 creates bytea column type instead of geometry

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

hibernate-spatial-4.0 creates bytea column type instead of geometry

Prathap KN (C)


Hi,

I am working with application which uses spring 3.1 and hibernate 4.2. For spatial feature we are planning to use hibernate spatial with postgis. But hibernate spatial creates column with bytea type instead of geometry. I am not able to find out where is root cause of this. I spend already couple of days in resolving but not successful.

hibernate-spatial-4.0.jar is used.

I am using following hibernate.properties file

database.driverClassName=org.postgresql.Driver

database.url=jdbc:postgresql://127.0.0.1:5433/mpdb

database.username=postgres

database.password=postgres


hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect

hibernate.show_sql=true

hibernate.hbm2ddl.auto=update

I am using following annotation in Entity

@Column(columnDefinition="Geometry", nullable = true)
    @Type(type = "org.hibernate.spatial.GeometryType")
    private Point geom;

Application successfully creates following table but instead of geometry type it creates bytea for column geom

                     Table "public.tile"
       Column           |            Type             | Modifiers

----------------------------+-----------------------------+----------- id | integer | not null alt | double precision | not null geom | bytea | lat | double precision | not null lng | double precision | not null multipath_table | text | not null multipath_table_min_value | double precision | multipath_table_resolution | integer | multipath_table_tx_id | text | tile_created | timestamp without time zone | not null tile_data_age | integer | tile_data_present | text | not null tile_num_tx | integer | Indexes: "tile_pkey" PRIMARY KEY, btree (id)

However manually I am able to create Geometry type column in postgis2.2-postgres9.5 database

I went through almost every thread but unsuccessful. Need help.





CONFIDENTIALITY NOTICE AND NOTICE REGARDING NO ELECTRONIC SIGNATURE:
The materials in this electronic transmission (including attachments) may be subject to attorney-client or work product privilege, may be private and confidential, and are the property of the sender. The information contained is intended only for the named addressees and should not be considered evidence of intent to be bound to any agreement. The taking of any action in reliance on the contents is strictly prohibited. If you are not the intended recipient of this message, please immediately notify the sender and promptly delete this message.

_______________________________________________
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: hibernate-spatial-4.0 creates bytea column type instead of geometry

Karel Maesen
Administrator
Usually this points to a problem with your configuration. Could you make sure that the Postgis dialect is actually loaded? You should find Hibernate log statements regarding the loaded Dialect.  Also verify that the postgis jar is on the class path and that you can write and read spatial data using your setup when you manually create the table.

You may also want to upgrade to HS 4.0.1 for Hibernate 4.2.

Regards,

Karel



> On 13 Jan 2016, at 11:20, Prathap KN (C) <[hidden email]> wrote:
>
>
> Hi,
>
> I am working with application which uses spring 3.1 and hibernate 4.2. For spatial feature we are planning to use hibernate spatial with postgis. But hibernate spatial creates column with bytea type instead of geometry. I am not able to find out where is root cause of this. I spend already couple of days in resolving but not successful.
>
> hibernate-spatial-4.0.jar is used.
>
> I am using following hibernate.properties file
>
> database.driverClassName=org.postgresql.Driver
>
>
> database
> .url=jdbc:postgresql://127.0.0.1:5433/mpdb
>
>
> database
> .username=
> postgres
>
> database
> .password=
> postgres
>
>
> hibernate
> .dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect
>
>
> hibernate
> .show_sql=true
>
>
> hibernate
> .hbm2ddl.auto=
> update
>
> I am using following annotation in
> Entity
>
>
>
> @Column(columnDefinition="Geometry", nullable = true)
>
>    
> @Type(type = "org.hibernate.spatial.GeometryType")
>
>    
> private Point geom;
> Application successfully creates following table but instead of geometry type it creates bytea for column geom
>
>                      Table "public.tile"
>
>        
> Column           |            Type             | Modifiers
> ----------------------------+-----------------------------+----------- id | integer | not null alt | double precision | not null geom | bytea | lat | double precision | not null lng | double precision | not null multipath_table | text | not null multipath_table_min_value | double precision | multipath_table_resolution | integer | multipath_table_tx_id | text | tile_created | timestamp without time zone | not null tile_data_age | integer | tile_data_present | text | not null tile_num_tx | integer | Indexes: "tile_pkey" PRIMARY KEY, btree (id)
>
> However manually I am able to create Geometry type column in postgis2.2-postgres9.5 database
>
> I went through almost every thread but unsuccessful. Need help.
>
>
>
>
>
> CONFIDENTIALITY NOTICE AND NOTICE REGARDING NO ELECTRONIC SIGNATURE:
> The materials in this electronic transmission (including attachments) may be subject to attorney-client or work product privilege, may be private and confidential, and are the property of the sender. The information contained is intended only for the named addressees and should not be considered evidence of intent to be bound to any agreement. The taking of any action in reliance on the contents is strictly prohibited. If you are not the intended recipient of this message, please immediately notify the sender and promptly delete this message.
> _______________________________________________
> 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: hibernate-spatial-4.0 creates bytea column type instead of geometry

Prathap KN (C)
Thanks.

I could able to fix this issue by modifying annotations used in Entity class.
This works for me.
@Column(columnDefinition="geometry(Point,4326)")
private org.hibernate.spatial.GeometryType geom;

I have couple of more questions.
1. I need to run following command from java application using hibernate spatial.
SELECT id,lat,lng
FROM tile
ORDER BY tile.geom::geometry <-> st_setsrid(st_makepoint(-136.9471652323,45.3251721412),4326)
I didnt find any similar example.
If hibernate spatial doesnt support can I run psql native query from application?.

2. I need one example for cube type. Any pointers on this?.
Your help is much appreciated.

Thanks,
Prathap
________________________________________
From: [hidden email] <[hidden email]> on behalf of Karel Maesen <[hidden email]>
Sent: Wednesday, January 13, 2016 1:18 PM
To: Hibernate Spatial Users Discussion
Subject: Re: [hibernatespatial-users] hibernate-spatial-4.0 creates bytea       column type instead of geometry

Usually this points to a problem with your configuration. Could you make sure that the Postgis dialect is actually loaded? You should find Hibernate log statements regarding the loaded Dialect.  Also verify that the postgis jar is on the class path and that you can write and read spatial data using your setup when you manually create the table.

You may also want to upgrade to HS 4.0.1 for Hibernate 4.2.

Regards,

Karel



> On 13 Jan 2016, at 11:20, Prathap KN (C) <[hidden email]> wrote:
>
>
> Hi,
>
> I am working with application which uses spring 3.1 and hibernate 4.2. For spatial feature we are planning to use hibernate spatial with postgis. But hibernate spatial creates column with bytea type instead of geometry. I am not able to find out where is root cause of this. I spend already couple of days in resolving but not successful.
>
> hibernate-spatial-4.0.jar is used.
>
> I am using following hibernate.properties file
>
> database.driverClassName=org.postgresql.Driver
>
>
> database
> .url=jdbc:postgresql://127.0.0.1:5433/mpdb
>
>
> database
> .username=
> postgres
>
> database
> .password=
> postgres
>
>
> hibernate
> .dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect
>
>
> hibernate
> .show_sql=true
>
>
> hibernate
> .hbm2ddl.auto=
> update
>
> I am using following annotation in
> Entity
>
>
>
> @Column(columnDefinition="Geometry", nullable = true)
>
>
> @Type(type = "org.hibernate.spatial.GeometryType")
>
>
> private Point geom;
> Application successfully creates following table but instead of geometry type it creates bytea for column geom
>
>                      Table "public.tile"
>
>
> Column           |            Type             | Modifiers
> ----------------------------+-----------------------------+----------- id | integer | not null alt | double precision | not null geom | bytea | lat | double precision | not null lng | double precision | not null multipath_table | text | not null multipath_table_min_value | double precision | multipath_table_resolution | integer | multipath_table_tx_id | text | tile_created | timestamp without time zone | not null tile_data_age | integer | tile_data_present | text | not null tile_num_tx | integer | Indexes: "tile_pkey" PRIMARY KEY, btree (id)
>
> However manually I am able to create Geometry type column in postgis2.2-postgres9.5 database
>
> I went through almost every thread but unsuccessful. Need help.
>
>
>
>
>
> CONFIDENTIALITY NOTICE AND NOTICE REGARDING NO ELECTRONIC SIGNATURE:
> The materials in this electronic transmission (including attachments) may be subject to attorney-client or work product privilege, may be private and confidential, and are the property of the sender. The information contained is intended only for the named addressees and should not be considered evidence of intent to be bound to any agreement. The taking of any action in reliance on the contents is strictly prohibited. If you are not the intended recipient of this message, please immediately notify the sender and promptly delete this message.
> _______________________________________________
> 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



CONFIDENTIALITY NOTICE AND NOTICE REGARDING NO ELECTRONIC SIGNATURE:
The materials in this electronic transmission (including attachments) may be subject to attorney-client or work product privilege, may be private and confidential, and are the property of the sender. The information contained is intended only for the named addressees and should not be considered evidence of intent to be bound to any agreement. The taking of any action in reliance on the contents is strictly prohibited. If you are not the intended recipient of this message, please immediately notify the sender and promptly delete this message.
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users