• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

org.hibernate.MappingException: No Dialect mapping for JDBC type: -9

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I get the above error message when I do this select (as a native query):



Here is the Java code:



The "em" is the entity manager.

Here is the stack trace:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:370)
org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)
org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)
org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)
org.hibernate.loader.Loader.getResultSet(Loader.java:1796)
org.hibernate.loader.Loader.doQuery(Loader.java:674)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
org.hibernate.loader.Loader.doList(Loader.java:2220)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
org.hibernate.loader.Loader.list(Loader.java:2099)
org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:66)
org.apache.jsp.webclient.admin.custom.query_005fstatistics_jsp._jspService(query_005fstatistics_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
om.face.oam.AdminFilter.doFilter(AdminFilter.java:109)


What am I doing wrong here? The database is an SQL Server 2008.

Thanks
Markus
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What data types are you using in your mapped table?
 
Markus Källander
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:What data types are you using in your mapped table?



nvarchar50. Some cells are null, many have the same content, but that shouldn't be a problem, should it?

/Markus
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nvarchar(50) should be fine. What driver and dialect are you using?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...also, out of curiosity, that is a very simple query. Any reason you are doing it in native SQL rather than as Criteria or as HQL? Like I say, just curious. Its probably nothing to do with your issue.
 
Markus Källander
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:nvarchar(50) should be fine. What driver and dialect are you using?



The direver is sqljdbc4 (com.microsoft.sqlserver.jdbc.SQLServerDriver) and the dialect is org.hibernate.dialect.SQLServerDialect. I am also using this query:



...and that works fine.

/Markus
 
Markus Källander
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:...also, out of curiosity, that is a very simple query. Any reason you are doing it in native SQL rather than as Criteria or as HQL? Like I say, just curious. Its probably nothing to do with your issue.



I have a view that is defined by the query:

This works fine:

And this doesn't (org.hibernate.MappingException: No Dialect mapping for JDBC type: -9):

I tried both SQL and HQL, no difference.
/Markus
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is odd behaviour. JDBC Type -9 is nvarchar, and I am happily using them with Hibernate against SQL Server 2008. The only difference is I use jTDS, but the MS SQL Server driver is pretty decent these days (I'd be amazed if they had not implemented NVARCHAR). Can you show use the DDL for the table(s) you compose you view from?
 
Markus Källander
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:That is odd behaviour. JDBC Type -9 is nvarchar, and I am happily using them with Hibernate against SQL Server 2008. The only difference is I use jTDS, but the MS SQL Server driver is pretty decent these days (I'd be amazed if they had not implemented NVARCHAR). Can you show use the DDL for the table(s) you compose you view from?



DDL? Is this what you mean?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I did, but unfortunately nothing obvious shows itself from that!

I can't really think of a reason this doesn't work. Have you tried swapping to jTDS? Might be worth a go.
 
Markus Källander
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:Yes I did, but unfortunately nothing obvious shows itself from that!

I can't really think of a reason this doesn't work. Have you tried swapping to jTDS? Might be worth a go.



Can't change the driver. But I just discovered that when I cast the nvarchar to varchar (cast([ServerName] as varchar) as ServerName) it works fine!, So I'll go with that...

Thanks!
/Markus
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, seems a little drastic ditching Unicode support just to work round this, but its your call.

I've had a quick glance on MSDN, it looks like its only from the 2.0 version of the official driver that NVARCHAR was supported. If you can convince whoever is preventing you upgrading to change their mind I would do that.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am using this Query as follows


config.configure(new File(_hibernateConfigPath));
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
SessionFactory sessionFactory = config.buildSessionFactory(serviceRegistry);
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();


String myquery = "select t2.name as column_name from sys.objects t1 inner join sys.columns t2 on t2.object_id = t1.object_id"+
" left join sys.indexes t3 on t3.object_id = t1.object_id and t3.is_unique = 1 left join sys.index_columns t4 on t4.object_id = t1.object_id and t4.index_id = t3.index_id and t4.column_id = t2.column_id where (upper(t1.type) = 'U' or upper(t1.type) = 'V') and upper(schema_name(t1.schema_id)) = 'dbo' and upper(t1.name) = 'TEST'";


List<Object[]> metadataList = session.createSQLQuery(myquery).list();
session.close();

I am getting org.hibernate.MappingException: No Dialect mapping for JDBC type: -9. Dont understand why? Please help!!!



 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi... try this..


String myquery = "select cast(t2.name as varchar) column_name from sys.objects t1 inner join sys.columns t2 on t2.object_id = t1.object_id"+
" left join sys.indexes t3 on t3.object_id = t1.object_id and t3.is_unique = 1 left join sys.index_columns t4 on t4.object_id = t1.object_id and t4.index_id = t3.index_id and t4.column_id = t2.column_id where (upper(t1.type) = 'U' or upper(t1.type) = 'V') and upper(schema_name(t1.schema_id)) = 'dbo' and upper(t1.name) = 'TEST'";
 
aswini nayak
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rashmi it works for me but is there any other solution?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do it like this


SQLQuery q=getSessionFactory().getCurrentSession().createSQLQuery(query);
q.addScalar("fechaalbaran", TimestampType.INSTANCE);
q.addScalar("sualbaran", StringType.INSTANCE);
q.addScalar("dtocomercial", DoubleType.INSTANCE);
q.addScalar("totdtocomercial", DoubleType.INSTANCE);
q.addScalar("dtopp", DoubleType.INSTANCE);
q.addScalar("totdtopp", DoubleType.INSTANCE);
q.addScalar("totalbruto", DoubleType.INSTANCE);
q.addScalar("totalimpuestos", DoubleType.INSTANCE);
q.addScalar("totalneto", DoubleType.INSTANCE);
q.addScalar("CODPROVEEDOR", IntegerType.INSTANCE);
q.addScalar("NOMPROVEEDOR", StringType.INSTANCE);
q.addScalar("alias", StringType.INSTANCE);
q.addScalar("orden", StringType.INSTANCE);
q.addScalar("CODALMACEN", StringType.INSTANCE);
q.addScalar("nombrealmacen", StringType.INSTANCE);
q.addScalar("INDICADOR_RETEFUENTE", StringType.INSTANCE);
q.addScalar("INDICADOR_RETEIVA", StringType.INSTANCE);
q.addScalar("INDICADOR_ICA", StringType.INSTANCE);
q.addScalar("codbanco", StringType.INSTANCE);
q.addScalar("descripcion", StringType.INSTANCE);
List list = q.setParameter("desde", desde).setParameter("hasta", hasta).list();
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am also facing the same issue(org.springframework.orm.hibernate3.HibernateSystemException: No Dialect mapping for JDBC type: -9).
I have upgraded my application from ojdbc6.jar to ojdbd7.c for Oracle 12c Container Database.
Hibernate and Spring are on version 3.
For me issue is fixed by casting a nvarchar datatype to varchar2. But i don't want to go by this approach.

Please help in understating why nvarchar is not working with ojdbc7.jar. What would be the best fix for this issue.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic