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.