-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Custom Mapping Failing in Native SQL Queries
PostPosted: Wed Oct 21, 2009 8:57 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 1:17 pm
Posts: 78
I am using Oracle 11G and their sdo_geometry object for spatial queries. I have written a custom mapping that maps sdo_geometry to a generic Geometry class I wrote. I implemented the UserType.sqlTypes method as follows

Code:
private static final int[] SQL_TYPES = {2002};
.
.
.
public int[] sqlTypes() {
        return SQL_TYPES;
}


I have also written a custom dialect extending the Oracle 10g dialect with the following in the constructor:

Code:
public MyOracleDialect()  extends Oracle10gDialect {
        super();
        registerColumnType(2002, "sdo_geometry");
}


Now here is where it gets interesting.

I have a native SQL query in my orm.xml (as I am using JPA) that looks like this:

Code:
SELECT d.GEO FROM MY_TABLE d


and the following result set mapping:

Code:
<sql-result-set-mapping name="searchResults">
        <column-result name="GEO" />
</sql-result-set-mapping>


After all this, I get the following exception as I execute the query:

Code:
org.hibernate.MappingException: No Dialect mapping for JDBC type: 2002
   at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
   at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
   at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:370)
   at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)
   at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)
   at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:1796)
   at org.hibernate.loader.Loader.doQuery(Loader.java:674)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.doList(Loader.java:2213)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
   at org.hibernate.loader.Loader.list(Loader.java:2099)
   at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
   at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
   at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
   at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
   at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:65)


My custom dialect class is in place in my configuration file, and things work great when I run a JPA query. It is only in this native SQL situation where I have an issue, and I feel like I have done everything right. After all, I explicitly specify type 2002 in my custom dialect.

Am I missing something silly or obvious? I am under some time pressure, so any help you can provide is really appreciated.

Thanks.


Top
 Profile  
 
 Post subject: Re: Custom Mapping Failing in Native SQL Queries
PostPosted: Tue Jun 15, 2010 4:44 am 
Newbie

Joined: Tue Jun 15, 2010 4:41 am
Posts: 2
I'm having the same troubles... Do you solved this trouble?

When a try to do a JPA nativeQuery and get the geoemtry fielda I'm getting a "No Dialect mapping for JDBC type: 2002"..

Anybody know how to solve this?

Many thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.