java org.hibernate.MappingException:没有 JDBC 类型的方言映射:1111
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6743026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
org.hibernate.MappingException:No Dialect mapping for JDBC type: 1111
提问by lakshmi
I am using postgres v8.3 which has a columntype as XML. DDL looks like this:
我正在使用 postgres v8.3,它的列类型为 XML。DDL 看起来像这样:
CREATE TABLE contact (
"ID" INTEGER NOT NULL ,
"NAME" VARCHAR NOT NULL,
"Details" XML , ......
In the mapping hbm.xml file I map it like this:
在映射 hbm.xml 文件中,我像这样映射它:
<key-property name="Details" type="java.lang.String" >
<column name="Details" />
</key-property>
and I guess this is the reason of error : No Dialect mapping for JDBC type: 1111 when I run a select query using :
我猜这是错误的原因:当我使用以下命令运行选择查询时,JDBC 类型没有方言映射:1111:
List<?> contactList= session.createSQLQuery("select * from contact where id=" + val.getId() + " and name= '" + val.getName + "'").list();
but what is the other way I can map "XML" type to a java datatype ?
但是我可以将“XML”类型映射到 java 数据类型的另一种方式是什么?
回答by nIKUNJ
回答by Anand singh
Use addScalar();
Use addScalar();
For example
例如
session.createSQLQuery("select public.flcpool_backup()")
.addScalar("id", Hibernate.BIG_INTEGER)
.addScalar("caf_tbl_id", Hibernate.BIG_INTEGER)
.executeUpdate();
回答by Harry Joy
Try defining connection dialect "hibernate.dialect
" in hibernate.cfg.xml for postgres.
尝试hibernate.dialect
在 hibernate.cfg.xml 中为 postgres定义连接方言“ ”。