MyBatis中的注解
生活随笔
收集整理的這篇文章主要介紹了
MyBatis中的注解
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
代碼實(shí)現(xiàn)
1. @Select("select * from student") 2. List<Student> selectAll(); 3. 4. @Select("select * from student where sid=#{param1}") 5. Student selectOne(int id); 6. 7. @Insert("insert into student values(default,#{sname},#{clazzno})") 8. int insert(Student student); 9. 10. @Update("update student set sname=#{sname} where sid=#{sid}") 11. int update(Student student); 12. 13. @Delete("delete from student where sid=#{param1}") 14. int delte(int sid);02注解使用的優(yōu)缺點(diǎn)
[1] 使用注解沒(méi)有實(shí)現(xiàn)java代碼個(gè)sql語(yǔ)句的解耦
[2] 進(jìn)行多表的查詢(xún)比較的麻煩
[3] 無(wú)法實(shí)現(xiàn)sql語(yǔ)句的動(dòng)態(tài)拼接
總結(jié)
以上是生活随笔為你收集整理的MyBatis中的注解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: MyBatis中ThreadLocal
- 下一篇: MyBatis中的原理