简体   繁体   中英

Question marks in place of unicode(Hindi ) characters in JPA query in Spring?

I am using hindi characters in where clause in JPA query .When i print the queries in connsole using show jpa the chars are being replaced by ????.

I have used

value="${jdbc.url};databaseName=${jdbc.databaseName};useUnicode=true;characterEncoding=UTF-8" 

In jdbc url but its not solving the problem.

Following the console output.

Hibernate: select facilitysc0_.blockId as col_0_0_, formxpaths1_.xPath as col_1_0_, formxpaths1_.label as col_2_0_, formxpaths1_.formXpathScoreId as col_3_0_, case when ?='all' then case when formxpaths1_.xPath not in (? , ? , ? , ?) then CONVERT(float, count(case when facilitysc0_.score='???' then 1 end))/CONVERT(float, count(case when facilitysc0_.score='???' or facilitysc0_.score='????' or facilitysc0_.score='???? ????' or facilitysc0_.score='' then 1 end))*100 else CONVERT(FLOAT, count(case when facilitysc0_.score='???' then 1 end))/CONVERT(FLOAT, count(case when facilitysc0_.score='???' or facilitysc0_.score='????' then 1 end))*100 end else CONVERT(FLOAT, count(case when facilitysc0_.score='???' then 1 end))/CONVERT(FLOAT, count(case when facilitysc0_.score='???' or facilitysc0_.score='????' then 1 end))*100 end as col_4_0_, case when ?='all' then count(case when facilitysc0_.score='???' or facilitysc0_.score='????' or facilitysc0_.score='???? ????' or facilitysc0_.score='' then 1 end) else count(case when facilitysc0_.score='???' or facilitysc0_.score='????' then 1 end) end as col_5_0_, count(case when facilitysc0_.score='???' then 1 end) as col_6_0_ from FacilityScore facilitysc0_ inner join FormXpathScoreMapping formxpaths1_ on facilitysc0_.formXpathScoreId=formxpaths1_.formXpathScoreId inner join LastVisitData lastvisitd2_ on facilitysc0_.lastVisitDataId=lastvisitd2_.LastVisitDataId where formxpaths1_.formId=? and (formxpaths1_.type like 'select_one yes_no%') and ((facilitysc0_.score in (? , ?)) and (formxpaths1_.xPath in (? , ? , ? , ?)) or (facilitysc0_.score in (? , ? , ? , ?)) and (formxpaths1_.xPath not in (? , ? , ? , ?)) and ?='all' or facilitysc0_.score in (? , ?)) and (lastvisitd2_.DateOfVisit between ? and ?) and lastvisitd2_.IsLive=1 group by facilitysc0_.blockId , formxpaths1_.xPath , formxpaths1_.label , formxpaths1_.formXpathScoreId

Please help.

Try to change your JDBC URL to

value="${jdbc.url};databaseName=${jdbc.databaseName};useUnicode=yes;characterEncoding=UTF-8"

Note the useUnicode= yes

Use the following connectionProperties for enabling unicode

useUnicode=yes;
characterEncodinng=UTF-8

by default the parameter values are hidden and to check the values that are being binded, logging is to be enabled with the the log4j.properties

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n


# Root logger option
log4j.rootLogger=INFO, stdout

# Hibernate logging options (INFO only shows startup messages)
log4j.logger.org.hibernate=INFO

# Log JDBC bind parameter runtime arguments
log4j.logger.org.hibernate.type=trace

or import p6spy jar and update the spy.properties with corresponding jdbc driver and log file location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM