Hibernate Spatial:“No Dialect mapping for JDBC type:3000” [英] Hibernate Spatial: "No Dialect mapping for JDBC type: 3000"

查看:1069
本文介绍了Hibernate Spatial:“No Dialect mapping for JDBC type:3000”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过Hibernate将Spring Roo与支持PostGIS的PostgreSQL数据库集成,遵循 Hibernate空间教程。所有非GIS的东西都可以正常工作,并且已经从PostGIS模板创建了一个数据库。



问题是,一旦添加了几何属性到我的一个实体:

  @Type(type =org.hibernate.spatial.GeometryType)
private点中心点;

...它建立好,但尝试在服务器上运行(实际上与DB进行交互)
导致以下错误:

 导致:org.hibernate.MappingException:无JDBC类型的方言映射: 3000 
在org.hibernate.dialect.TypeNames.get(TypeNames.java:77)
在org.hibernate.dialect.TypeNames.get(TypeNames.java:100)
在org。 hibernate.dialect.Dialect.getTypeName(Dialect.java:298)
在org.hibernate.mapping.Column.getSqlType(Column.java:208)
在org.hibernate.mapping.Table.sqlCreateString( Table.java:418)
在org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:1099)
在org.hibernate.tool.hbm2ddl.SchemaExport。< init>(SchemaExport.java :106)
在org.hibernate.impl.SessionFactoryImpl。< init>(SessionFactoryImpl.java:372)
在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
在org.hibe rnate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
... 41更多

Hibernate Spatial的依赖关系似乎表明postgis-jdbc 1.5.3是必需的,但1.5.3不存在于任何Maven存储库中,我无法从源文件中进行编译。我尝试了1.5.2和1.3.3,并且都导致相同的3000错误。 HS说1.5.3应该是提供的,但是将依赖关系设置为1.5.3和< scope>提供的< / scope> p>

这只是需要一个精确版本的JDBC的情况,还是其他的错误?



相关我的POM的提取如下:

 <依赖关系> 
< groupId> com.vividsolutions< / groupId>
< artifactId> jts< / artifactId>
< version> 1.12< / version>
< / dependency>
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-spatial< / artifactId>
< version> 4.0-M1< / version>
< / dependency>
<依赖关系>
< groupId> org.postgis< / groupId>
< artifactId> postgis-jdbc< / artifactId>
< version> 1.5.2< / version>
< / dependency>

persistence.xml p>

 < property name =hibernate.dialectvalue =org.hibernate.spatial.dialect.postgis.PostgisDialect/> 


解决方案

您的异常表示Postgresql方言无法支持您通过注释提供的数据类型。使用自定义类来扩展它以添加支持可能是解决您的问题的一种方法。



我看过GIS项目,你是否提供了编译范围的javassist依赖您是否尝试使用以下注释引用数据类型?



请参阅 http://stackoverflow.com/a/3047190/390462

  @Column(name =geometry,columnDefinition =Geometry,nullable = true)
private几何几何;

正如我所理解的那样,你需要给出一个 columnDefinition 到您的字段,否则将无法将字段映射到良好的数据库列。


I'm attempting to integrate Spring Roo with a PostGIS-enabled PostgreSQL database via Hibernate, following the Hibernate Spatial tutorial. All of the non-GIS stuff is working fine, and I've created a DB from a PostGIS template.

The problem is that as soon as I add a Geometry property to one of my entities:

@Type(type="org.hibernate.spatial.GeometryType")
private Point centerPoint;

... it builds okay, but attempting to run on the server (and actually interact with the DB) causes the error below:

Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: 3000
    at org.hibernate.dialect.TypeNames.get(TypeNames.java:77)
    at org.hibernate.dialect.TypeNames.get(TypeNames.java:100)
    at org.hibernate.dialect.Dialect.getTypeName(Dialect.java:298)
    at org.hibernate.mapping.Column.getSqlType(Column.java:208)
    at org.hibernate.mapping.Table.sqlCreateString(Table.java:418)
    at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:1099)
    at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:106)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:372)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
    ... 41 more

Hibernate Spatial's dependencies seem to suggest that postgis-jdbc 1.5.3 is required but 1.5.3 is not present in any Maven repositories and I can't get it to compile from source. I've tried 1.5.2 and 1.3.3, and both result in the same 3000 error. HS says 1.5.3 should be "provided", but setting the dependency to 1.5.3 and <scope>provided</scope> doesn't help either.

Is this simply a case of needing a precise version of the JDBC, or is something else wrong?

The relevant extract of my POM is as follows:

        <dependency>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
            <version>1.12</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-spatial</artifactId>
            <version>4.0-M1</version>
        </dependency>
        <dependency>
            <groupId>org.postgis</groupId>
            <artifactId>postgis-jdbc</artifactId>
            <version>1.5.2</version>
        </dependency>

And from persistence.xml:

<property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>

解决方案

Your exception means that Postgresql dialect can't support the data type you have provided by annotation. Extending it with a custom class to add support could be a way to solve your problem.

I've look at the GIS project, do you provide javassist dependency with compile scope too ?

Did you try to reference your data types with the following annotations? See http://stackoverflow.com/a/3047190/390462.

@Column(name = "geometry", columnDefinition="Geometry", nullable = true) 
private Geometry geometry;

As much as I have understood, you need to give a columnDefinition to your field, otherwise it would not be able to map the field to the good db column.

这篇关于Hibernate Spatial:“No Dialect mapping for JDBC type:3000”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆