MyBatisGenerator£¨MBG£©ÊÇMyBatis´úÂëÉú³ÉÆ÷¡£
Ëü¿ÉÒÔ°ïÖúÎÒÃǸù¾ÝÊý¾Ý¿âÖбíµÄÉè¼ÆÉú³É¶ÔÓ¦µÄʵÌåÀ࣬xml MapperÓ³ÉäÎļþ£¬½Ó¿ÚÒÔ¼°°ïÖúÀà(Ò²¾ÍÊÇÎÒÃÇ¿ÉÒÔ½èÖú¸ÃÀàÀ´½øÐмòµ¥µÄCRUD²Ù×÷)£¬ÕâÑù¾Í±ÜÃâÁËÎÒÃÇÿʹÓõ½Ò»ÕűíµÄÊý¾Ý¾ÍÐèÒªÊÖ¶¯È¥´´½¨¶ÔÓ¦µÄÀàºÍxmlÓ³ÉäÎļþ£¬°ïÖúÎÒÃǽÚÔ¼ÁË´óÁ¿µÄʱ¼äÈ¥¿ª·¢ºÍÒµÎñÂß¼ÓйصŦÄÜ£¬µ«ÊÇÈç¹û¶ÔÁªºÏ²éѯ»òÕßÌ«¹ý¸´ÔӵIJéѯ£¬ÈÔÈ»ÐèÒªÊÖдSQLºÍ¶ÔÏó¡£
MBGµÄ¹¦Ó÷dz£µÄÇ¿´ó£¬ÔÚÓÚËüÌṩÁ˸÷ÖÖ¸÷Ñù¶ÔÊý¾Ý±íµÄCURD²Ù×÷¡£ÕâÀ¾ÍÁгöһЩMBG×î³£Óõķ½·¨£¬¹©´ó¼Ò²Î¿¼£º
1. Êý¾Ý¿â²Ù×÷·½·¨
MBGÌṩÁ˷dz£¶àµÄ·½·¨£¬ÈÃÎÒÃÇ¿ÉÒÔʵÏÖ²»Í¬µÄ²Ù×÷£¬ÏÂÃæÁгöMBGµÄһЩ·½·¨£¬¹©´ó¼Ò²Î¿¼£º
·½·¨ | ¹¦ÄÜ˵Ã÷ |
int countByExample(UserExample example) thorws SQLException | °´Ìõ¼þ¼ÆÊý |
int deleteByPrimaryKey(Integer id) thorws SQLException | °´Ö÷¼üɾ³ý |
int deleteByExample(UserExample example) thorws SQLException | °´Ìõ¼þɾ³ý |
String/Integer insert(User record) thorws SQLException | ²åÈëÊý¾Ý£¨·µ»ØֵΪID£© |
User selectByPrimaryKey(Integer id) thorws SQLException | °´Ö÷¼ü²éѯ |
ListselectByExample(UserExample example) thorws SQLException | °´Ìõ¼þ²éѯ |
ListselectByExampleWithBLOGs(UserExample example) thorws SQLException | °´Ìõ¼þ²éѯ£¨°üÀ¨BLOB×ֶΣ©¡£Ö»Óе±Êý¾Ý±íÖеÄ×Ö¶ÎÀàÐÍÓÐΪ¶þ½øÖƵIJŻá²úÉú¡£ |
int updateByPrimaryKey(User record) thorws SQLException | °´Ö÷¼ü¸üР|
int updateByPrimaryKeySelective(User record) thorws SQLException | °´Ö÷¼ü¸üÐÂÖµ²»ÎªnullµÄ×ֶΠ|
int updateByExample(User record, UserExample example) thorws SQLException | °´Ìõ¼þ¸üР|
int updateByExampleSelective(User record, UserExample example) thorws SQLException | °´Ìõ¼þ¸üÐÂÖµ²»ÎªnullµÄ×ֶΠ|
2.Ìí¼ÓÌõ¼þµÄ·½·¨
ÉÏÃæÊDzÙ×÷Êý¾Ý¿âµÄ·½·¨£¬¶øÈç¹ûÒª¸øCURDÌí¼ÓһЩÌõ¼þ£¬¾ÍÐèҪʹÓõ½ÕâЩ·½·¨£º
·½·¨ | ˵Ã÷ |
example.setOrderByClause(¡°×Ö¶ÎÃû ASC¡±); | Ìí¼ÓÉýÐòÅÅÁÐÌõ¼þ£¬DESCΪ½µÐò |
example.setDistinct(false) | È¥³ýÖظ´£¬booleanÐÍ£¬trueΪѡÔñ²»Öظ´µÄ¼Ç¼¡£ |
criteria.andXxxIsNull | Ìí¼Ó×Ö¶ÎxxxΪnullµÄÌõ¼þ |
criteria.andXxxIsNotNull | Ìí¼Ó×Ö¶Îxxx²»ÎªnullµÄÌõ¼þ |
criteria.andXxxEqualTo(value) | Ìí¼Óxxx×ֶεÈÓÚvalueÌõ¼þ |
criteria.andXxxNotEqualTo(value) | Ìí¼Óxxx×ֶβ»µÈÓÚvalueÌõ¼þ |
criteria.andXxxGreaterThan(value) | Ìí¼Óxxx×ֶδóÓÚvalueÌõ¼þ |
criteria.andXxxGreaterThanOrEqualTo(value) | Ìí¼Óxxx×ֶδóÓÚµÈÓÚvalueÌõ¼þ |
criteria.andXxxLessThan(value) | Ìí¼Óxxx×Ö¶ÎСÓÚvalueÌõ¼þ |
criteria.andXxxLessThanOrEqualTo(value) | Ìí¼Óxxx×Ö¶ÎСÓÚµÈÓÚvalueÌõ¼þ |
criteria.andXxxIn(List<£¿>) | Ìí¼Óxxx×Ö¶ÎÖµÔÚList<£¿>Ìõ¼þ |
criteria.andXxxNotIn(List<£¿>) | Ìí¼Óxxx×Ö¶ÎÖµ²»ÔÚList<£¿>Ìõ¼þ |
criteria.andXxxLike(¡°%¡±+value+¡±%¡±) | Ìí¼Óxxx×Ö¶ÎֵΪvalueµÄÄ£ºý²éѯÌõ¼þ |
criteria.andXxxNotLike(¡°%¡±+value+¡±%¡±) | Ìí¼Óxxx×Ö¶ÎÖµ²»ÎªvalueµÄÄ£ºý²éѯÌõ¼þ |
criteria.andXxxBetween(value1,value2) | Ìí¼Óxxx×Ö¶ÎÖµÔÚvalue1ºÍvalue2Ö®¼äÌõ¼þ |
criteria.andXxxNotBetween(value1,value2) | Ìí¼Óxxx×Ö¶ÎÖµ²»ÔÚvalue1ºÍvalue2Ö®¼äÌõ¼þ |
¿ÉÒÔ¿´µ½£¬¸øCURDÌí¼ÓÌõ¼þµÄ·½·¨£¬·Ç³£µÄÈ«Ã棬µ«¿ÉϧµÄÊÇ£¬Ã»ÓзÖÒ³Óй¦ÄÜÔÚÆäÖС£
ÒÔÉϾÍÊÇMBG×î³£Óõķ½·¨¡£
END£¡£¡£¡£¡