-->
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.  [ 4 posts ] 
Author Message
 Post subject: Mapping Exception: No Dialect mapping for JDBC type -9
PostPosted: Mon Jan 09, 2017 2:58 am 
Newbie

Joined: Mon Jan 09, 2017 2:37 am
Posts: 3
Hi guys,

I found this defect in branch 5.2.5 of hibernate-orm module.

Following is the error message:
Code:
javax.persistence.PersistenceException: org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
  at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
  at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
  at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1407)
  at org.hibernate.Query.getResultList(Query.java:427)
  at com.sant.jinglebell.domain.entity.PolicyDataTest.test(PolicyDataTest.java:26)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
  at org.hibernate.dialect.TypeNames.get(TypeNames.java:70)
  at org.hibernate.dialect.TypeNames.get(TypeNames.java:101)
  at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:683)
  at org.hibernate.loader.custom.JdbcResultMetadata.getHibernateType(JdbcResultMetadata.java:77)
  at org.hibernate.loader.custom.ScalarResultColumnProcessor.performDiscovery(ScalarResultColumnProcessor.java:45)
  at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:486)
  at org.hibernate.loader.Loader.getResultSet(Loader.java:2131)
  at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1911)
  at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1887)
  at org.hibernate.loader.Loader.doQuery(Loader.java:932)
  at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349)
  at org.hibernate.loader.Loader.doList(Loader.java:2615)
  at org.hibernate.loader.Loader.doList(Loader.java:2598)
  at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2430)
  at org.hibernate.loader.Loader.list(Loader.java:2425)
  at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:335)
  at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2142)
  at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:991)
  at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:147)
  at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1398)
  ... 25 more


And my environment:
  • Windows 7 x64
  • Eclipse IDE MARS r2
  • SQLServer 2014 x64
  • Microsoft SQL Server Driver 6.1

When the exception has been triggered, I tracked the error message in stack. And there are some lines could be tracked in source code.
  • Types.java line: 286
  • AbstractTransactSQLDialect.java line: 41
  • SQLServerDialect.java line:41
  • Dialect.java line: 216

Usually, I will create a sub-class to extend SQLServerDialect.
Code:
public class SQLServerJDBC4Dialect extends SQLServerDialect {

    public SQLServerJDBC4Dialect() {
        super();
        registerHibernateType(-9, "string");
        registerHibernateType(Types.NVARCHAR, StandardBasicTypes.STRING.getName());
    }
}


After some digging, I think this defect could be fixed in source code. I plan to do some changes in the above files and test in my local.

What do you think? Could I get a invitation for this defect fixing?

Your ideas are welcome!


Thanks,
Max


Top
 Profile  
 
 Post subject: Re: Mapping Exception: No Dialect mapping for JDBC type -9
PostPosted: Mon Jan 09, 2017 7:33 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
There's the [ur=https://hibernate.atlassian.net/browse/HHH-10183]HHH-10183[/url] issue for this problem. I added a replicating test case as well. Would you mind providing a fix in a Pull Request?

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Mapping Exception: No Dialect mapping for JDBC type -9
PostPosted: Mon Jan 09, 2017 10:03 pm 
Newbie

Joined: Mon Jan 09, 2017 2:37 am
Posts: 3
vlad wrote:
There's the [ur=https://hibernate.atlassian.net/browse/HHH-10183]HHH-10183[/url] issue for this problem. I added a replicating test case as well. Would you mind providing a fix in a Pull Request?


I found that I also could map those columns which are defined as nvarchar to nstring. And I could not use my customized SQLServerDialect.

But, I think this fix is still needed. I will commit my changes later.


Top
 Profile  
 
 Post subject: Re: Mapping Exception: No Dialect mapping for JDBC type -9
PostPosted: Tue Jan 10, 2017 4:44 am 
Newbie

Joined: Mon Jan 09, 2017 2:37 am
Posts: 3
vlad wrote:
There's the [ur=https://hibernate.atlassian.net/browse/HHH-10183]HHH-10183[/url] issue for this problem. I added a replicating test case as well. Would you mind providing a fix in a Pull Request?


I created a pull request Pull Request.

It comes from the topic branch of my hibernate-orm fork.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.