- 在Mybatis的全局配置文件mybatis-config.xml中加入
<configuration> <settings> <setting name="mapUnderscoreToCamelCase" value="true"/> </settings> </configuration>
- ssm整合项目中,在spring-mybatis.xml文件中
<property name="configuration"> <bean class="org.apache.ibatis.session.Configuration"> <!--可以加入驼峰命名法其他mybatis的配置也就是mybatis.cfg.xml的相关配置都会转移到这里--> <property name="mapUnderscoreToCamelCase" value="true"/> </bean> </property>
<select id="queryByName" resultType="com.yangfan.pojo.User"> select * from user <where> <if test="userName !=null and userName!=''"> and user_name = #{
userName} </if> </where> </select>
这样通过sql语句查询的结果中的带下划线字段 就可以映射上User类以驼峰命名的属性了,但是不可以写成 select * from user where userName=#{userName}
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/209352.html原文链接:https://javaforall.net
