?
Solved

Hibernate localization

Posted on 2006-11-29
14
Medium Priority
?
622 Views
Last Modified: 2013-11-24
Hi,
    I am inserting the thai data into the database thru hibernate. This is working absolutely fine. When i am trying to retrieve the thai data from the database It is displaying some junk characters. Probably while data is set into the data objects the UTF-8 conversion is required. How do i go about with this.

Hibernate version: 3.1.2

Name and version of the database you are using: Oracle 10g


Thank U,
Parimala
0
Comment
Question by:seekingsolution
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +2
14 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 18035923
set charset on the hibernate.cfg.xml

<property name="hibernate.connnection.charSet">UTF-8</property>
0
 

Author Comment

by:seekingsolution
ID: 18043056
The following is my sessionfactory

<bean id="sessionFactory"
            class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource">
                  <ref bean="dataSource" />
            </property>
            <property name="mappingDirectoryLocations">
                  <list>
                        <value>dataObjects</value>
                  </list>
            </property>

            <property name="hibernateProperties">
                  <props>
                        <prop key="hibernate.show_sql">
                              ${hibernate.show_sql}
                        </prop>
                        <prop key="hibernate.dialect">
                              ${hibernate.dialect}
                        </prop>

                        <prop key="jta.UserTransaction">
                              java:comp/UserTransaction
                        </prop>
                        <prop key="hibernate.connnection.charSet">UTF-8</prop>
                                                <prop key="hibernate.transaction.factory_class">
                              org.hibernate.transaction.JTATransactionFactory
                        </prop>

                        
                        <prop key="hibernate.cache.use_structured_entries">
                              true
                        </prop>
                        <prop key="hibernate.generate_statistics">true</prop>
                        <prop key="hibernate.cache.use_minimal_puts">true</prop>
                        <prop key="hibernate.query.factory_class">
                              org.hibernate.hql.classic.ClassicQueryTranslatorFactory
                        </prop>

                  </props>
            </property>
      </bean>

I am getting all question marks :-(

0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 18043068
> I am getting all question marks :-(
where?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:seekingsolution
ID: 18043897
in the result page the where i am displaying the data.

I am using User Transaction, not using the direct connection.
All this is with the combination of spring

0
 
LVL 35

Expert Comment

by:girionis
ID: 18043903
IS the problem in the database or in the display page? Can you read the characters in the dataabse?
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 18043935
how are you printing the response - may be there there is loss of data.
0
 

Author Comment

by:seekingsolution
ID: 18044310
result is a DO
<ibaBean:write name="result" property="utfText" />
0
 
LVL 12

Expert Comment

by:Gibu George
ID: 18044447
What is the output when you directly query it from the db? is that also giving the same special characters, then the CHAR SET used by the db and that by hibernate is different, execute the following query and find the charatecter set used by db and use the same

SELECT VALUE
  FROM nls_database_parameters
 WHERE parameter = 'NLS_CHARACTERSET'
0
 

Author Comment

by:seekingsolution
ID: 18052518
There ia no problem with Hibernate in this case.
This is all due to Struts. It's resolved.
Thanks and sorry
0
 
LVL 35

Expert Comment

by:girionis
ID: 18052586
Can you post the solution?
0
 

Author Comment

by:seekingsolution
ID: 18052623
Here it goes


Added the filter in the web.xml
      <filter>
            <filter-name>UTF8Filter</filter-name>
            <filter-class>
                  filters.UTF8Filter
            </filter-class>
      </filter>



public class UTF8Filter implements Filter {

      public void destroy() {
      }

      public void doFilter(ServletRequest request, ServletResponse response,
                  FilterChain chain) throws IOException, ServletException {
            request.setCharacterEncoding("UTF8");
            chain.doFilter(request, response);
      }

      public void init(FilterConfig filterConfig) throws ServletException {
      }

}
0
 
LVL 35

Expert Comment

by:girionis
ID: 18052664
Nice :)

Please ask a question in Community Support (http://www.experts-exchange.com/Community_Support/) to PAQ this question and refund the points to you.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18368405
PAQed with points refunded (125)

DarthMod
Community Support Moderator
0

Featured Post

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question