001/*
002 *  Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
003 *  <p>
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *  <p>
008 *  http://www.apache.org/licenses/LICENSE-2.0
009 *  <p>
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package com.mybatisflex.annotation;
017
018import java.lang.annotation.*;
019
020/**
021 * 一对多映射。
022 *
023 * @author michael
024 */
025@Inherited
026@Retention(RetentionPolicy.RUNTIME)
027@Target({ElementType.FIELD})
028public @interface RelationOneToMany {
029
030    /**
031     * 当前实体类的属性。
032     *
033     * @return 属性名称
034     */
035    String selfField() default "";
036
037    /**
038     * 当前字段值根据字符串分割
039     * @return 分割字符串
040     */
041    String selfValueSplitBy() default "";
042
043    /**
044     * <p>
045     * 目标实体类对应的表的 schema 模式。
046     *
047     * <p>
048     * 如果目标实体类没有使用 {@code @Table(schema = "...")} 指定 schema 时,
049     * 需要在这里指定对应表的 schema 值。一般关联数据不是 entity 对象,而是 vo、dto
050     * 等需要配置此项。
051     *
052     * @return schema 名称
053     */
054    String targetSchema() default "";
055
056    /**
057     * <p>
058     * 目标实体类对应的表名。
059     *
060     * <p>
061     * 如果目标实体类没有使用 {@code @Table(value = "...")} 指定表名时,
062     * 需要在这里指定对应表的表名。一般关联数据不是 entity 对象,而是 vo、dto
063     * 等需要配置此项。
064     *
065     * @return 表名
066     */
067    String targetTable() default "";
068
069    /**
070     * 目标实体类的关联属性。
071     *
072     * @return 属性名称
073     */
074    String targetField();
075
076    /**
077     * 目标对象的关系实体类的属性绑定
078     * <p>
079     * 当字段不为空串时,只进行某个字段赋值(使用对应字段类型接收)
080     * @return 属性名称
081     */
082    String valueField() default "";
083
084    /**
085     * 当映射是一个 map 时,使用哪个内容来当做 map 的 Key
086     * @return 指定的列
087     */
088    String mapKeyField() default "";
089
090    /**
091     * 中间表名称,一对一的关系是通过通过中间表维护时,需要添加此项配置。
092     *
093     * @return 中间表名称
094     */
095    String joinTable() default "";
096
097    /**
098     * 中间表与当前表的关联字段,一对一的关系是通过通过中间表维护时,需要添加此项配置。
099     *
100     * @return 字段名称,列名
101     */
102    String joinSelfColumn() default "";
103
104    /**
105     * 目标表的关联字段名称,一对一的关系是通过通过中间表维护时,需要添加此项配置。
106     *
107     * @return 字段名称和表
108     */
109    String joinTargetColumn() default "";
110
111    /**
112     * 查询时,追加的额外条件。
113     */
114    String extraCondition() default "";
115
116    /**
117     * 查询(加载)指定的列
118     */
119    String[] selectColumns() default {};
120
121    /**
122     * 查询排序。
123     *
124     * @return 排序方式
125     */
126    String orderBy() default "";
127
128    /**
129     * 现在查询的数据量。
130     *
131     * @return 数据量
132     */
133    long limit() default 0;
134
135    /**
136     * 默认使用哪个数据源,若系统找不到该指定的数据源时,默认使用第一个数据源。
137     *
138     * @return 数据源
139     */
140    String dataSource() default "";
141
142
143}