发帖    主题    评论    推荐    标签    作者    订阅    查搜    注册   登陆   关注
 
面向对象 设计模式 领域驱动设计 企业架构 框架 开发教程 微服务 大数据 扩展性 并发编程 事件驱动 分布式 SOA

hibernate 2.0 + Oracle 8.1.7中文显示问题

2003-06-16 16:52
赞助商链接

部分原码如下
...
Query query = session.createQuery("from " + CLASS_NAME + " a ");
query.setFirstResult(from);
query.setMaxResults(max);

return query.list();

...

利用Hibernate的分页查询功能从零开始,每次20条
第一页显示正常,可是翻页之后,String型的字段显示都是乱码

但是我在HyperSQL上同样的代码,同样的的数据,就没有上述问题
我不知道是Oracle的配置没到位,还是Hibernate或JDBC的问题
还请各位高手指教

2003-06-17 09:24

我也这么用了啊!没有问题啊!我的环境也是hibernate2+oracle8.17还有oracle901都没有问题。

是不是你的oracle安装的有问题呢?
你看看oracle的nls_lang是否设置正确了!

2003-06-17 15:06

Oracle 的字符集我已经设过了:ZHS16GBK,我写了单独的测试代码直接用JDBC来测试,发现取出来得中文显示正常。
下面是Hibernate打印的部分消息

2003-06-17 13:37:32,049 DEBUG [net.sf.hibernate.hql.QueryTranslator] SQL: select a.id as id, a.chanel as chanel, a.class_id as class_id, a.class_name as class_name, a.comments as comments, a.host_id as host_id, a.host_name as host_name, a.model_id as model_id, a.model_name as model_name, a.model_type as model_type, a.operate as operate, a.parm as parm, a.sou_path as sou_path, a.state as state, a.tgt_filename as tgt_fil15_, a.tgt_path as tgt_path from view_model a
2003-06-17 13:37:32,049 DEBUG [net.sf.hibernate.impl.BatcherImpl] 1 open PreparedStatements
2003-06-17 13:37:32,049 DEBUG [net.sf.hibernate.connection.DriverManagerConnectionProvider] total checked-out connections: 0
2003-06-17 13:37:32,049 DEBUG [net.sf.hibernate.connection.DriverManagerConnectionProvider] using pooled JDBC connection, pool size: 0
2003-06-17 13:37:32,049 DEBUG [net.sf.hibernate.impl.SessionFactoryImpl] scrollable prepared statement get: select a.id as id, a.chanel as chanel, a.class_id as class_id, a.class_name as class_name, a.comments as comments, a.host_id as host_id, a.host_name as host_name, a.model_id as model_id, a.model_name as model_name, a.model_type as model_type, a.operate as operate, a.parm as parm, a.sou_path as sou_path, a.state as state, a.tgt_filename as tgt_fil15_, a.tgt_path as tgt_path from view_model a
2003-06-17 13:37:32,049 INFO [STDOUT] Hibernate: select a.id as id, a.chanel as chanel, a.class_id as class_id, a.class_name as class_name, a.comments as comments, a.host_id as host_id, a.host_name as host_name, a.model_id as model_id, a.model_name as model_name, a.model_type as model_type, a.operate as operate, a.parm as parm, a.sou_path as sou_path, a.state as state, a.tgt_filename as tgt_fil15_, a.tgt_path as tgt_path from view_model a
2003-06-17 13:37:32,049 DEBUG [net.sf.hibernate.impl.SessionFactoryImpl] preparing statement
2003-06-17 13:37:32,059 DEBUG [net.sf.hibernate.loader.Loader] processing result set
2003-06-17 13:37:32,059 DEBUG [net.sf.hibernate.type.IntegerType] returning '2' as column: id
2003-06-17 13:37:32,059 DEBUG [net.sf.hibernate.loader.Loader] result row: 2
2003-06-17 13:37:32,059 DEBUG [net.sf.hibernate.loader.Loader] Initializing object from ResultSet: 2
2003-06-17 13:37:32,059 DEBUG [net.sf.hibernate.loader.Loader] Hydrating entity: com.linkage.rmon.basedata.domain.ViewModel#2
2003-06-17 13:37:32,059 DEBUG [net.sf.hibernate.type.StringType] returning '0x303032202020202020' as column: chanel
2003-06-17 13:37:32,069 DEBUG [net.sf.hibernate.type.StringType] returning '0x313130202020202020' as column: class_id
2003-06-17 13:37:32,069 DEBUG [net.sf.hibernate.type.StringType] returning '0xE9A284E5A484E79086' as column: class_name
2003-06-17 13:37:32,069 DEBUG [net.sf.hibernate.type.StringType] returning '0x4151' as column: comments
2003-06-17 13:37:32,069 DEBUG [net.sf.hibernate.type.StringType] returning '0x303031202020202020202020' as column: host_id
2003-06-17 13:37:32,079 DEBUG [net.sf.hibernate.type.StringType] returning '0x4850E4B8BBE69CBA' as column: host_name
2003-06-17 13:37:32,079 DEBUG [net.sf.hibernate.type.StringType] returning '0x303032202020202020202020' as column: model_id
2003-06-17 13:37:32,079 DEBUG [net.sf.hibernate.type.StringType] returning '0xE58699E69687E4BBB6E587BAE99499E5918AE8ADA6' as column: model_name
2003-06-17 13:37:32,079 DEBUG [net.sf.hibernate.type.StringType] returning '0x303120202020' as column: model_type

我在Class_Path中加入nsl_charset12.zip(Oracle_JDBC自带)后,英文正常了,中文问题依然没解决

2003-06-17 15:09

to:fishandfly
你那边都没有作特殊设置就可以正常显示吗?
我这里别的都没关系,只要翻页,中文全变乱麻

2003-06-18 14:31

我的nsl_lang:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
你在sqlplus中能显示中文吗?

你是否说用unit test可以显示中文,那么在那里不能显示中文呢?如果是web应用,在jsp端也要做处理的。

我什么都没有设置,oracle+hibernate就可以显示中文的!在控制台打印出来也是中文的!

赞助商链接

赞助商链接

返回顶部

移动版 关于本站 使用帮助 联系管理员 最佳分辨率1366x768
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-20 jdon.com