关于Hibernate的 No Dialect mapping for JDBC type: -1 知道的进!
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
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:192)
at org.hibernate.loader.custom.CustomLoader.getHibernateType(CustomLoader.java:161)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:131)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1678)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
at com.book.Interface.impl.BookImpl.selectRondomBook(BookImpl.java:102)
at com.book.test.TestOfBook.testBookRondom(TestOfBook.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
就是这么一个错误。。。请问?什么意思?我 抓耳挠腮中...分数给70...
[解决办法]
你hibernate配置的方言是否正确呢?
[解决办法]
不同的数据库有不同的方言支持,检查你的配置``
[解决办法]
个人认为:用什么数据库就用什么方言!
<property name= "dialect ">
org.hibernate.dialect.?Dialect
</property>
[解决办法]
检查你的hibernate.hbm.xml里的配置信息
[解决办法]
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
这是一个sqlserver2005
你的hibernate配置文件是手写的么!
不同的数据库有不同的方言!
[解决办法]
影射文件xml 有类型错误!
[解决办法]
createSQLQuery SQL语句
createQuery HQL语句
------解决方案--------------------
我看了错误信息有很多关于list的,网上帮你搜了一下,希望对你有所帮助。
createQuery与createSQLQuery两者区别是:
前者用的hql语句进行查询,后者可以用sql语句查询
前者以hibernate生成的Bean为对象装入list返回
后者则是以对象数组进行存储
所以使用createSQLQuery有时候也想以hibernate生成的Bean为对象装入list返回,就不是很方便
突然发现createSQLQuery有这样一个方法可以直接转换对象
Query query = session.createSQLQuery(sql).addEntity(XXX.class);
XXX 代表以hibernate生成的Bean的对象,也就是数据表映射出的Bean。
[解决办法]
看看你的查询语句是“from ‘实体’”的不?要是的话就得使用createQuery