private String parseResultMap(Method method) { Class<?> returnType = getReturnType(method); ConstructorArgs args = method.getAnnotation(ConstructorArgs.class); Results results = method.getAnnotation(Results.class); TypeDiscriminator typeDiscriminator = method.getAnnotation(TypeDiscriminator.class); String resultMapId = generateResultMapName(method); applyResultMap(resultMapId, returnType, argsIf(args), resultsIf(results), typeDiscriminator); return resultMapId; }
private Arg[] argsIf(ConstructorArgs args) { return args == null ? new Arg[0] : args.value(); }
@Select("select id, name from product where name = #{value}") @ConstructorArgs({ @Arg(id = true, column="id", javaType = ProductId.class, jdbcType=JdbcType.INTEGER), @Arg(column="name") }) Product getProductByNameUsingConstructor(String name);
/** * 查询词频统计结果,查询频次开前的N个结果 */ @Select("SELECT `word`,`count` FROM `wordcount` ORDER BY `count` DESC LIMIT #{N}") @ConstructorArgs(value = { @Arg(column = "word", javaType = String.class), @Arg(column = "count", javaType = Integer.class) }) @ResultType(value = WordAndCount.class) public List<WordAndCount> selectWordCountTopN(int N);
@ConstructorArgs({ @Arg(column = "id", name = "noSuchConstructorArg"), }) @Select("select * from users ") User select();
@ConstructorArgs({ @Arg(column = "id", name = "id", javaType = Integer.class), }) @Select("select * from users ") User select();
@ConstructorArgs({ @Arg(column = "id", name = "id"), }) @Select("select * from users ") User select();