org.teasoft.bee.osql.annotation.Sharding Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bee Show documentation
Show all versions of bee Show documentation
Bee is a Java ORM framework.Easy and Stronger!
The newest version!
/*
* Copyright 2016-2022 the original author.All rights reserved.
* Kingstar([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.teasoft.bee.osql.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Sharding.
*
Specify different tables in the same database after calculation; Specify different databases after calculation.
*
When there are multiple tables, cross table is not supported.
*
The dataSource of the sub table is consistent with the main table.
*
Order: 1->2
*
1. Special (if special is configured, others will not be detected)
*
2. Calculate by algorithm (default if there is no match)
* @author AiTeaSoft
* @since 2.0
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Sharding {
/**
* appoint dataSource
* @return appointed dataSource
*/
String appointDS() default "";
/**
* appoint table name
* @return appointed table name
*/
String appointTab() default "";
/**
* 0: operations that can be calculated directly such as remainder; 1: Take part of the string such as date; 2: Custom
* @return value of dsAlgorithm
*/
int dsAlgorithm() default 0;
/**
* 0: operations that can be calculated directly such as remainder; 1: Take part of the string such as date; 2: Custom
* @return value of tabAlgorithm
*/
int tabAlgorithm() default 0;
/**
* If dsRule is not set, that is, the default empty value is used, it means that is not to consider the database name.
*
eg: "id%dsSize
* @return value of dsRule
*/
String dsRule() default "";
/**
* If dsRule is empty and the value of dsName is not set, the database name is not required.
*
By default, the value calculated by dsRule() will be automatically used as the suffix of dsName.
* @return dsName
*/
String dsName() default "";
/**
* get tabRule
* @return tabRule
*/
String tabRule() default "";
/**
* get tabName.
*
The default is the value calculated by tabRule() as the suffix of tabName.
*
eg:tab${tabRule}
* @return tabName
*/
String tabName() default "";
/**
* use for define DsTabHandler.
* @return class of DsTabHandler type
*/
Class extends DsTabHandler> handler() default DsTabHandler.class;
}