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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 17:06:10  来源:igfitidea点击:

org.hibernate.MappingException:No Dialect mapping for JDBC type: 1111

javahibernate

提问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

You have to specify your custom column type using org.hibernate.usertype.UserTypeclass provided by hibernate.

您必须使用org.hibernate.usertype.UserTypehibernate 提供的类来指定您的自定义列类型。

Hereis very good example.

是一个很好的例子。

Thanks.

谢谢。

回答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定义连接方言“ ”。