Skip to content

Commit

Permalink
Merge pull request mybatis#1466 from kazuki43zoo/supports-databaseid-…
Browse files Browse the repository at this point in the history
…on-annotation-mapper

Supports the statement switching feature that correspond database on the annotation driven mapper
  • Loading branch information
harawata authored May 17, 2020
2 parents c67c2db + 4aba814 commit 6795230
Show file tree
Hide file tree
Showing 25 changed files with 1,513 additions and 109 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@
<version>10.14.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/Delete.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand All @@ -39,11 +40,31 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(Delete.List.class)
public @interface Delete {
/**
* Returns an SQL for deleting record(s).
*
* @return an SQL for deleting record(s)
*/
String[] value();

/**
* @return A database id that correspond this statement
* @since 3.5.5
*/
String databaseId() default "";

/**
* The container annotation for {@link Delete}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
Delete[] value();
}

}
20 changes: 20 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/DeleteProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand Down Expand Up @@ -47,6 +48,7 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(DeleteProvider.List.class)
public @interface DeleteProvider {

/**
Expand Down Expand Up @@ -91,4 +93,22 @@
*/
String method() default "";

/**
* @return A database id that correspond this provider
* @since 3.5.5
*/
String databaseId() default "";

/**
* The container annotation for {@link DeleteProvider}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
DeleteProvider[] value();
}

}
21 changes: 21 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/Insert.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand All @@ -39,11 +40,31 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(Insert.List.class)
public @interface Insert {
/**
* Returns an SQL for inserting record(s).
*
* @return an SQL for inserting record(s)
*/
String[] value();

/**
* @return A database id that correspond this statement
* @since 3.5.5
*/
String databaseId() default "";

/**
* The container annotation for {@link Insert}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
Insert[] value();
}

}
20 changes: 20 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/InsertProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand Down Expand Up @@ -47,6 +48,7 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(InsertProvider.List.class)
public @interface InsertProvider {

/**
Expand Down Expand Up @@ -91,4 +93,22 @@
*/
String method() default "";

/**
* @return A database id that correspond this provider
* @since 3.5.5
*/
String databaseId() default "";

/**
* The container annotation for {@link InsertProvider}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
InsertProvider[] value();
}

}
21 changes: 21 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand All @@ -43,6 +44,7 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(Options.List.class)
public @interface Options {
/**
* The options for the {@link Options#flushCache()}.
Expand Down Expand Up @@ -135,4 +137,23 @@ enum FlushCachePolicy {
* @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();
}

}
21 changes: 21 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/Select.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand All @@ -39,11 +40,31 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(Select.List.class)
public @interface Select {
/**
* Returns an SQL for retrieving record(s).
*
* @return an SQL for retrieving record(s)
*/
String[] value();

/**
* @return A database id that correspond this statement
* @since 3.5.5
*/
String databaseId() default "";

/**
* The container annotation for {@link Select}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
Select[] value();
}

}
21 changes: 21 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/SelectKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand All @@ -42,6 +43,7 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(SelectKey.List.class)
public @interface SelectKey {
/**
* Returns an SQL for retrieving a key value.
Expand Down Expand Up @@ -90,4 +92,23 @@
* @return the statement type
*/
StatementType statementType() default StatementType.PREPARED;

/**
* @return A database id that correspond this select key
* @since 3.5.5
*/
String databaseId() default "";

/**
* The container annotation for {@link SelectKey}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
SelectKey[] value();
}

}
20 changes: 20 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/SelectProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand Down Expand Up @@ -47,6 +48,7 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(SelectProvider.List.class)
public @interface SelectProvider {

/**
Expand Down Expand Up @@ -91,4 +93,22 @@
*/
String method() default "";

/**
* @return A database id that correspond this provider
* @since 3.5.5
*/
String databaseId() default "";

/**
* The container annotation for {@link SelectProvider}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
SelectProvider[] value();
}

}
21 changes: 21 additions & 0 deletions src/main/java/org/apache/ibatis/annotations/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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;
Expand All @@ -39,11 +40,31 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(Update.List.class)
public @interface Update {
/**
* Returns an SQL for updating record(s).
*
* @return an SQL for updating record(s)
*/
String[] value();

/**
* @return A database id that correspond this statement
* @since 3.5.5
*/
String databaseId() default "";

/**
* The container annotation for {@link Update}.
* @author Kazuki Shimizu
* @since 3.5.5
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface List {
Update[] value();
}

}
Loading

0 comments on commit 6795230

Please sign in to comment.