下面列出了怎么用org.apache.ibatis.annotations.UpdateProvider的API类实例代码及写法,或者点击链接到github查看源代码。
public MapperAnnotationBuilder(Configuration configuration, Class<?> type) {
String resource = type.getName().replace('.', '/') + ".java (best guess)";
this.assistant = new MapperBuilderAssistant(configuration, resource);
this.configuration = configuration;
this.type = type;
sqlAnnotationTypes.add(Select.class);
sqlAnnotationTypes.add(Insert.class);
sqlAnnotationTypes.add(Update.class);
sqlAnnotationTypes.add(Delete.class);
sqlProviderAnnotationTypes.add(SelectProvider.class);
sqlProviderAnnotationTypes.add(InsertProvider.class);
sqlProviderAnnotationTypes.add(UpdateProvider.class);
sqlProviderAnnotationTypes.add(DeleteProvider.class);
}
private SqlCommandType getSqlCommandType(Method method) {
Class<? extends Annotation> type = getSqlAnnotationType(method);
if (type == null) {
type = getSqlProviderAnnotationType(method);
if (type == null) {
return SqlCommandType.UNKNOWN;
}
if (type == SelectProvider.class) {
type = Select.class;
} else if (type == InsertProvider.class) {
type = Insert.class;
} else if (type == UpdateProvider.class) {
type = Update.class;
} else if (type == DeleteProvider.class) {
type = Delete.class;
}
}
return SqlCommandType.valueOf(type.getSimpleName().toUpperCase(Locale.ENGLISH));
}
public MapperAnnotationBuilder(Configuration configuration, Class<?> type) {
String resource = type.getName().replace('.', '/') + ".java (best guess)";
this.assistant = new MapperBuilderAssistant(configuration, resource);
this.configuration = configuration;
this.type = type;
sqlAnnotationTypes.add(Select.class);
sqlAnnotationTypes.add(Insert.class);
sqlAnnotationTypes.add(Update.class);
sqlAnnotationTypes.add(Delete.class);
sqlProviderAnnotationTypes.add(SelectProvider.class);
sqlProviderAnnotationTypes.add(InsertProvider.class);
sqlProviderAnnotationTypes.add(UpdateProvider.class);
sqlProviderAnnotationTypes.add(DeleteProvider.class);
}
private SqlCommandType getSqlCommandType(Method method) {
Class<? extends Annotation> type = getSqlAnnotationType(method);
if (type == null) {
type = getSqlProviderAnnotationType(method);
if (type == null) {
return SqlCommandType.UNKNOWN;
}
if (type == SelectProvider.class) {
type = Select.class;
} else if (type == InsertProvider.class) {
type = Insert.class;
} else if (type == UpdateProvider.class) {
type = Update.class;
} else if (type == DeleteProvider.class) {
type = Delete.class;
}
}
return SqlCommandType.valueOf(type.getSimpleName().toUpperCase(Locale.ENGLISH));
}
@UpdateProvider(type =BaseProvider.class,method = "update")
long update(T t);
@UpdateProvider(type=UserSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") User record, @Param("example") UserCriteria example);
@UpdateProvider(type=UserSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") User record, @Param("example") UserCriteria example);
@UpdateProvider(type=UserSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(User record);
@UpdateProvider(type = PersonalInfoSqlProvide.class, method = "clearErrorCountSql")
Integer clearErrorCount(String uuid);
@UpdateProvider(type = PersonalInfoSqlProvide.class, method = "clearErrorCountAllSql")
Integer clearErrorCountAll();
@UpdateProvider(type = ImpPayHeadSqlProvide.class, method = "updateImpPayHeadSql")
Integer updateImpPayHead(ImpPayHead impPayHead);
@UpdateProvider(type = InvtHeadSqlProvide.class, method = "updateInvtHeadStatusSql")
Integer updateInvtHeadStatus(String headGuid, String status);
@UpdateProvider(type = InvtHeadSqlProvide.class, method = "updateInvtStatusAndInvtNoSql")
Integer updateInvtStatusAndInvtNo(InvtHead invtHead);
@UpdateProvider(type = InvtHeadSqlProvide.class, method = "syncInvtNoStatusSql")
Integer syncInvtNoStatus(String cusStatus, String status);
@UpdateProvider(type = ServerSystemSqlProvide.class, method = "updateServerSystemSql")
int updateServerSystem(ServerSystem serverSystem);
@UpdateProvider(type = VersionSqlProvide.class, method = "updateVersionSql")
int updateVersion(Version version);
@UpdateProvider(type = MemberSqlProvide.class, method = "updateMemberSql")
int updateMember(Member member);
@UpdateProvider(type = VeHeadSqlProvide.class, method = "syncVeENoSql")
Integer syncVeENo();
@UpdateProvider(type = VeHeadSqlProvide.class, method = "clearVeeNoSql")
Integer clearVeeNo(String veId);
@UpdateProvider(type = RoleSqlProvider.class, method = "deleteSql")
void delete(long uid);
@UpdateProvider(type = RoleSqlProvider.class, method = "updateSql")
MemAccount update(MemAccount memAccount);
@UpdateProvider(type = BusListenerSqlProvider.class, method = "deleteSql")
void delete(@Param("uid") long uid, @Param("event") int event);
@UpdateProvider(type = BusProgressSqlProvider.class, method = "updateSql")
void update(MemBusProgress memBusProgress);
@UpdateProvider(type = BusProgressSqlProvider.class, method = "deleteSql")
void delete(@Param("uid") long uid, @Param("event") int busId);
@UpdateProvider(type = BusInfoSqlProvider.class, method = "updateSql")
void update(MemBusInfo memBusInfo);
@UpdateProvider(type = BusInfoSqlProvider.class, method = "deleteSql")
void delete(@Param("uid") long uid, @Param("busId") int busId);
@UpdateProvider(type = BusInfoSqlProvider.class, method = "deleteByListSql")
void deleteBatch(@Param("uid") long uid, @Param("list") List<Integer> list);
/**
* 通过in条件更新所有字段,只支持一个in条件,是简单的封装
* @param paramName 该表中的字段名(和Example不同,只能是表中字段名,不能是实体对应字段名)
* @param params 该表中的对应字段
* @param record 更新的数据,为null的字段会更新为null
* @author Frodez
* @date 2019-12-25
*/
@UpdateProvider(type = InMapperProvider.class, method = "dynamicSQL")
int updateIn(@Param("paramName") String paramName, @Param("params") List<?> params, T record);
/**
* 通过in条件更新所有record中不为null字段,只支持一个in条件,是简单的封装
* @param paramName 该表中的字段名(和Example不同,只能是表中字段名,不能是实体对应字段名)
* @param params 该表中的对应字段
* @param record 更新的数据,为null的字段将不更新
* @author Frodez
* @date 2019-12-25
*/
@UpdateProvider(type = InMapperProvider.class, method = "dynamicSQL")
int updateInSelective(@Param("paramName") String paramName, @Param("params") List<?> params, T record);
/**
* 通过equal条件更新所有字段,只支持一个equal条件,是简单的封装
* @param paramName 该表中的字段名(和Example不同,只能是表中字段名,不能是实体对应字段名)
* @param param 该表中的对应字段
* @param record 更新的数据,为null的字段会更新为null
* @author Frodez
* @date 2019-12-25
*/
@UpdateProvider(type = EqualMapperProvider.class, method = "dynamicSQL")
int updateEqual(@Param("paramName") String paramName, @Param("param") Object param, T record);