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 Yang 024 */ 025@Retention(RetentionPolicy.RUNTIME) 026@Target({ElementType.TYPE}) 027//@Inherited 需要注释,否则会在 vo 等继承 model 的实体类中,生成多余的、或冲突的 tableDef 028public @interface Table { 029 030 /** 031 * 显式指定表名称。 032 */ 033 String value(); 034 035 /** 036 * 数据库的 schema(模式)。 037 */ 038 String schema() default ""; 039 040 /** 041 * 默认为 驼峰属性 转换为 下划线字段。 042 */ 043 boolean camelToUnderline() default true; 044 045 /** 046 * 默认使用哪个数据源,若系统找不到该指定的数据源时,默认使用第一个数据源。 047 */ 048 String dataSource() default ""; 049 050 /** 051 * 数据库表注释,在 AI 时代,注释的内容往往可用于 AI 辅助对话 052 */ 053 String comment() default ""; 054 055 /** 056 * 监听 entity 的 insert 行为。 057 */ 058 Class<? extends InsertListener>[] onInsert() default {}; 059 060 /** 061 * 监听 entity 的 update 行为。 062 */ 063 Class<? extends UpdateListener>[] onUpdate() default {}; 064 065 /** 066 * 监听 entity 的查询数据的 set 行为,用户主动 set 不会触发。 067 */ 068 Class<? extends SetListener>[] onSet() default {}; 069 070 /** 071 * 在某些场景下,我们需要手动编写 Mapper,可以通过这个注解来关闭 APT 的 Mapper 生成。 072 */ 073 boolean mapperGenerateEnable() default true; 074 075}