discuss-mapper.xml 中的sql
<sql id="selectFields">
id, user_id, title, content, type, status, create_time, comment_count, score, kind_one, kind_two
</sql>
<select id="selectDiscussPosts" resultType="DiscussPost">
select <include refid="selectFields"></include>
from discuss_post
where status != 2
<if test="userId!=0">
and user_id = #{userId}
</if>
and kind_one = #{kind_one}
and kind_two = #{kind_two}
<if test="orderMode==0">
order by type desc, create_time desc
</if>
<if test="orderMode==1">
order by type desc, score desc, create_time desc
</if>
limit #{offset}, #{limit}
</select>
entity中的:
@Id
private int id;
@Field(type = FieldType.Integer)
private int userId;
// 互聯網校招
@Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
private String title;
@Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
private String content;
@Field(type = FieldType.Integer)
private int type;
@Field(type = FieldType.Integer)
private int status;
@Field(type = FieldType.Date)
private Date createTime;
@Field(type = FieldType.Integer)
private int commentCount;
@Field(type = FieldType.Double)
private double score;
test代碼: DiscussPost discussPost = discussPostService.findDiscussPostById(289);
int id = discussPost.getKind_one();
System.out.println(discussPost);
輸出:DiscussPost{id=289, userId=150, title='222111', content='222', type=7, status=0, createTime=Wed Jul 08 22:27:01 GMT+08:00 2020, commentCount=0, score=0.0, kind_one=0, kind_two=0}
但是資料庫中的kind_one是1
為什么會出現這樣的問題呢
uj5u.com熱心網友回復:
先看欄位對應,或者欄位是否寫錯,然后再看其他問題uj5u.com熱心網友回復:
entity類里確定有kind_one欄位嗎?你代碼里是沒有的轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/41402.html
標籤:Web 開發
下一篇:cannot retrive initial cluster cluster partitions from initial uris
