org.hibernate.MappingException:否JDBC类型的方言映射:2002 [英] org.hibernate.MappingException: No Dialect mapping for JDBC type: 2002

查看:102
本文介绍了org.hibernate.MappingException:否JDBC类型的方言映射:2002的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试执行JPA nativeQuery以获取几何字段类型时,出现 org.hibernate.MappingException:No对于JDBC类型:2002 的Dialect映射。 / p>

我使用Oracle和 org.hibernatespatial.oracle.OracleSpatial10gDialect



几何字段映射为:

  @Column(name =geometry)
@Type(type =org.hibernatespatial.GeometryUserType)
private几何几何;

// ...

List< Object> listFeatures = new LinkedList< Object>();

Query query = entityManager.createNativeQuery(
SELECT+ slots +,geometry FROM edtem_features feature,edtem_dades dada WHERE+
feature。+ tematic.getIdGeomField )+= dada。+ tematic.getIdDataField()+
AND dada.capesid =+ tematic.getCapa()。getId()+
AND feature.geometriesid =+ tematic。 。getGeometria()的getId());
listFeatures.addAll(query.getResultList());

这是我在spring + struts2上的hibernate配置

 < bean id =entityManagerFactory
class =org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean>
< property name =dataSourceref =dataSource/>

< property name =jpaVendorAdapter>
< bean class =org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter>
< property name =databasePlatformvalue =org.hibernatespatial.oracle.OracleSpatial10gDialect/>
< property name =showSqlvalue =true/>
< / bean>
< / property>
< property name =jpaProperties>
<道具>
< prop key =hibernate.dialect> org.hibernatespatial.oracle.OracleSpatial10gDialect< / prop>
< prop key =hibernate.default_schema> my_schema< / prop>
< /道具>
< / property>
< / bean>

这怎么解决?或者如何强制几何的类型得到这个工作?

解决方案

您可以尝试使用以下映射定义: b>

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

而不是:

  @Column(name =geometry)
@Type(type =org.hibernatespatial.GeometryUserType)
private几何几何;


I'm getting org.hibernate.MappingException: No Dialect mapping for JDBC type: 2002 when I try to do a JPA nativeQuery to get a geometry field type.

I'm using Oracle and org.hibernatespatial.oracle.OracleSpatial10gDialect.

The geometry field is mapped as:

@Column(name="geometry")  
@Type(type = "org.hibernatespatial.GeometryUserType")  
private Geometry geometry;

// ...

List<Object> listFeatures = new LinkedList<Object>();

Query query = entityManager.createNativeQuery(
   "SELECT "+ slots +" , geometry FROM  edtem_features feature, edtem_dades dada WHERE" +
   " feature."+ tematic.getIdGeomField() +" = dada."+ tematic.getIdDataField()+ 
   " AND dada.capesid= "+ tematic.getCapa().getId() +
   " AND feature.geometriesid= "+ tematic.getGeometria().getId());
listFeatures.addAll(query.getResultList());

This is my hibernate configuration over spring+struts2

<bean id="entityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />

    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="databasePlatform" value="org.hibernatespatial.oracle.OracleSpatial10gDialect" />
            <property name="showSql" value="true" />
        </bean>
    </property>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernatespatial.oracle.OracleSpatial10gDialect</prop>
            <prop key="hibernate.default_schema">my_schema</prop>
        </props>
    </property>
</bean>

How can this be solved? Or how to force the type of the geometry to get this working?

解决方案

Could you try with the following mapping definition:

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

Instead of:

@Column(name="geometry")  
@Type(type = "org.hibernatespatial.GeometryUserType")  
private Geometry geometry;

这篇关于org.hibernate.MappingException:否JDBC类型的方言映射:2002的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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