org.apache.ibatis.annotations.Options Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.apache.servicemix.bundles.mybatis
Show all versions of org.apache.servicemix.bundles.mybatis
This OSGi bundle wraps ${pkgArtifactId} ${pkgVersion} jar file.
/*
* Copyright 2009-2021 the original author or authors.
*
* 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.apache.ibatis.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.mapping.StatementType;
/**
* The annotation that specify options for customizing default behaviors.
*
*
* How to use:
*
*
* public interface UserMapper {
* @Options(useGeneratedKeys = true, keyProperty = "id")
* @Insert("INSERT INTO users (name) VALUES(#{name})")
* boolean insert(User user);
* }
*
*
* @author Clinton Begin
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(Options.List.class)
public @interface Options {
/**
* The options for the {@link Options#flushCache()}.
* The default is {@link FlushCachePolicy#DEFAULT}
*/
enum FlushCachePolicy {
/** false
for select statement; true
for insert/update/delete statement. */
DEFAULT,
/** Flushes cache regardless of the statement type. */
TRUE,
/** Does not flush cache regardless of the statement type. */
FALSE
}
/**
* Returns whether use the 2nd cache feature if assigned the cache.
*
* @return {@code true} if use; {@code false} if otherwise
*/
boolean useCache() default true;
/**
* Returns the 2nd cache flush strategy.
*
* @return the 2nd cache flush strategy
*/
FlushCachePolicy flushCache() default FlushCachePolicy.DEFAULT;
/**
* Returns the result set type.
*
* @return the result set type
*/
ResultSetType resultSetType() default ResultSetType.DEFAULT;
/**
* Return the statement type.
*
* @return the statement type
*/
StatementType statementType() default StatementType.PREPARED;
/**
* Returns the fetch size.
*
* @return the fetch size
*/
int fetchSize() default -1;
/**
* Returns the statement timeout.
*
* @return the statement timeout
*/
int timeout() default -1;
/**
* Returns whether use the generated keys feature supported by JDBC 3.0
*
* @return {@code true} if use; {@code false} if otherwise
*/
boolean useGeneratedKeys() default false;
/**
* Returns property names that holds a key value.
*
* If you specify multiple property, please separate using comma(',').
*
*
* @return property names that separate with comma(',')
*/
String keyProperty() default "";
/**
* Returns column names that retrieves a key value.
*
* If you specify multiple column, please separate using comma(',').
*
*
* @return column names that separate with comma(',')
*/
String keyColumn() default "";
/**
* Returns result set names.
*
* If you specify multiple result set, please separate using comma(',').
*
*
* @return result set names that separate with comma(',')
*/
String resultSets() default "";
/**
* @return A database id that correspond this options
* @since 3.5.5
*/
String databaseId() default "";
/**
* The container annotation for {@link Options}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
Options[] value();
}
}