1 /* 2 * Copyright 2009-2023 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.apache.ibatis.annotations; 17 18 import java.lang.annotation.Documented; 19 import java.lang.annotation.ElementType; 20 import java.lang.annotation.Repeatable; 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 import java.lang.annotation.Target; 24 25 import org.apache.ibatis.type.JdbcType; 26 import org.apache.ibatis.type.TypeHandler; 27 import org.apache.ibatis.type.UnknownTypeHandler; 28 29 /** 30 * The annotation that specify a mapping definition for the constructor argument. 31 * 32 * @see ConstructorArgs 33 * 34 * @author Clinton Begin 35 */ 36 @Documented 37 @Retention(RetentionPolicy.RUNTIME) 38 @Target(ElementType.METHOD) 39 @Repeatable(ConstructorArgs.class) 40 public @interface Arg { 41 42 /** 43 * Returns whether id column or not. 44 * 45 * @return {@code true} if id column; {@code false} if otherwise 46 */ 47 boolean id() default false; 48 49 /** 50 * Return the column name(or column label) to map to this argument. 51 * 52 * @return the column name(or column label) 53 */ 54 String column() default ""; 55 56 /** 57 * Return the java type for this argument. 58 * 59 * @return the java type 60 */ 61 Class<?> javaType() default void.class; 62 63 /** 64 * Return the jdbc type for column that map to this argument. 65 * 66 * @return the jdbc type 67 */ 68 JdbcType jdbcType() default JdbcType.UNDEFINED; 69 70 /** 71 * Returns the {@link TypeHandler} type for retrieving a column value from result set. 72 * 73 * @return the {@link TypeHandler} type 74 */ 75 Class<? extends TypeHandler> typeHandler() default UnknownTypeHandler.class; 76 77 /** 78 * Return the statement id for retrieving a object that map to this argument. 79 * 80 * @return the statement id 81 */ 82 String select() default ""; 83 84 /** 85 * Returns the result map id for mapping to a object that map to this argument. 86 * 87 * @return the result map id 88 */ 89 String resultMap() default ""; 90 91 /** 92 * Returns the parameter name for applying this mapping. 93 * 94 * @return the parameter name 95 * 96 * @since 3.4.3 97 */ 98 String name() default ""; 99 100 /** 101 * Returns the column prefix that use when applying {@link #resultMap()}. 102 * 103 * @return the column prefix 104 * 105 * @since 3.5.0 106 */ 107 String columnPrefix() default ""; 108 }