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 RelationManyToMany {
029
030    /**
031     * 当前实体类的属性。
032     *
033     * @return 属性名称
034     */
035    String selfField() default "";
036
037    /**
038     * <p>
039     * 目标实体类对应的表的 schema 模式。
040     *
041     * <p>
042     * 如果目标实体类没有使用 {@code @Table(schema = "...")} 指定 schema 时,
043     * 需要在这里指定对应表的 schema 值。一般关联数据不是 entity 对象,而是 vo、dto
044     * 等需要配置此项。
045     *
046     * @return schema 名称
047     */
048    String targetSchema() default "";
049
050    /**
051     * <p>
052     * 目标实体类对应的表名。
053     *
054     * <p>
055     * 如果目标实体类没有使用 {@code @Table(value = "...")} 指定表名时,
056     * 需要在这里指定对应表的表名。一般关联数据不是 entity 对象,而是 vo、dto
057     * 等需要配置此项。
058     *
059     * @return 表名
060     */
061    String targetTable() default "";
062
063    /**
064     * 目标实体类的关联属性。
065     *
066     * @return 属性名称
067     */
068    String targetField() default "";
069
070    /**
071     * 目标对象的关系实体类的属性绑定
072     * <p>
073     * 当字段不为空串时,只进行某个字段赋值(使用对应字段类型接收)
074     * @return 属性名称
075     */
076    String valueField() default "";
077
078    /**
079     * 当映射是一个 map 时,使用哪个内容来当做 map 的 Key
080     * @return 指定的列
081     */
082    String mapKeyField() default "";
083
084    /**
085     * 中间表名称。
086     *
087     * @return 中间表名称
088     */
089    String joinTable();
090
091    /**
092     * 中间表与当前表的关联字段。
093     *
094     * @return 字段名称,列名
095     */
096    String joinSelfColumn();
097
098    /**
099     * 目标表的关联字段名称。
100     *
101     * @return 字段名称和表
102     */
103    String joinTargetColumn();
104
105    /**
106     * 查询时,追加的额外条件。
107     */
108    String extraCondition() default "";
109
110    /**
111     * 查询(加载)指定的列
112     */
113    String[] selectColumns() default {};
114
115    /**
116     * 查询排序。
117     *
118     * @return 排序方式
119     */
120    String orderBy() default "";
121
122    /**
123     * 默认使用哪个数据源,若系统找不到该指定的数据源时,默认使用第一个数据源。
124     *
125     * @return 数据源
126     */
127    String dataSource() default "";
128
129}