seekingsolution
asked on
Hibernate localization
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
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
ASKER
The following is my sessionfactory
<bean id="sessionFactory"
class="org.springframework .orm.hiber nate3.Loca lSessionFa ctoryBean" >
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingDirectoryLoca tions">
<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</pro p>
<prop key="hibernate.transaction .factory_c lass">
org.hibernate.transaction. JTATransac tionFactor y
</prop>
<prop key="hibernate.cache.use_s tructured_ entries">
true
</prop>
<prop key="hibernate.generate_st atistics"> true</prop >
<prop key="hibernate.cache.use_m inimal_put s">true</p rop>
<prop key="hibernate.query.facto ry_class">
org.hibernate.hql.classic. ClassicQue ryTranslat orFactory
</prop>
</props>
</property>
</bean>
I am getting all question marks :-(
<bean id="sessionFactory"
class="org.springframework
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingDirectoryLoca
<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
<prop key="hibernate.transaction
org.hibernate.transaction.
</prop>
<prop key="hibernate.cache.use_s
true
</prop>
<prop key="hibernate.generate_st
<prop key="hibernate.cache.use_m
<prop key="hibernate.query.facto
org.hibernate.hql.classic.
</prop>
</props>
</property>
</bean>
I am getting all question marks :-(
> I am getting all question marks :-(
where?
where?
ASKER
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
I am using User Transaction, not using the direct connection.
All this is with the combination of spring
IS the problem in the database or in the display page? Can you read the characters in the dataabse?
how are you printing the response - may be there there is loss of data.
ASKER
result is a DO
<ibaBean:write name="result" property="utfText" />
<ibaBean:write name="result" property="utfText" />
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'
SELECT VALUE
FROM nls_database_parameters
WHERE parameter = 'NLS_CHARACTERSET'
ASKER
There ia no problem with Hibernate in this case.
This is all due to Struts. It's resolved.
Thanks and sorry
This is all due to Struts. It's resolved.
Thanks and sorry
Can you post the solution?
ASKER
Here it goes
Added the filter in the web.xml
<filter>
<filter-name>UTF8Filter</f ilter-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.setCharacterEncodi ng("UTF8") ;
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
}
}
Added the filter in the web.xml
<filter>
<filter-name>UTF8Filter</f
<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.setCharacterEncodi
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
}
}
Nice :)
Please ask a question in Community Support (https://www.experts-exchange.com/Community_Support/) to PAQ this question and refund the points to you.
Please ask a question in Community Support (https://www.experts-exchange.com/Community_Support/) to PAQ this question and refund the points to you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<property name="hibernate.connnectio