Mybatis 一对一 、一对多查询



"http://mybatis.org/dtd/mybatis-3-mapper.dtd">









































































select="cn.tramp.iblog.dao.IBlogMapper.queryForBlogByUserID" />


role_id, user_name, password
]]>






INSERT INTO iblog_user(role_id,user_name,password,user_nickname,gender,user_email,
user_birthday, photo_path, is_show_birthday, marriage_state, occupation, live_place,
native_place, personal_intro, is_lock)
VALUES(
#{role_id},
#{user_name},
#{password},
#{user_nickname},
#{gender},
#{user_email},
#{user_birthday},
#{photo_path},
#{is_show_birthday},
#{marriage_state},
#{occupation},
#{live_place},
#{native_place},
#{personal_intro},
#{is_lock}
)



UPDATE iblog_user SET
role_id = #{role_id},
user_name = #{user_name},
password = #{password},
user_nickname = #{user_nickname},
gender = #{gender},
user_email = #{user_email},
user_birthday = #{user_birthday},
photo_path = #{photo_path},
is_show_birthday = #{is_show_birthday},
marriage_state = #{marriage_state},
occupation = #{occupation},
live_place = #{live_place},
native_place = #{native_place},
personal_intro = #{personal_intro},
is_lock = #{is_lock}
WHERE user_id = #{user_id}













DELETE FROM iblog_user WHERE user_id = #{user_id}





"http://mybatis.org/dtd/mybatis-3-mapper.dtd">


























select="cn.tramp.iblog.dao.IUserMapper.queryForObject"/>


































role_id, user_name, password
]]>




INSERT INTO iblog_blog(user_id,blog_type_id,blog_title,key_words,blog_content,post_datetime,
edit_datetime, read_times, comment_times)
VALUES(
#{user_id},
#{blog_type_id},
#{blog_title},
#{key_words},
#{blog_content},
#{post_datetime},
#{edit_datetime},
#{read_times},
#{comment_times}
)



UPDATE iblog_blog SET
user_id = #{user_id},
blog_type_id = #{blog_type_id},
blog_title = #{blog_title},
key_words = #{key_words},
blog_content = #{blog_content},
post_datetime = #{post_datetime},
read_times = #{read_times},
comment_times = #{comment_times}
WHERE blog_id = #{blog_id}









DELETE FROM iblog_blog WHERE blog_id = #{blog_id}


你可能感兴趣的:(Mybatis)