背景:
1.在數(shù)據(jù)庫中有一個通知表

可以看到其中的
- gmt_create、
- notifier_name、
- outer_title
這三個字段是有下劃線的
2.這張表對應(yīng)的實體類為
public class Notification {
private Long id;
private Long notifier;
private Long receiver;
private Long outerId;
private Integer type;
private Long gmtCreate;
private Integer status;
private String notifierName;
private String outerTitle;
}
在寫實際java代碼命名采用駝峰命名
注意application.properties是否開啟了駝峰映射
#駝峰映射
mybatis.configuration.map-underscore-to-camel-case=true
3.在Mapper中有一個插入語句
//0.插入一條通知
@Insert("insert into questions (title,description,gmt_create,gmt_modified,creator,tag) values (#{title},#{description},#{gmtCreate},#{gmtModified},#{creator},#{tag})")
void createQuestion(Question question);
結(jié)論:在進行占位時#{}中的內(nèi)容應(yīng)為gmtCreate
寫的時候留心下,寫成gmt_create可能會報錯
There is no getter for property named 'gmt_create' in 'class com.example.com
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:- MyBatis直接執(zhí)行SQL的工具SqlMapper
- 詳解 MapperScannerConfigurer之sqlSessionFactory注入方式
- Mybatis中SqlMapper配置的擴展與應(yīng)用詳細(xì)介紹(1)
- 使用XSD校驗Mybatis的SqlMapper配置文件的方法(2)
- 使用XSD校驗Mybatis的SqlMapper配置文件的方法(1)
- 詳解MyBatis的getMapper()接口、resultMap標(biāo)簽、Alias別名、 盡量提取sql列、動態(tài)操作
- MyBatis MapperProvider MessageFormat拼接批量SQL語句執(zhí)行報錯的原因分析及解決辦法