Hibernate Oracle 和字符编码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1225071/
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-09-18 18:42:39  来源:igfitidea点击:

Hibernate Oracle and Character Encoding

oraclehibernateencoding

提问by Mark

Im having an issue at the moment where my testing environment is not persisting the trademark character "?" in the database. When I enter in the form data, then submit it, I can see that on the server side, the request has the correctly encoded ? character, but then when the call to hibernate's "saveOrUpdate()" method is called, the data in the table shows up as an upside down question mark.

在我的测试环境没有保留商标字符“?”时,我遇到了一个问题。在数据库中。当我输入表单数据然后提交时,我可以看到在服务器端,请求的编码正确?字符,但是当调用 hibernate 的“saveOrUpdate()”方法时,表中的数据显示为倒置的问号。

Im using SqlDeveloper to inspect the table, and I can manually change the character to a ? by pasting directly into the row then committing, and it works.

我使用 SqlDeveloper 检查表,我可以手动将字符更改为 ? 通过直接粘贴到行然后提交,它的工作原理。

So I have made the assumption that hibernates methods of persistence are not working correctly.

所以我假设休眠的持久性方法不能正常工作。

Im at a loss here, really, I just dont know what to try, I have set the:

我在这里不知所措,真的,我只是不知道该尝试什么,我已经设置了:

<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">utf-8</property>

properties in the config file, with no luck.

配置文件中的属性,没有运气。

My columns in the tables are NVARCHAR2(400 CHAR) (although they were originally, just VARCHAR2 to start with, but I changed them during the debugging of this issue).

我在表中的列是 NVARCHAR2(400 CHAR)(虽然它们最初只是 VARCHAR2,但我在调试这个问题的过程中改变了它们)。

Any help here is greatly appreciated.

非常感谢这里的任何帮助。

Mark

标记

采纳答案by Mark

Ok, so it turns out that what I needed to do was to set the defaultNCharconnection property to true.

好的,事实证明我需要做的是将defaultNChar连接属性设置为true

I did this via the context file for my app in Tomcat.

我是通过 Tomcat 中我的应用程序的上下文文件完成的。

The article that enlightened me was here.

启发我的文章在这里