Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.hibernate.MappingException: No Dialect mapping for JDBC type: 2002

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?

like image 237
Moli Avatar asked Jun 15 '10 10:06

Moli


1 Answers

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;
like image 151
Pascal Thivent Avatar answered Oct 13 '22 11:10

Pascal Thivent