在spring集成hibernate 中,如果包含中文参数查询不出结果

我的项目在spring4.3.5中集成hibernate4.3.11,其中如果包含中文参数查询不出任何结果

下面方法的参数username如果是字母可以正常读取到数据,如果是中文则uniqueResult为null。

我谷歌了网上说的都是使用setString 设置参数就不会有中文问题了,可我本来就是用的是setString方法设置参数的,请求各位大侠赐教

 @Override
    public void updateUserAccount(String username, int price) {
        // 验证余额是否足够
        String hql = "select a.balance from Account a where a.username=?";
        Object uniqueResult = getSession().createQuery(hql).setString(0, username).uniqueResult();
        int balance = (int) uniqueResult;
        if (balance < price) {
            throw new RuntimeException("用户名为:" + username + "的用户余额不足");
        }

        hql = "update Account a set a.balance = a.balance - ? where a.username=?";
        getSession().createQuery(hql).setParameter(0, price).setParameter(1, username).executeUpdate();
    }

下面是spring的配置文件中已经设置了使用utf-8

 <!-- 配置hibernate sessionFactory的实例 -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <!-- 配置数据源属性 -->
        <property name="dataSource" ref="dataSource"></property>
        <!-- 配置hibernate的配置文件路径及名称 -->
        <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
        <!-- 配置hibernate 映射文件的位置及名称 -->
        <property name="mappingLocations"
            value="classpath:com/atguigu/spring/hibernate/entity/*.hbm.xml"></property>

        <property name="hibernateProperties">
            <props>
                <prop key="connection.useUnicode">true</prop>
                <prop key="connection.characterEncoding">UTF-8</prop>
            </props>
        </property>
    </bean>

可以和ssh没有关系,如果是mysql数据库是否编码有问题哦
http://www.cnblogs.com/qmfsun/p/4846467.html

可以去控制台吧sql执行语句打印出来看下执行的是什么