View Javadoc
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 property.
31   *
32   * @see Results
33   *
34   * @author Clinton Begin
35   */
36  @Documented
37  @Retention(RetentionPolicy.RUNTIME)
38  @Target(ElementType.METHOD)
39  @Repeatable(Results.class)
40  public @interface Result {
41    /**
42     * Returns whether id column or not.
43     *
44     * @return {@code true} if id column; {@code false} if otherwise
45     */
46    boolean id() default false;
47  
48    /**
49     * Return the column name(or column label) to map to this argument.
50     *
51     * @return the column name(or column label)
52     */
53    String column() default "";
54  
55    /**
56     * Returns the property name for applying this mapping.
57     *
58     * @return the property name
59     */
60    String property() default "";
61  
62    /**
63     * Return the java type for this argument.
64     *
65     * @return the java type
66     */
67    Class<?> javaType() default void.class;
68  
69    /**
70     * Return the jdbc type for column that map to this argument.
71     *
72     * @return the jdbc type
73     */
74    JdbcType jdbcType() default JdbcType.UNDEFINED;
75  
76    /**
77     * Returns the {@link TypeHandler} type for retrieving a column value from result set.
78     *
79     * @return the {@link TypeHandler} type
80     */
81    Class<? extends TypeHandler> typeHandler() default UnknownTypeHandler.class;
82  
83    /**
84     * Returns the mapping definition for single relationship.
85     *
86     * @return the mapping definition for single relationship
87     */
88    One one() default @One;
89  
90    /**
91     * Returns the mapping definition for collection relationship.
92     *
93     * @return the mapping definition for collection relationship
94     */
95    Many many() default @Many;
96  }