diff --git a/src/main/java/org/apache/ibatis/annotations/Arg.java b/src/main/java/org/apache/ibatis/annotations/Arg.java index d5a505cee1c..3cea44307b4 100644 --- a/src/main/java/org/apache/ibatis/annotations/Arg.java +++ b/src/main/java/org/apache/ibatis/annotations/Arg.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -30,6 +30,7 @@ * The annotation that specify a mapping definition for the constructor argument. * * @see ConstructorArgs + * * @author Clinton Begin */ @Documented @@ -91,6 +92,7 @@ * Returns the parameter name for applying this mapping. * * @return the parameter name + * * @since 3.4.3 */ String name() default ""; @@ -99,6 +101,7 @@ * Returns the column prefix that use when applying {@link #resultMap()}. * * @return the column prefix + * * @since 3.5.0 */ String columnPrefix() default ""; diff --git a/src/main/java/org/apache/ibatis/annotations/AutomapConstructor.java b/src/main/java/org/apache/ibatis/annotations/AutomapConstructor.java index b09fa0c5ed3..91742b147a4 100644 --- a/src/main/java/org/apache/ibatis/annotations/AutomapConstructor.java +++ b/src/main/java/org/apache/ibatis/annotations/AutomapConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,7 +23,6 @@ /** * The marker annotation that indicate a constructor for automatic mapping. - * *

* How to use: * @@ -47,6 +46,7 @@ * * * @author Tim Chen + * * @since 3.4.3 */ @Documented diff --git a/src/main/java/org/apache/ibatis/annotations/CacheNamespace.java b/src/main/java/org/apache/ibatis/annotations/CacheNamespace.java index 8e1f22ebea0..a7358a8ce13 100644 --- a/src/main/java/org/apache/ibatis/annotations/CacheNamespace.java +++ b/src/main/java/org/apache/ibatis/annotations/CacheNamespace.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -27,7 +27,6 @@ /** * The annotation that specify to use cache on namespace(e.g. mapper interface). - * *

* How to use: * @@ -96,6 +95,7 @@ * Returns property values for a implementation object. * * @return property values + * * @since 3.4.2 */ Property[] properties() default {}; diff --git a/src/main/java/org/apache/ibatis/annotations/CacheNamespaceRef.java b/src/main/java/org/apache/ibatis/annotations/CacheNamespaceRef.java index 2eace78dbe5..319f66a8785 100644 --- a/src/main/java/org/apache/ibatis/annotations/CacheNamespaceRef.java +++ b/src/main/java/org/apache/ibatis/annotations/CacheNamespaceRef.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,9 +23,8 @@ /** * The annotation that reference a cache. - * - *

If you use this annotation, should be specified either {@link #value()} or {@link #name()} attribute. - * + *

+ * If you use this annotation, should be specified either {@link #value()} or {@link #name()} attribute. *

* How to use: * @@ -55,6 +54,7 @@ * Returns the namespace name to reference a cache. * * @return the namespace name + * * @since 3.4.2 */ String name() default ""; diff --git a/src/main/java/org/apache/ibatis/annotations/Case.java b/src/main/java/org/apache/ibatis/annotations/Case.java index e3b285c81d8..186c3096ddc 100644 --- a/src/main/java/org/apache/ibatis/annotations/Case.java +++ b/src/main/java/org/apache/ibatis/annotations/Case.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -28,6 +28,7 @@ * @see Arg * @see Results * @see ConstructorArgs + * * @author Clinton Begin */ @Documented diff --git a/src/main/java/org/apache/ibatis/annotations/ConstructorArgs.java b/src/main/java/org/apache/ibatis/annotations/ConstructorArgs.java index 0ad301a6bd4..b3cc6bb888d 100644 --- a/src/main/java/org/apache/ibatis/annotations/ConstructorArgs.java +++ b/src/main/java/org/apache/ibatis/annotations/ConstructorArgs.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,7 +23,6 @@ /** * The annotation that be grouping mapping definitions for constructor. - * *

* How to use: * diff --git a/src/main/java/org/apache/ibatis/annotations/Delete.java b/src/main/java/org/apache/ibatis/annotations/Delete.java index 8546a2bf93e..8396669a5fb 100644 --- a/src/main/java/org/apache/ibatis/annotations/Delete.java +++ b/src/main/java/org/apache/ibatis/annotations/Delete.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * The annotation that specify an SQL for deleting record(s). - * *

* How to use: * @@ -51,13 +50,16 @@ /** * @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 diff --git a/src/main/java/org/apache/ibatis/annotations/DeleteProvider.java b/src/main/java/org/apache/ibatis/annotations/DeleteProvider.java index e7f49852e4b..5ae9043875a 100644 --- a/src/main/java/org/apache/ibatis/annotations/DeleteProvider.java +++ b/src/main/java/org/apache/ibatis/annotations/DeleteProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * The annotation that specify a method that provide an SQL for deleting record(s). - * *

* How to use: * @@ -55,7 +54,9 @@ * Specify a type that implements an SQL provider method. * * @return a type that implements an SQL provider method + * * @since 3.5.2 + * * @see #type() */ Class value() default void.class; @@ -67,13 +68,13 @@ *

* * @return a type that implements an SQL provider method + * * @see #value() */ Class type() default void.class; /** * Specify a method for providing an SQL. - * *

* Since 3.5.1, this attribute can omit. * If this attribute omit, the MyBatis will call a method that decide by following rules. @@ -95,13 +96,16 @@ /** * @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 diff --git a/src/main/java/org/apache/ibatis/annotations/Flush.java b/src/main/java/org/apache/ibatis/annotations/Flush.java index e08bdc0d3a2..2063d77297d 100644 --- a/src/main/java/org/apache/ibatis/annotations/Flush.java +++ b/src/main/java/org/apache/ibatis/annotations/Flush.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,7 +23,6 @@ /** * The maker annotation that invoke a flush statements via Mapper interface. - * *

* How to use: * @@ -35,6 +34,7 @@ * * * @since 3.3.0 + * * @author Kazuki Shimizu */ @Documented diff --git a/src/main/java/org/apache/ibatis/annotations/Insert.java b/src/main/java/org/apache/ibatis/annotations/Insert.java index 458dd7d13ac..9b6bb56b944 100644 --- a/src/main/java/org/apache/ibatis/annotations/Insert.java +++ b/src/main/java/org/apache/ibatis/annotations/Insert.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * The annotation that specify an SQL for inserting record(s). - * *

* How to use: * @@ -51,13 +50,16 @@ /** * @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 diff --git a/src/main/java/org/apache/ibatis/annotations/InsertProvider.java b/src/main/java/org/apache/ibatis/annotations/InsertProvider.java index 9c2b025ddac..71c8b5406ee 100644 --- a/src/main/java/org/apache/ibatis/annotations/InsertProvider.java +++ b/src/main/java/org/apache/ibatis/annotations/InsertProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * The annotation that specify a method that provide an SQL for inserting record(s). - * *

* How to use: * @@ -55,7 +54,9 @@ * Specify a type that implements an SQL provider method. * * @return a type that implements an SQL provider method + * * @since 3.5.2 + * * @see #type() */ Class value() default void.class; @@ -67,13 +68,13 @@ *

* * @return a type that implements an SQL provider method + * * @see #value() */ Class type() default void.class; /** * Specify a method for providing an SQL. - * *

* Since 3.5.1, this attribute can omit. * If this attribute omit, the MyBatis will call a method that decide by following rules. @@ -95,13 +96,16 @@ /** * @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 diff --git a/src/main/java/org/apache/ibatis/annotations/Lang.java b/src/main/java/org/apache/ibatis/annotations/Lang.java index bcbb6ed76f4..371a87287f3 100644 --- a/src/main/java/org/apache/ibatis/annotations/Lang.java +++ b/src/main/java/org/apache/ibatis/annotations/Lang.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -25,7 +25,6 @@ /** * The annotation that specify a {@link LanguageDriver} to use. - * *

* How to use: * diff --git a/src/main/java/org/apache/ibatis/annotations/Many.java b/src/main/java/org/apache/ibatis/annotations/Many.java index bc028e7ec82..066f4a31c9a 100644 --- a/src/main/java/org/apache/ibatis/annotations/Many.java +++ b/src/main/java/org/apache/ibatis/annotations/Many.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -27,6 +27,7 @@ * * @see Result * @see Results + * * @author Clinton Begin */ @Documented @@ -37,6 +38,7 @@ * Returns the columnPrefix. * * @return the columnPrefix. + * * @since 3.5.5 */ String columnPrefix() default ""; @@ -45,6 +47,7 @@ * Returns the result map id used to map collection. * * @return the result map id + * * @since 3.5.5 */ String resultMap() default ""; diff --git a/src/main/java/org/apache/ibatis/annotations/MapKey.java b/src/main/java/org/apache/ibatis/annotations/MapKey.java index 09a61fa5fd3..b51edf44350 100644 --- a/src/main/java/org/apache/ibatis/annotations/MapKey.java +++ b/src/main/java/org/apache/ibatis/annotations/MapKey.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,7 +23,6 @@ /** * The annotation that specify the property name(or column name) for a key value of {@link java.util.Map}. - * *

* How to use: * diff --git a/src/main/java/org/apache/ibatis/annotations/Mapper.java b/src/main/java/org/apache/ibatis/annotations/Mapper.java index 28c62159f9d..9467cb7319d 100644 --- a/src/main/java/org/apache/ibatis/annotations/Mapper.java +++ b/src/main/java/org/apache/ibatis/annotations/Mapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * Marker interface for MyBatis mappers. - * *

* How to use: * diff --git a/src/main/java/org/apache/ibatis/annotations/One.java b/src/main/java/org/apache/ibatis/annotations/One.java index dae873a65cf..fb60375d6fb 100644 --- a/src/main/java/org/apache/ibatis/annotations/One.java +++ b/src/main/java/org/apache/ibatis/annotations/One.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -27,6 +27,7 @@ * * @see Result * @see Results + * * @author Clinton Begin */ @Documented @@ -37,6 +38,7 @@ * Returns the columnPrefix. * * @return the columnPrefix. + * * @since 3.5.5 */ String columnPrefix() default ""; @@ -45,6 +47,7 @@ * Returns the result map id used to map single object. * * @return the result map id + * * @since 3.5.5 */ String resultMap() default ""; diff --git a/src/main/java/org/apache/ibatis/annotations/Options.java b/src/main/java/org/apache/ibatis/annotations/Options.java index 35f96e4be36..12d80c20bf7 100644 --- a/src/main/java/org/apache/ibatis/annotations/Options.java +++ b/src/main/java/org/apache/ibatis/annotations/Options.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -27,7 +27,6 @@ /** * The annotation that specify options for customizing default behaviors. - * *

* How to use: * @@ -47,8 +46,7 @@ @Repeatable(Options.List.class) public @interface Options { /** - * The options for the {@link Options#flushCache()}. - * The default is {@link FlushCachePolicy#DEFAULT} + * 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. */ @@ -140,13 +138,16 @@ enum FlushCachePolicy { /** * @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 diff --git a/src/main/java/org/apache/ibatis/annotations/Param.java b/src/main/java/org/apache/ibatis/annotations/Param.java index d1f8f1886f5..b69689e6d66 100644 --- a/src/main/java/org/apache/ibatis/annotations/Param.java +++ b/src/main/java/org/apache/ibatis/annotations/Param.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,7 +23,6 @@ /** * The annotation that specify the parameter name. - * *

* How to use: * diff --git a/src/main/java/org/apache/ibatis/annotations/Property.java b/src/main/java/org/apache/ibatis/annotations/Property.java index 15caca2819e..5e684d50b75 100644 --- a/src/main/java/org/apache/ibatis/annotations/Property.java +++ b/src/main/java/org/apache/ibatis/annotations/Property.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,9 @@ * The annotation that inject a property value. * * @since 3.4.2 + * * @author Kazuki Shimizu + * * @see CacheNamespace */ @Documented diff --git a/src/main/java/org/apache/ibatis/annotations/Result.java b/src/main/java/org/apache/ibatis/annotations/Result.java index 8abb15be171..48cce78e741 100644 --- a/src/main/java/org/apache/ibatis/annotations/Result.java +++ b/src/main/java/org/apache/ibatis/annotations/Result.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -30,6 +30,7 @@ * The annotation that specify a mapping definition for the property. * * @see Results + * * @author Clinton Begin */ @Documented diff --git a/src/main/java/org/apache/ibatis/annotations/ResultMap.java b/src/main/java/org/apache/ibatis/annotations/ResultMap.java index 56fd697032b..36c650864b8 100644 --- a/src/main/java/org/apache/ibatis/annotations/ResultMap.java +++ b/src/main/java/org/apache/ibatis/annotations/ResultMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,7 +23,6 @@ /** * The annotation that specify result map names to use. - * *

* How to use:
* Mapper interface: @@ -39,7 +38,9 @@ * User selectByEmail(String email); * } * + * * Mapper XML: + * *

{@code
  * 
  *   
diff --git a/src/main/java/org/apache/ibatis/annotations/ResultType.java b/src/main/java/org/apache/ibatis/annotations/ResultType.java
index eaab7252934..5d9e0761acd 100644
--- a/src/main/java/org/apache/ibatis/annotations/ResultType.java
+++ b/src/main/java/org/apache/ibatis/annotations/ResultType.java
@@ -1,5 +1,5 @@
 /*
- *    Copyright 2009-2022 the original author or authors.
+ *    Copyright 2009-2023 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.
@@ -22,11 +22,8 @@
 import java.lang.annotation.Target;
 
 /**
- * This annotation can be used when a @Select method is using a
- * ResultHandler.  Those methods must have void return type, so
- * this annotation can be used to tell MyBatis what kind of object
- * it should build for each row.
- *
+ * This annotation can be used when a @Select method is using a ResultHandler. Those methods must have void return type,
+ * so this annotation can be used to tell MyBatis what kind of object it should build for each row.
  * 

* How to use: * @@ -39,6 +36,7 @@ *

* * @since 3.2.0 + * * @author Jeff Butler */ @Documented diff --git a/src/main/java/org/apache/ibatis/annotations/Results.java b/src/main/java/org/apache/ibatis/annotations/Results.java index 84f9b10156a..2fe865f4acc 100644 --- a/src/main/java/org/apache/ibatis/annotations/Results.java +++ b/src/main/java/org/apache/ibatis/annotations/Results.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,7 +23,6 @@ /** * The annotation that be grouping mapping definitions for property. - * *

* How to use: * diff --git a/src/main/java/org/apache/ibatis/annotations/Select.java b/src/main/java/org/apache/ibatis/annotations/Select.java index 3796871090c..e3256380bd8 100644 --- a/src/main/java/org/apache/ibatis/annotations/Select.java +++ b/src/main/java/org/apache/ibatis/annotations/Select.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * The annotation that specify an SQL for retrieving record(s). - * *

* How to use: * @@ -51,6 +50,7 @@ /** * @return A database id that correspond this statement + * * @since 3.5.5 */ String databaseId() default ""; @@ -60,13 +60,16 @@ * e.g. RETURNING of PostgreSQL or OUTPUT of MS SQL Server. * * @return {@code true} if this select affects DB data; {@code false} if otherwise + * * @since 3.5.12 */ boolean affectData() default false; /** * The container annotation for {@link Select}. + * * @author Kazuki Shimizu + * * @since 3.5.5 */ @Documented diff --git a/src/main/java/org/apache/ibatis/annotations/SelectKey.java b/src/main/java/org/apache/ibatis/annotations/SelectKey.java index 5715135df1d..1b1848abb11 100644 --- a/src/main/java/org/apache/ibatis/annotations/SelectKey.java +++ b/src/main/java/org/apache/ibatis/annotations/SelectKey.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -26,7 +26,6 @@ /** * The annotation that specify an SQL for retrieving a key value. - * *

* How to use: * @@ -95,13 +94,16 @@ /** * @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 diff --git a/src/main/java/org/apache/ibatis/annotations/SelectProvider.java b/src/main/java/org/apache/ibatis/annotations/SelectProvider.java index 282374c6459..d23077e7b2d 100644 --- a/src/main/java/org/apache/ibatis/annotations/SelectProvider.java +++ b/src/main/java/org/apache/ibatis/annotations/SelectProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * The annotation that specify a method that provide an SQL for retrieving record(s). - * *

* How to use: * @@ -55,7 +54,9 @@ * Specify a type that implements an SQL provider method. * * @return a type that implements an SQL provider method + * * @since 3.5.2 + * * @see #type() */ Class value() default void.class; @@ -67,13 +68,13 @@ *

* * @return a type that implements an SQL provider method + * * @see #value() */ Class type() default void.class; /** * Specify a method for providing an SQL. - * *

* Since 3.5.1, this attribute can omit. * If this attribute omit, the MyBatis will call a method that decide by following rules. @@ -95,6 +96,7 @@ /** * @return A database id that correspond this provider + * * @since 3.5.5 */ String databaseId() default ""; @@ -104,13 +106,16 @@ * e.g. RETURNING of PostgreSQL or OUTPUT of MS SQL Server. * * @return {@code true} if this select affects DB data; {@code false} if otherwise + * * @since 3.5.12 */ boolean affectData() default false; /** * The container annotation for {@link SelectProvider}. + * * @author Kazuki Shimizu + * * @since 3.5.5 */ @Documented diff --git a/src/main/java/org/apache/ibatis/annotations/TypeDiscriminator.java b/src/main/java/org/apache/ibatis/annotations/TypeDiscriminator.java index 74043cd9ea3..cdbd38536ae 100644 --- a/src/main/java/org/apache/ibatis/annotations/TypeDiscriminator.java +++ b/src/main/java/org/apache/ibatis/annotations/TypeDiscriminator.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -27,7 +27,6 @@ /** * The annotation that be grouping conditional mapping definitions. - * *

* How to use: * diff --git a/src/main/java/org/apache/ibatis/annotations/Update.java b/src/main/java/org/apache/ibatis/annotations/Update.java index deba99b9d2b..9de9f9782f8 100644 --- a/src/main/java/org/apache/ibatis/annotations/Update.java +++ b/src/main/java/org/apache/ibatis/annotations/Update.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * The annotation that specify an SQL for updating record(s). - * *

* How to use: * @@ -51,13 +50,16 @@ /** * @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 diff --git a/src/main/java/org/apache/ibatis/annotations/UpdateProvider.java b/src/main/java/org/apache/ibatis/annotations/UpdateProvider.java index b5adf72ad7c..a3c20796abd 100644 --- a/src/main/java/org/apache/ibatis/annotations/UpdateProvider.java +++ b/src/main/java/org/apache/ibatis/annotations/UpdateProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,7 +24,6 @@ /** * The annotation that specify a method that provide an SQL for updating record(s). - * *

* How to use: * @@ -55,7 +54,9 @@ * Specify a type that implements an SQL provider method. * * @return a type that implements an SQL provider method + * * @since 3.5.2 + * * @see #type() */ Class value() default void.class; @@ -67,6 +68,7 @@ *

* * @return a type that implements an SQL provider method + * * @see #value() */ Class type() default void.class; @@ -95,13 +97,16 @@ /** * @return A database id that correspond this provider + * * @since 3.5.5 */ String databaseId() default ""; /** * The container annotation for {@link UpdateProvider}. + * * @author Kazuki Shimizu + * * @since 3.5.5 */ @Documented diff --git a/src/main/java/org/apache/ibatis/binding/MapperMethod.java b/src/main/java/org/apache/ibatis/binding/MapperMethod.java index 17b6cd9f863..67857ac0b21 100644 --- a/src/main/java/org/apache/ibatis/binding/MapperMethod.java +++ b/src/main/java/org/apache/ibatis/binding/MapperMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -85,8 +85,7 @@ public Object execute(SqlSession sqlSession, Object[] args) { } else { Object param = method.convertArgsToSqlCommandParam(args); result = sqlSession.selectOne(command.getName(), param); - if (method.returnsOptional() - && (result == null || !method.getReturnType().equals(result.getClass()))) { + if (method.returnsOptional() && (result == null || !method.getReturnType().equals(result.getClass()))) { result = Optional.ofNullable(result); } } @@ -115,7 +114,8 @@ private Object rowCountResult(int rowCount) { } else if (Boolean.class.equals(method.getReturnType()) || Boolean.TYPE.equals(method.getReturnType())) { result = rowCount > 0; } else { - throw new BindingException("Mapper method '" + command.getName() + "' has an unsupported return type: " + method.getReturnType()); + throw new BindingException( + "Mapper method '" + command.getName() + "' has an unsupported return type: " + method.getReturnType()); } return result; } @@ -124,9 +124,9 @@ private void executeWithResultHandler(SqlSession sqlSession, Object[] args) { MappedStatement ms = sqlSession.getConfiguration().getMappedStatement(command.getName()); if (!StatementType.CALLABLE.equals(ms.getStatementType()) && void.class.equals(ms.getResultMaps().get(0).getType())) { - throw new BindingException("method " + command.getName() - + " needs either a @ResultMap annotation, a @ResultType annotation," - + " or a resultType attribute in XML so a ResultHandler can be used as a parameter."); + throw new BindingException( + "method " + command.getName() + " needs either a @ResultMap annotation, a @ResultType annotation," + + " or a resultType attribute in XML so a ResultHandler can be used as a parameter."); } Object param = method.convertArgsToSqlCommandParam(args); if (method.hasRowBounds()) { @@ -224,15 +224,14 @@ public static class SqlCommand { public SqlCommand(Configuration configuration, Class mapperInterface, Method method) { final String methodName = method.getName(); final Class declaringClass = method.getDeclaringClass(); - MappedStatement ms = resolveMappedStatement(mapperInterface, methodName, declaringClass, - configuration); + MappedStatement ms = resolveMappedStatement(mapperInterface, methodName, declaringClass, configuration); if (ms == null) { if (method.getAnnotation(Flush.class) != null) { name = null; type = SqlCommandType.FLUSH; } else { - throw new BindingException("Invalid bound statement (not found): " - + mapperInterface.getName() + "." + methodName); + throw new BindingException( + "Invalid bound statement (not found): " + mapperInterface.getName() + "." + methodName); } } else { name = ms.getId(); @@ -251,8 +250,8 @@ public SqlCommandType getType() { return type; } - private MappedStatement resolveMappedStatement(Class mapperInterface, String methodName, - Class declaringClass, Configuration configuration) { + private MappedStatement resolveMappedStatement(Class mapperInterface, String methodName, Class declaringClass, + Configuration configuration) { String statementId = mapperInterface.getName() + "." + methodName; if (configuration.hasStatement(statementId)) { return configuration.getMappedStatement(statementId); @@ -261,8 +260,7 @@ private MappedStatement resolveMappedStatement(Class mapperInterface, String } for (Class superInterface : mapperInterface.getInterfaces()) { if (declaringClass.isAssignableFrom(superInterface)) { - MappedStatement ms = resolveMappedStatement(superInterface, methodName, - declaringClass, configuration); + MappedStatement ms = resolveMappedStatement(superInterface, methodName, declaringClass, configuration); if (ms != null) { return ms; } @@ -349,6 +347,7 @@ public boolean returnsCursor() { * return whether return type is {@code java.util.Optional}. * * @return return {@code true}, if return type is {@code java.util.Optional} + * * @since 3.5.0 */ public boolean returnsOptional() { @@ -363,7 +362,8 @@ private Integer getUniqueParamIndex(Method method, Class paramType) { if (index == null) { index = i; } else { - throw new BindingException(method.getName() + " cannot have multiple " + paramType.getSimpleName() + " parameters"); + throw new BindingException( + method.getName() + " cannot have multiple " + paramType.getSimpleName() + " parameters"); } } } diff --git a/src/main/java/org/apache/ibatis/binding/MapperRegistry.java b/src/main/java/org/apache/ibatis/binding/MapperRegistry.java index 0bce6fc1f43..f3484ac64b2 100644 --- a/src/main/java/org/apache/ibatis/binding/MapperRegistry.java +++ b/src/main/java/org/apache/ibatis/binding/MapperRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -83,6 +83,7 @@ public void addMapper(Class type) { * Gets the mappers. * * @return the mappers + * * @since 3.2.2 */ public Collection> getMappers() { @@ -96,6 +97,7 @@ public Collection> getMappers() { * the package name * @param superType * the super type + * * @since 3.2.2 */ public void addMappers(String packageName, Class superType) { @@ -112,6 +114,7 @@ public void addMappers(String packageName, Class superType) { * * @param packageName * the package name + * * @since 3.2.2 */ public void addMappers(String packageName) { diff --git a/src/main/java/org/apache/ibatis/builder/BaseBuilder.java b/src/main/java/org/apache/ibatis/builder/BaseBuilder.java index 7e7a443726b..ab1b8dbf63f 100644 --- a/src/main/java/org/apache/ibatis/builder/BaseBuilder.java +++ b/src/main/java/org/apache/ibatis/builder/BaseBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -125,7 +125,8 @@ protected TypeHandler resolveTypeHandler(Class javaType, String typeHandle } Class type = resolveClass(typeHandlerAlias); if (type != null && !TypeHandler.class.isAssignableFrom(type)) { - throw new BuilderException("Type " + type.getName() + " is not a valid TypeHandler because it does not implement TypeHandler interface"); + throw new BuilderException( + "Type " + type.getName() + " is not a valid TypeHandler because it does not implement TypeHandler interface"); } @SuppressWarnings("unchecked") // already verified it is a TypeHandler Class> typeHandlerType = (Class>) type; diff --git a/src/main/java/org/apache/ibatis/builder/InitializingObject.java b/src/main/java/org/apache/ibatis/builder/InitializingObject.java index 1f7c9f1a992..2dc09ba3050 100644 --- a/src/main/java/org/apache/ibatis/builder/InitializingObject.java +++ b/src/main/java/org/apache/ibatis/builder/InitializingObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -19,6 +19,7 @@ * Interface that indicate to provide an initialization method. * * @since 3.4.2 + * * @author Kazuki Shimizu */ public interface InitializingObject { diff --git a/src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java b/src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java index 4c9341a16a9..5758c138c2b 100644 --- a/src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java +++ b/src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -75,8 +75,8 @@ public void setCurrentNamespace(String currentNamespace) { } if (this.currentNamespace != null && !this.currentNamespace.equals(currentNamespace)) { - throw new BuilderException("Wrong namespace. Expected '" - + this.currentNamespace + "' but found '" + currentNamespace + "'."); + throw new BuilderException( + "Wrong namespace. Expected '" + this.currentNamespace + "' but found '" + currentNamespace + "'."); } this.currentNamespace = currentNamespace; @@ -204,8 +204,7 @@ public ResultMap addResultMap( resultMappings.addAll(extendedResultMappings); } ResultMap resultMap = new ResultMap.Builder(configuration, id, type, resultMappings, autoMapping) - .discriminator(discriminator) - .build(); + .discriminator(discriminator).build(); configuration.addResultMap(resultMap); return resultMap; } @@ -340,6 +339,7 @@ public MappedStatement addMappedStatement( * the database id * @param lang * the lang + * * @return the mapped statement */ public MappedStatement addMappedStatement(String id, SqlSource sqlSource, StatementType statementType, @@ -484,6 +484,7 @@ public ResultMapping buildResultMapping( * the type handler * @param flags * the flags + * * @return the result mapping */ public ResultMapping buildResultMapping(Class resultType, String property, String column, Class javaType, @@ -499,7 +500,9 @@ public ResultMapping buildResultMapping(Class resultType, String property, St * * @param langClass * the lang class + * * @return the language driver + * * @deprecated Use {@link Configuration#getLanguageDriver(Class)} */ @Deprecated diff --git a/src/main/java/org/apache/ibatis/builder/ResultMapResolver.java b/src/main/java/org/apache/ibatis/builder/ResultMapResolver.java index 907a1ca8b48..7fb6edbafc4 100644 --- a/src/main/java/org/apache/ibatis/builder/ResultMapResolver.java +++ b/src/main/java/org/apache/ibatis/builder/ResultMapResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -33,7 +33,8 @@ public class ResultMapResolver { private final List resultMappings; private final Boolean autoMapping; - public ResultMapResolver(MapperBuilderAssistant assistant, String id, Class type, String extend, Discriminator discriminator, List resultMappings, Boolean autoMapping) { + public ResultMapResolver(MapperBuilderAssistant assistant, String id, Class type, String extend, + Discriminator discriminator, List resultMappings, Boolean autoMapping) { this.assistant = assistant; this.id = id; this.type = type; @@ -44,7 +45,8 @@ public ResultMapResolver(MapperBuilderAssistant assistant, String id, Class t } public ResultMap resolve() { - return assistant.addResultMap(this.id, this.type, this.extend, this.discriminator, this.resultMappings, this.autoMapping); + return assistant.addResultMap(this.id, this.type, this.extend, this.discriminator, this.resultMappings, + this.autoMapping); } } diff --git a/src/main/java/org/apache/ibatis/builder/SqlSourceBuilder.java b/src/main/java/org/apache/ibatis/builder/SqlSourceBuilder.java index 9c6b3fb2765..3a643ccf8cc 100644 --- a/src/main/java/org/apache/ibatis/builder/SqlSourceBuilder.java +++ b/src/main/java/org/apache/ibatis/builder/SqlSourceBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -41,7 +41,8 @@ public SqlSourceBuilder(Configuration configuration) { } public SqlSource parse(String originalSql, Class parameterType, Map additionalParameters) { - ParameterMappingTokenHandler handler = new ParameterMappingTokenHandler(configuration, parameterType, additionalParameters); + ParameterMappingTokenHandler handler = new ParameterMappingTokenHandler(configuration, parameterType, + additionalParameters); GenericTokenParser parser = new GenericTokenParser("#{", "}", handler); String sql; if (configuration.isShrinkWhitespacesInSql()) { @@ -72,7 +73,8 @@ private static class ParameterMappingTokenHandler extends BaseBuilder implements private final Class parameterType; private final MetaObject metaParameters; - public ParameterMappingTokenHandler(Configuration configuration, Class parameterType, Map additionalParameters) { + public ParameterMappingTokenHandler(Configuration configuration, Class parameterType, + Map additionalParameters) { super(configuration); this.parameterType = parameterType; this.metaParameters = configuration.newMetaObject(additionalParameters); @@ -134,7 +136,8 @@ private ParameterMapping buildParameterMapping(String content) { } else if ("expression".equals(name)) { throw new BuilderException("Expression based parameters are not supported yet"); } else { - throw new BuilderException("An invalid property '" + name + "' was found in mapping #{" + content + "}. Valid properties are " + PARAMETER_PROPERTIES); + throw new BuilderException("An invalid property '" + name + "' was found in mapping #{" + content + + "}. Valid properties are " + PARAMETER_PROPERTIES); } } if (typeHandlerAlias != null) { @@ -149,7 +152,8 @@ private Map parseParameterMapping(String content) { } catch (BuilderException ex) { throw ex; } catch (Exception ex) { - throw new BuilderException("Parsing error was found in mapping #{" + content + "}. Check syntax #{property|(expression), var1=value1, var2=value2, ...} ", ex); + throw new BuilderException("Parsing error was found in mapping #{" + content + + "}. Check syntax #{property|(expression), var1=value1, var2=value2, ...} ", ex); } } } diff --git a/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java b/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java index 3a8c533bed6..160790f551f 100644 --- a/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java +++ b/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java @@ -175,7 +175,8 @@ private void loadXmlResource() { } } if (inputStream != null) { - XMLMapperBuilder xmlParser = new XMLMapperBuilder(inputStream, assistant.getConfiguration(), xmlResource, configuration.getSqlFragments(), type.getName()); + XMLMapperBuilder xmlParser = new XMLMapperBuilder(inputStream, assistant.getConfiguration(), xmlResource, + configuration.getSqlFragments(), type.getName()); xmlParser.parse(); } } @@ -187,7 +188,8 @@ private void parseCache() { Integer size = cacheDomain.size() == 0 ? null : cacheDomain.size(); Long flushInterval = cacheDomain.flushInterval() == 0 ? null : cacheDomain.flushInterval(); Properties props = convertToProperties(cacheDomain.properties()); - assistant.useNewCache(cacheDomain.implementation(), cacheDomain.eviction(), flushInterval, size, cacheDomain.readWrite(), cacheDomain.blocking(), props); + assistant.useNewCache(cacheDomain.implementation(), cacheDomain.eviction(), flushInterval, size, + cacheDomain.readWrite(), cacheDomain.blocking(), props); } } @@ -197,8 +199,7 @@ private Properties convertToProperties(Property[] properties) { } Properties props = new Properties(); for (Property property : properties) { - props.setProperty(property.name(), - PropertyParser.parse(property.value(), configuration.getVariables())); + props.setProperty(property.name(), PropertyParser.parse(property.value(), configuration.getVariables())); } return props; } @@ -249,7 +250,8 @@ private String generateResultMapName(Method method) { return type.getName() + "." + method.getName() + suffix; } - private void applyResultMap(String resultMapId, Class returnType, Arg[] args, Result[] results, TypeDiscriminator discriminator) { + private void applyResultMap(String resultMapId, Class returnType, Arg[] args, Result[] results, + TypeDiscriminator discriminator) { List resultMappings = new ArrayList<>(); applyConstructorArgs(args, returnType, resultMappings); applyResults(results, returnType, resultMappings); @@ -279,8 +281,8 @@ private Discriminator applyDiscriminator(String resultMapId, Class resultType Class javaType = discriminator.javaType() == void.class ? String.class : discriminator.javaType(); JdbcType jdbcType = discriminator.jdbcType() == JdbcType.UNDEFINED ? null : discriminator.jdbcType(); @SuppressWarnings("unchecked") - Class> typeHandler = (Class>) - (discriminator.typeHandler() == UnknownTypeHandler.class ? null : discriminator.typeHandler()); + Class> typeHandler = (Class>) (discriminator + .typeHandler() == UnknownTypeHandler.class ? null : discriminator.typeHandler()); Case[] cases = discriminator.cases(); Map discriminatorMap = new HashMap<>(); for (Case c : cases) { @@ -298,9 +300,11 @@ void parseStatement(Method method) { final LanguageDriver languageDriver = getLanguageDriver(method); getAnnotationWrapper(method, true, statementAnnotationTypes).ifPresent(statementAnnotation -> { - final SqlSource sqlSource = buildSqlSource(statementAnnotation.getAnnotation(), parameterTypeClass, languageDriver, method); + final SqlSource sqlSource = buildSqlSource(statementAnnotation.getAnnotation(), parameterTypeClass, + languageDriver, method); final SqlCommandType sqlCommandType = statementAnnotation.getSqlCommandType(); - final Options options = getAnnotationWrapper(method, false, Options.class).map(x -> (Options)x.getAnnotation()).orElse(null); + final Options options = getAnnotationWrapper(method, false, Options.class).map(x -> (Options) x.getAnnotation()) + .orElse(null); final String mappedStatementId = type.getName() + "." + method.getName(); final KeyGenerator keyGenerator; @@ -308,9 +312,11 @@ void parseStatement(Method method) { String keyColumn = null; if (SqlCommandType.INSERT.equals(sqlCommandType) || SqlCommandType.UPDATE.equals(sqlCommandType)) { // first check for SelectKey annotation - that overrides everything else - SelectKey selectKey = getAnnotationWrapper(method, false, SelectKey.class).map(x -> (SelectKey)x.getAnnotation()).orElse(null); + SelectKey selectKey = getAnnotationWrapper(method, false, SelectKey.class) + .map(x -> (SelectKey) x.getAnnotation()).orElse(null); if (selectKey != null) { - keyGenerator = handleSelectKeyAnnotation(selectKey, mappedStatementId, getParameterType(method), languageDriver); + keyGenerator = handleSelectKeyAnnotation(selectKey, mappedStatementId, getParameterType(method), + languageDriver); keyProperty = selectKey.keyProperty(); } else if (options == null) { keyGenerator = configuration.isUseGeneratedKeys() ? Jdbc3KeyGenerator.INSTANCE : NoKeyGenerator.INSTANCE; @@ -337,7 +343,8 @@ void parseStatement(Method method) { flushCache = false; } useCache = options.useCache(); - fetchSize = options.fetchSize() > -1 || options.fetchSize() == Integer.MIN_VALUE ? options.fetchSize() : null; //issue #348 + // issue #348 + fetchSize = options.fetchSize() > -1 || options.fetchSize() == Integer.MIN_VALUE ? options.fetchSize() : null; timeout = options.timeout() > -1 ? options.timeout() : null; statementType = options.statementType(); if (options.resultSetType() != ResultSetType.DEFAULT) { @@ -396,7 +403,8 @@ private Class getParameterType(Method method) { Class parameterType = null; Class[] parameterTypes = method.getParameterTypes(); for (Class currentParameterType : parameterTypes) { - if (!RowBounds.class.isAssignableFrom(currentParameterType) && !ResultHandler.class.isAssignableFrom(currentParameterType)) { + if (!RowBounds.class.isAssignableFrom(currentParameterType) + && !ResultHandler.class.isAssignableFrom(currentParameterType)) { if (parameterType == null) { parameterType = currentParameterType; } else { @@ -581,7 +589,8 @@ private String nullOrEmpty(String value) { return value == null || value.trim().length() == 0 ? null : value; } - private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class parameterTypeClass, LanguageDriver languageDriver) { + private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, + Class parameterTypeClass, LanguageDriver languageDriver) { String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX; Class resultTypeClass = selectKeyAnnotation.resultType(); StatementType statementType = selectKeyAnnotation.statementType(); diff --git a/src/main/java/org/apache/ibatis/builder/annotation/ProviderContext.java b/src/main/java/org/apache/ibatis/builder/annotation/ProviderContext.java index 498d6b2b29a..2665868554f 100644 --- a/src/main/java/org/apache/ibatis/builder/annotation/ProviderContext.java +++ b/src/main/java/org/apache/ibatis/builder/annotation/ProviderContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -21,6 +21,7 @@ * The context object for sql provider method. * * @author Kazuki Shimizu + * * @since 3.4.5 */ public final class ProviderContext { @@ -67,6 +68,7 @@ public Method getMapperMethod() { * Get a database id that provided from {@link org.apache.ibatis.mapping.DatabaseIdProvider}. * * @return A database id + * * @since 3.5.1 */ public String getDatabaseId() { diff --git a/src/main/java/org/apache/ibatis/builder/annotation/ProviderMethodResolver.java b/src/main/java/org/apache/ibatis/builder/annotation/ProviderMethodResolver.java index 7bb0fd37bb6..cc9cf2202ac 100644 --- a/src/main/java/org/apache/ibatis/builder/annotation/ProviderMethodResolver.java +++ b/src/main/java/org/apache/ibatis/builder/annotation/ProviderMethodResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,36 +24,41 @@ /** * The interface that resolve an SQL provider method via an SQL provider class. - * - *

This interface need to implements at an SQL provider class and - * it need to define the default constructor for creating a new instance. + *

+ * This interface need to implements at an SQL provider class and it need to define the default constructor for creating + * a new instance. * * @since 3.5.1 + * * @author Kazuki Shimizu */ public interface ProviderMethodResolver { /** * Resolve an SQL provider method. - * - *

The default implementation return a method that matches following conditions. + *

+ * The default implementation return a method that matches following conditions. *

    *
  • Method name matches with mapper method
  • *
  • Return type matches the {@link CharSequence}({@link String}, {@link StringBuilder}, etc...)
  • *
* If matched method is zero or multiple, it throws a {@link BuilderException}. * - * @param context a context for SQL provider + * @param context + * a context for SQL provider + * * @return an SQL provider method - * @throws BuilderException Throws when cannot resolve a target method + * + * @throws BuilderException + * Throws when cannot resolve a target method */ default Method resolveMethod(ProviderContext context) { List sameNameMethods = Arrays.stream(getClass().getMethods()) .filter(m -> m.getName().equals(context.getMapperMethod().getName())) .collect(Collectors.toList()); if (sameNameMethods.isEmpty()) { - throw new BuilderException("Cannot resolve the provider method because '" - + context.getMapperMethod().getName() + "' not found in SqlProvider '" + getClass().getName() + "'."); + throw new BuilderException("Cannot resolve the provider method because '" + context.getMapperMethod().getName() + + "' not found in SqlProvider '" + getClass().getName() + "'."); } List targetMethods = sameNameMethods.stream() .filter(m -> CharSequence.class.isAssignableFrom(m.getReturnType())) @@ -62,12 +67,11 @@ default Method resolveMethod(ProviderContext context) { return targetMethods.get(0); } if (targetMethods.isEmpty()) { - throw new BuilderException("Cannot resolve the provider method because '" - + context.getMapperMethod().getName() + "' does not return the CharSequence or its subclass in SqlProvider '" - + getClass().getName() + "'."); + throw new BuilderException("Cannot resolve the provider method because '" + context.getMapperMethod().getName() + + "' does not return the CharSequence or its subclass in SqlProvider '" + getClass().getName() + "'."); } else { - throw new BuilderException("Cannot resolve the provider method because '" - + context.getMapperMethod().getName() + "' is found multiple in SqlProvider '" + getClass().getName() + "'."); + throw new BuilderException("Cannot resolve the provider method because '" + context.getMapperMethod().getName() + + "' is found multiple in SqlProvider '" + getClass().getName() + "'."); } } diff --git a/src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java b/src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java index 7b8781b26b1..bee88b36c47 100644 --- a/src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java +++ b/src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -52,6 +52,7 @@ public class ProviderSqlSource implements SqlSource { * the configuration * @param provider * the provider + * * @deprecated Since 3.5.3, Please use the {@link #ProviderSqlSource(Configuration, Annotation, Class, Method)} * instead of this. */ @@ -71,8 +72,11 @@ public ProviderSqlSource(Configuration configuration, Object provider) { * the mapper type * @param mapperMethod * the mapper method + * * @since 3.4.5 - * @deprecated Since 3.5.3, Please use the {@link #ProviderSqlSource(Configuration, Annotation, Class, Method)} instead of this. + * + * @deprecated Since 3.5.3, Please use the {@link #ProviderSqlSource(Configuration, Annotation, Class, Method)} + * instead of this. */ @Deprecated public ProviderSqlSource(Configuration configuration, Object provider, Class mapperType, Method mapperMethod) { @@ -90,6 +94,7 @@ public ProviderSqlSource(Configuration configuration, Object provider, Class * the mapper type * @param mapperMethod * the mapper method + * * @since 3.5.3 */ public ProviderSqlSource(Configuration configuration, Annotation provider, Class mapperType, Method mapperMethod) { @@ -103,14 +108,17 @@ public ProviderSqlSource(Configuration configuration, Annotation provider, Class this.providerType = getProviderType(configuration, provider, mapperMethod); candidateProviderMethodName = (String) provider.annotationType().getMethod("method").invoke(provider); - if (candidateProviderMethodName.length() == 0 && ProviderMethodResolver.class.isAssignableFrom(this.providerType)) { + if (candidateProviderMethodName.length() == 0 + && ProviderMethodResolver.class.isAssignableFrom(this.providerType)) { candidateProviderMethod = ((ProviderMethodResolver) this.providerType.getDeclaredConstructor().newInstance()) .resolveMethod(new ProviderContext(mapperType, mapperMethod, configuration.getDatabaseId())); } if (candidateProviderMethod == null) { - candidateProviderMethodName = candidateProviderMethodName.length() == 0 ? "provideSql" : candidateProviderMethodName; + candidateProviderMethodName = candidateProviderMethodName.length() == 0 ? "provideSql" + : candidateProviderMethodName; for (Method m : this.providerType.getMethods()) { - if (candidateProviderMethodName.equals(m.getName()) && CharSequence.class.isAssignableFrom(m.getReturnType())) { + if (candidateProviderMethodName.equals(m.getName()) + && CharSequence.class.isAssignableFrom(m.getReturnType())) { if (candidateProviderMethod != null) { throw new BuilderException("Error creating SqlSource for SqlProvider. Method '" + candidateProviderMethodName + "' is found multiple in SqlProvider '" + this.providerType.getName() @@ -126,8 +134,8 @@ public ProviderSqlSource(Configuration configuration, Annotation provider, Class throw new BuilderException("Error creating SqlSource for SqlProvider. Cause: " + e, e); } if (candidateProviderMethod == null) { - throw new BuilderException("Error creating SqlSource for SqlProvider. Method '" - + candidateProviderMethodName + "' not found in SqlProvider '" + this.providerType.getName() + "'."); + throw new BuilderException("Error creating SqlSource for SqlProvider. Method '" + candidateProviderMethodName + + "' not found in SqlProvider '" + this.providerType.getName() + "'."); } this.providerMethod = candidateProviderMethod; this.providerMethodArgumentNames = new ParamNameResolver(configuration, this.providerMethod).getNames(); @@ -139,9 +147,10 @@ public ProviderSqlSource(Configuration configuration, Annotation provider, Class Class parameterType = this.providerMethodParameterTypes[i]; if (parameterType == ProviderContext.class) { if (candidateProviderContext != null) { - throw new BuilderException("Error creating SqlSource for SqlProvider. ProviderContext found multiple in SqlProvider method (" - + this.providerType.getName() + "." + providerMethod.getName() - + "). ProviderContext can not define multiple in SqlProvider method argument."); + throw new BuilderException( + "Error creating SqlSource for SqlProvider. ProviderContext found multiple in SqlProvider method (" + + this.providerType.getName() + "." + providerMethod.getName() + + "). ProviderContext can not define multiple in SqlProvider method argument."); } candidateProviderContext = new ProviderContext(mapperType, mapperMethod, configuration.getDatabaseId()); candidateProviderContextIndex = i; @@ -163,7 +172,8 @@ private SqlSource createSqlSource(Object parameterObject) { if (parameterObject instanceof Map) { int bindParameterCount = providerMethodParameterTypes.length - (providerContext == null ? 0 : 1); if (bindParameterCount == 1 - && providerMethodParameterTypes[Integer.valueOf(0).equals(providerContextIndex) ? 1 : 0].isAssignableFrom(parameterObject.getClass())) { + && providerMethodParameterTypes[Integer.valueOf(0).equals(providerContextIndex) ? 1 : 0] + .isAssignableFrom(parameterObject.getClass())) { sql = invokeProviderMethod(extractProviderMethodArguments(parameterObject)); } else { @SuppressWarnings("unchecked") @@ -181,17 +191,17 @@ private SqlSource createSqlSource(Object parameterObject) { } else if (providerMethodParameterTypes.length == 2) { sql = invokeProviderMethod(extractProviderMethodArguments(parameterObject)); } else { - throw new BuilderException("Cannot invoke SqlProvider method '" + providerMethod - + "' with specify parameter '" + (parameterObject == null ? null : parameterObject.getClass()) - + "' because SqlProvider method arguments for '" + mapperMethod + "' is an invalid combination."); + throw new BuilderException("Cannot invoke SqlProvider method '" + providerMethod + "' with specify parameter '" + + (parameterObject == null ? null : parameterObject.getClass()) + + "' because SqlProvider method arguments for '" + mapperMethod + "' is an invalid combination."); } Class parameterType = parameterObject == null ? Object.class : parameterObject.getClass(); return languageDriver.createSqlSource(configuration, sql, parameterType); } catch (BuilderException e) { throw e; } catch (Exception e) { - throw new BuilderException("Error invoking SqlProvider method '" + providerMethod - + "' with specify parameter '" + (parameterObject == null ? null : parameterObject.getClass()) + "'. Cause: " + extractRootCause(e), e); + throw new BuilderException("Error invoking SqlProvider method '" + providerMethod + "' with specify parameter '" + + (parameterObject == null ? null : parameterObject.getClass()) + "'. Cause: " + extractRootCause(e), e); } } @@ -244,13 +254,11 @@ private Class getProviderType(Configuration configuration, Annotation provide return configuration.getDefaultSqlProviderType(); } throw new BuilderException("Please specify either 'value' or 'type' attribute of @" - + providerAnnotation.annotationType().getSimpleName() - + " at the '" + mapperMethod.toString() + "'."); + + providerAnnotation.annotationType().getSimpleName() + " at the '" + mapperMethod.toString() + "'."); } if (value != void.class && type != void.class && value != type) { throw new BuilderException("Cannot specify different class on 'value' and 'type' attribute of @" - + providerAnnotation.annotationType().getSimpleName() - + " at the '" + mapperMethod.toString() + "'."); + + providerAnnotation.annotationType().getSimpleName() + " at the '" + mapperMethod.toString() + "'."); } return value == void.class ? type : value; } diff --git a/src/main/java/org/apache/ibatis/builder/xml/XMLConfigBuilder.java b/src/main/java/org/apache/ibatis/builder/xml/XMLConfigBuilder.java index 0bb9a4d827d..b0d1854dc28 100644 --- a/src/main/java/org/apache/ibatis/builder/xml/XMLConfigBuilder.java +++ b/src/main/java/org/apache/ibatis/builder/xml/XMLConfigBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -70,7 +70,8 @@ public XMLConfigBuilder(Reader reader, String environment, Properties props) { this(Configuration.class, reader, environment, props); } - public XMLConfigBuilder(Class configClass, Reader reader, String environment, Properties props) { + public XMLConfigBuilder(Class configClass, Reader reader, String environment, + Properties props) { this(configClass, new XPathParser(reader, true, props, new XMLMapperEntityResolver()), environment, props); } @@ -86,11 +87,13 @@ public XMLConfigBuilder(InputStream inputStream, String environment, Properties this(Configuration.class, inputStream, environment, props); } - public XMLConfigBuilder(Class configClass, InputStream inputStream, String environment, Properties props) { + public XMLConfigBuilder(Class configClass, InputStream inputStream, String environment, + Properties props) { this(configClass, new XPathParser(inputStream, true, props, new XMLMapperEntityResolver()), environment, props); } - private XMLConfigBuilder(Class configClass, XPathParser parser, String environment, Properties props) { + private XMLConfigBuilder(Class configClass, XPathParser parser, String environment, + Properties props) { super(newConfig(configClass)); ErrorContext.instance().resource("SQL Mapper Configuration"); this.configuration.setVariables(props); @@ -140,7 +143,8 @@ private Properties settingsAsProperties(XNode context) { MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory); for (Object key : props.keySet()) { if (!metaConfig.hasSetter(String.valueOf(key))) { - throw new BuilderException("The setting " + key + " is not known. Make sure you spelled it correctly (case sensitive)."); + throw new BuilderException( + "The setting " + key + " is not known. Make sure you spelled it correctly (case sensitive)."); } } return props; @@ -153,7 +157,7 @@ private void loadCustomVfs(Properties props) throws ClassNotFoundException { for (String clazz : clazzes) { if (!clazz.isEmpty()) { @SuppressWarnings("unchecked") - Class vfsImpl = (Class)Resources.classForName(clazz); + Class vfsImpl = (Class) Resources.classForName(clazz); configuration.setVfsImpl(vfsImpl); } } @@ -194,7 +198,8 @@ private void pluginElement(XNode parent) throws Exception { for (XNode child : parent.getChildren()) { String interceptor = child.getStringAttribute("interceptor"); Properties properties = child.getChildrenAsProperties(); - Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).getDeclaredConstructor().newInstance(); + Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).getDeclaredConstructor() + .newInstance(); interceptorInstance.setProperties(properties); configuration.addInterceptor(interceptorInstance); } @@ -233,7 +238,8 @@ private void propertiesElement(XNode context) throws Exception { String resource = context.getStringAttribute("resource"); String url = context.getStringAttribute("url"); if (resource != null && url != null) { - throw new BuilderException("The properties element cannot specify both a URL and a resource based property file reference. Please specify one or the other."); + throw new BuilderException( + "The properties element cannot specify both a URL and a resource based property file reference. Please specify one or the other."); } if (resource != null) { defaults.putAll(Resources.getResourceAsProperties(resource)); @@ -250,8 +256,10 @@ private void propertiesElement(XNode context) throws Exception { } private void settingsElement(Properties props) { - configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL"))); - configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE"))); + configuration + .setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL"))); + configuration.setAutoMappingUnknownColumnBehavior( + AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE"))); configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true)); configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory"))); configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false)); @@ -267,7 +275,8 @@ private void settingsElement(Properties props) { configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false)); configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION"))); configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER"))); - configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString")); + configuration.setLazyLoadTriggerMethods( + stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString")); configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true)); configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage"))); configuration.setDefaultEnumTypeHandler(resolveClass(props.getProperty("defaultEnumTypeHandler"))); @@ -277,7 +286,8 @@ private void settingsElement(Properties props) { configuration.setLogPrefix(props.getProperty("logPrefix")); configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory"))); configuration.setShrinkWhitespacesInSql(booleanValueOf(props.getProperty("shrinkWhitespacesInSql"), false)); - configuration.setArgNameBasedConstructorAutoMapping(booleanValueOf(props.getProperty("argNameBasedConstructorAutoMapping"), false)); + configuration.setArgNameBasedConstructorAutoMapping( + booleanValueOf(props.getProperty("argNameBasedConstructorAutoMapping"), false)); configuration.setDefaultSqlProviderType(resolveClass(props.getProperty("defaultSqlProviderType"))); configuration.setNullableOnForEach(booleanValueOf(props.getProperty("nullableOnForEach"), false)); } @@ -293,8 +303,7 @@ private void environmentsElement(XNode context) throws Exception { TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager")); DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource")); DataSource dataSource = dsFactory.getDataSource(); - Environment.Builder environmentBuilder = new Environment.Builder(id) - .transactionFactory(txFactory) + Environment.Builder environmentBuilder = new Environment.Builder(id).transactionFactory(txFactory) .dataSource(dataSource); configuration.setEnvironment(environmentBuilder.build()); break; @@ -383,21 +392,24 @@ private void mapperElement(XNode parent) throws Exception { String mapperClass = child.getStringAttribute("class"); if (resource != null && url == null && mapperClass == null) { ErrorContext.instance().resource(resource); - try(InputStream inputStream = Resources.getResourceAsStream(resource)) { - XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments()); + try (InputStream inputStream = Resources.getResourceAsStream(resource)) { + XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, resource, + configuration.getSqlFragments()); mapperParser.parse(); } } else if (resource == null && url != null && mapperClass == null) { ErrorContext.instance().resource(url); - try(InputStream inputStream = Resources.getUrlAsStream(url)){ - XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, url, configuration.getSqlFragments()); + try (InputStream inputStream = Resources.getUrlAsStream(url)) { + XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, url, + configuration.getSqlFragments()); mapperParser.parse(); } } else if (resource == null && url == null && mapperClass != null) { Class mapperInterface = Resources.classForName(mapperClass); configuration.addMapper(mapperInterface); } else { - throw new BuilderException("A mapper element may only specify a url, resource or class, but not more than one."); + throw new BuilderException( + "A mapper element may only specify a url, resource or class, but not more than one."); } } } diff --git a/src/main/java/org/apache/ibatis/builder/xml/XMLIncludeTransformer.java b/src/main/java/org/apache/ibatis/builder/xml/XMLIncludeTransformer.java index 1fc8356d315..cd0a893acbf 100644 --- a/src/main/java/org/apache/ibatis/builder/xml/XMLIncludeTransformer.java +++ b/src/main/java/org/apache/ibatis/builder/xml/XMLIncludeTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -113,6 +113,7 @@ private String getStringAttribute(Node node, String name) { * Include node instance * @param inheritedVariablesContext * Current context used for replace variables in new variables values + * * @return variables context from include instance (no inherited values) */ private Properties getVariablesContext(Node node, Properties inheritedVariablesContext) { diff --git a/src/main/java/org/apache/ibatis/builder/xml/XMLMapperBuilder.java b/src/main/java/org/apache/ibatis/builder/xml/XMLMapperBuilder.java index cbff63e334e..4f9f21a1d86 100644 --- a/src/main/java/org/apache/ibatis/builder/xml/XMLMapperBuilder.java +++ b/src/main/java/org/apache/ibatis/builder/xml/XMLMapperBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -61,28 +61,33 @@ public class XMLMapperBuilder extends BaseBuilder { private final String resource; @Deprecated - public XMLMapperBuilder(Reader reader, Configuration configuration, String resource, Map sqlFragments, String namespace) { + public XMLMapperBuilder(Reader reader, Configuration configuration, String resource, Map sqlFragments, + String namespace) { this(reader, configuration, resource, sqlFragments); this.builderAssistant.setCurrentNamespace(namespace); } @Deprecated - public XMLMapperBuilder(Reader reader, Configuration configuration, String resource, Map sqlFragments) { - this(new XPathParser(reader, true, configuration.getVariables(), new XMLMapperEntityResolver()), - configuration, resource, sqlFragments); + public XMLMapperBuilder(Reader reader, Configuration configuration, String resource, + Map sqlFragments) { + this(new XPathParser(reader, true, configuration.getVariables(), new XMLMapperEntityResolver()), configuration, + resource, sqlFragments); } - public XMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource, Map sqlFragments, String namespace) { + public XMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource, + Map sqlFragments, String namespace) { this(inputStream, configuration, resource, sqlFragments); this.builderAssistant.setCurrentNamespace(namespace); } - public XMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource, Map sqlFragments) { - this(new XPathParser(inputStream, true, configuration.getVariables(), new XMLMapperEntityResolver()), - configuration, resource, sqlFragments); + public XMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource, + Map sqlFragments) { + this(new XPathParser(inputStream, true, configuration.getVariables(), new XMLMapperEntityResolver()), configuration, + resource, sqlFragments); } - private XMLMapperBuilder(XPathParser parser, Configuration configuration, String resource, Map sqlFragments) { + private XMLMapperBuilder(XPathParser parser, Configuration configuration, String resource, + Map sqlFragments) { super(configuration); this.builderAssistant = new MapperBuilderAssistant(configuration, resource); this.parser = parser; @@ -133,7 +138,8 @@ private void buildStatementFromContext(List list) { private void buildStatementFromContext(List list, String requiredDatabaseId) { for (XNode context : list) { - final XMLStatementBuilder statementParser = new XMLStatementBuilder(configuration, builderAssistant, context, requiredDatabaseId); + final XMLStatementBuilder statementParser = new XMLStatementBuilder(configuration, builderAssistant, context, + requiredDatabaseId); try { statementParser.parseStatementNode(); } catch (IncompleteElementException e) { @@ -190,7 +196,8 @@ private void parsePendingStatements() { private void cacheRefElement(XNode context) { if (context != null) { configuration.addCacheRef(builderAssistant.getCurrentNamespace(), context.getStringAttribute("namespace")); - CacheRefResolver cacheRefResolver = new CacheRefResolver(builderAssistant, context.getStringAttribute("namespace")); + CacheRefResolver cacheRefResolver = new CacheRefResolver(builderAssistant, + context.getStringAttribute("namespace")); try { cacheRefResolver.resolveCacheRef(); } catch (IncompleteElementException e) { @@ -233,7 +240,8 @@ private void parameterMapElement(List list) { Class javaTypeClass = resolveClass(javaType); JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType); Class> typeHandlerClass = resolveClass(typeHandler); - ParameterMapping parameterMapping = builderAssistant.buildParameterMapping(parameterClass, property, javaTypeClass, jdbcTypeEnum, resultMap, modeEnum, typeHandlerClass, numericScale); + ParameterMapping parameterMapping = builderAssistant.buildParameterMapping(parameterClass, property, + javaTypeClass, jdbcTypeEnum, resultMap, modeEnum, typeHandlerClass, numericScale); parameterMappings.add(parameterMapping); } builderAssistant.addParameterMap(id, parameterClass, parameterMappings); @@ -254,7 +262,8 @@ private ResultMap resultMapElement(XNode resultMapNode) { return resultMapElement(resultMapNode, Collections.emptyList(), null); } - private ResultMap resultMapElement(XNode resultMapNode, List additionalResultMappings, Class enclosingType) { + private ResultMap resultMapElement(XNode resultMapNode, List additionalResultMappings, + Class enclosingType) { ErrorContext.instance().activity("processing " + resultMapNode.getValueBasedIdentifier()); String type = resultMapNode.getStringAttribute("type", resultMapNode.getStringAttribute("ofType", @@ -280,11 +289,11 @@ private ResultMap resultMapElement(XNode resultMapNode, List addi resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags)); } } - String id = resultMapNode.getStringAttribute("id", - resultMapNode.getValueBasedIdentifier()); + String id = resultMapNode.getStringAttribute("id", resultMapNode.getValueBasedIdentifier()); String extend = resultMapNode.getStringAttribute("extends"); Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping"); - ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend, discriminator, resultMappings, autoMapping); + ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend, discriminator, + resultMappings, autoMapping); try { return resultMapResolver.resolve(); } catch (IncompleteElementException e) { @@ -318,7 +327,8 @@ private void processConstructorElement(XNode resultChild, Class resultType, L } } - private Discriminator processDiscriminatorElement(XNode context, Class resultType, List resultMappings) { + private Discriminator processDiscriminatorElement(XNode context, Class resultType, + List resultMappings) { String column = context.getStringAttribute("column"); String javaType = context.getStringAttribute("javaType"); String jdbcType = context.getStringAttribute("jdbcType"); @@ -329,10 +339,12 @@ private Discriminator processDiscriminatorElement(XNode context, Class result Map discriminatorMap = new HashMap<>(); for (XNode caseChild : context.getChildren()) { String value = caseChild.getStringAttribute("value"); - String resultMap = caseChild.getStringAttribute("resultMap", processNestedResultMappings(caseChild, resultMappings, resultType)); + String resultMap = caseChild.getStringAttribute("resultMap", + processNestedResultMappings(caseChild, resultMappings, resultType)); discriminatorMap.put(value, resultMap); } - return builderAssistant.buildDiscriminator(resultType, column, javaTypeClass, jdbcTypeEnum, typeHandlerClass, discriminatorMap); + return builderAssistant.buildDiscriminator(resultType, column, javaTypeClass, jdbcTypeEnum, typeHandlerClass, + discriminatorMap); } private void sqlElement(List list) { @@ -393,7 +405,8 @@ private ResultMapping buildResultMappingFromContext(XNode context, Class resu return builderAssistant.buildResultMapping(resultType, property, column, javaTypeClass, jdbcTypeEnum, nestedSelect, nestedResultMap, notNullColumn, columnPrefix, typeHandlerClass, flags, resultSet, foreignColumn, lazy); } - private String processNestedResultMappings(XNode context, List resultMappings, Class enclosingType) { + private String processNestedResultMappings(XNode context, List resultMappings, + Class enclosingType) { if (Arrays.asList("association", "collection", "case").contains(context.getName()) && context.getStringAttribute("select") == null) { validateCollection(context, enclosingType); diff --git a/src/main/java/org/apache/ibatis/builder/xml/XMLMapperEntityResolver.java b/src/main/java/org/apache/ibatis/builder/xml/XMLMapperEntityResolver.java index 916dc7ca8f2..3136fc3ef65 100644 --- a/src/main/java/org/apache/ibatis/builder/xml/XMLMapperEntityResolver.java +++ b/src/main/java/org/apache/ibatis/builder/xml/XMLMapperEntityResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -47,6 +47,7 @@ public class XMLMapperEntityResolver implements EntityResolver { * The public id that is what comes after "PUBLIC" * @param systemId * The system id that is what comes after the public id. + * * @return The InputSource for the DTD * * @throws org.xml.sax.SAXException @@ -59,7 +60,8 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc String lowerCaseSystemId = systemId.toLowerCase(Locale.ENGLISH); if (lowerCaseSystemId.contains(MYBATIS_CONFIG_SYSTEM) || lowerCaseSystemId.contains(IBATIS_CONFIG_SYSTEM)) { return getInputSource(MYBATIS_CONFIG_DTD, publicId, systemId); - } else if (lowerCaseSystemId.contains(MYBATIS_MAPPER_SYSTEM) || lowerCaseSystemId.contains(IBATIS_MAPPER_SYSTEM)) { + } else if (lowerCaseSystemId.contains(MYBATIS_MAPPER_SYSTEM) + || lowerCaseSystemId.contains(IBATIS_MAPPER_SYSTEM)) { return getInputSource(MYBATIS_MAPPER_DTD, publicId, systemId); } } diff --git a/src/main/java/org/apache/ibatis/cache/Cache.java b/src/main/java/org/apache/ibatis/cache/Cache.java index 34028a284b3..a09e9cd004e 100644 --- a/src/main/java/org/apache/ibatis/cache/Cache.java +++ b/src/main/java/org/apache/ibatis/cache/Cache.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -57,23 +57,20 @@ public interface Cache { /** * @param key * The key + * * @return The object stored in the cache. */ Object getObject(Object key); /** - * As of 3.3.0 this method is only called during a rollback - * for any previous value that was missing in the cache. - * This lets any blocking cache to release the lock that - * may have previously put on the key. - * A blocking cache puts a lock when a value is null - * and releases it when the value is back again. - * This way other threads will wait for the value to be - * available instead of hitting the database. - * + * As of 3.3.0 this method is only called during a rollback for any previous value that was missing in the cache. This + * lets any blocking cache to release the lock that may have previously put on the key. A blocking cache puts a lock + * when a value is null and releases it when the value is back again. This way other threads will wait for the value + * to be available instead of hitting the database. * * @param key * The key + * * @return Not used */ Object removeObject(Object key); diff --git a/src/main/java/org/apache/ibatis/cache/NullCacheKey.java b/src/main/java/org/apache/ibatis/cache/NullCacheKey.java index eeca8746aae..55a62592972 100644 --- a/src/main/java/org/apache/ibatis/cache/NullCacheKey.java +++ b/src/main/java/org/apache/ibatis/cache/NullCacheKey.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -17,6 +17,7 @@ /** * @author Clinton Begin + * * @deprecated Since 3.5.3, This class never used and will be removed future version. */ @Deprecated diff --git a/src/main/java/org/apache/ibatis/cache/decorators/BlockingCache.java b/src/main/java/org/apache/ibatis/cache/decorators/BlockingCache.java index 0c84c2449cd..b70fc0c61f8 100644 --- a/src/main/java/org/apache/ibatis/cache/decorators/BlockingCache.java +++ b/src/main/java/org/apache/ibatis/cache/decorators/BlockingCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,16 +23,16 @@ import org.apache.ibatis.cache.CacheException; /** - *

Simple blocking decorator - * - *

Simple and inefficient version of EhCache's BlockingCache decorator. - * It sets a lock over a cache key when the element is not found in cache. - * This way, other threads will wait until this element is filled instead of hitting the database. - * - *

By its nature, this implementation can cause deadlock when used incorrectly. + *

+ * Simple blocking decorator + *

+ * Simple and inefficient version of EhCache's BlockingCache decorator. It sets a lock over a cache key when the element + * is not found in cache. This way, other threads will wait until this element is filled instead of hitting the + * database. + *

+ * By its nature, this implementation can cause deadlock when used incorrectly. * * @author Eduardo Macarron - * */ public class BlockingCache implements Cache { diff --git a/src/main/java/org/apache/ibatis/cache/decorators/SoftCache.java b/src/main/java/org/apache/ibatis/cache/decorators/SoftCache.java index 8e6ba0ad351..daef435e890 100644 --- a/src/main/java/org/apache/ibatis/cache/decorators/SoftCache.java +++ b/src/main/java/org/apache/ibatis/cache/decorators/SoftCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -23,7 +23,8 @@ import org.apache.ibatis.cache.Cache; /** - * Soft Reference cache decorator + * Soft Reference cache decorator. + *

* Thanks to Dr. Heinz Kabutz for his guidance here. * * @author Clinton Begin diff --git a/src/main/java/org/apache/ibatis/cache/decorators/TransactionalCache.java b/src/main/java/org/apache/ibatis/cache/decorators/TransactionalCache.java index 1a71a50f110..914c72a5cd6 100644 --- a/src/main/java/org/apache/ibatis/cache/decorators/TransactionalCache.java +++ b/src/main/java/org/apache/ibatis/cache/decorators/TransactionalCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -27,10 +27,10 @@ /** * The 2nd level cache transactional buffer. *

- * This class holds all cache entries that are to be added to the 2nd level cache during a Session. - * Entries are sent to the cache when commit is called or discarded if the Session is rolled back. - * Blocking cache support has been added. Therefore any get() that returns a cache miss - * will be followed by a put() so any lock associated with the key can be released. + * This class holds all cache entries that are to be added to the 2nd level cache during a Session. Entries are sent to + * the cache when commit is called or discarded if the Session is rolled back. Blocking cache support has been added. + * Therefore any get() that returns a cache miss will be followed by a put() so any lock associated with the key can be + * released. * * @author Clinton Begin * @author Eduardo Macarron diff --git a/src/main/java/org/apache/ibatis/cache/decorators/WeakCache.java b/src/main/java/org/apache/ibatis/cache/decorators/WeakCache.java index 1b161a8d80b..8af6f1d0b5a 100644 --- a/src/main/java/org/apache/ibatis/cache/decorators/WeakCache.java +++ b/src/main/java/org/apache/ibatis/cache/decorators/WeakCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,6 +24,7 @@ /** * Weak Reference cache decorator. + *

* Thanks to Dr. Heinz Kabutz for his guidance here. * * @author Clinton Begin diff --git a/src/main/java/org/apache/ibatis/cursor/Cursor.java b/src/main/java/org/apache/ibatis/cursor/Cursor.java index 84bf296514a..4fa26a68c12 100644 --- a/src/main/java/org/apache/ibatis/cursor/Cursor.java +++ b/src/main/java/org/apache/ibatis/cursor/Cursor.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -18,10 +18,9 @@ import java.io.Closeable; /** - * Cursor contract to handle fetching items lazily using an Iterator. - * Cursors are a perfect fit to handle millions of items queries that would not normally fit in memory. - * If you use collections in resultMaps then cursor SQL queries must be ordered (resultOrdered="true") - * using the id columns of the resultMap. + * Cursor contract to handle fetching items lazily using an Iterator. Cursors are a perfect fit to handle millions of + * items queries that would not normally fit in memory. If you use collections in resultMaps then cursor SQL queries + * must be ordered (resultOrdered="true") using the id columns of the resultMap. * * @author Guillaume Darmont / guillaume@dropinocean.com */ @@ -33,7 +32,6 @@ public interface Cursor extends Closeable, Iterable { boolean isOpen(); /** - * * @return true if the cursor is fully consumed and has returned all elements matching the query. */ boolean isConsumed(); diff --git a/src/main/java/org/apache/ibatis/cursor/defaults/DefaultCursor.java b/src/main/java/org/apache/ibatis/cursor/defaults/DefaultCursor.java index c10cde7f9bf..42e216aeaa6 100644 --- a/src/main/java/org/apache/ibatis/cursor/defaults/DefaultCursor.java +++ b/src/main/java/org/apache/ibatis/cursor/defaults/DefaultCursor.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -29,8 +29,7 @@ import org.apache.ibatis.session.RowBounds; /** - * This is the default implementation of a MyBatis Cursor. - * This implementation is not thread safe. + * This is the default implementation of a MyBatis Cursor. This implementation is not thread safe. * * @author Guillaume Darmont / guillaume@dropinocean.com */ @@ -69,7 +68,8 @@ private enum CursorStatus { CONSUMED } - public DefaultCursor(DefaultResultSetHandler resultSetHandler, ResultMap resultMap, ResultSetWrapper rsw, RowBounds rowBounds) { + public DefaultCursor(DefaultResultSetHandler resultSetHandler, ResultMap resultMap, ResultSetWrapper rsw, + RowBounds rowBounds) { this.resultSetHandler = resultSetHandler; this.resultMap = resultMap; this.rsw = rsw; diff --git a/src/main/java/org/apache/ibatis/datasource/pooled/PooledConnection.java b/src/main/java/org/apache/ibatis/datasource/pooled/PooledConnection.java index 7834b0b32c8..8e99612d215 100644 --- a/src/main/java/org/apache/ibatis/datasource/pooled/PooledConnection.java +++ b/src/main/java/org/apache/ibatis/datasource/pooled/PooledConnection.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -215,6 +215,7 @@ public int hashCode() { * * @param obj * - the other connection to test for equality + * * @see Object#equals(Object) */ @Override @@ -237,6 +238,7 @@ public boolean equals(Object obj) { * - the method to be executed * @param args * - the parameters to be passed to the method + * * @see java.lang.reflect.InvocationHandler#invoke(Object, java.lang.reflect.Method, Object[]) */ @Override diff --git a/src/main/java/org/apache/ibatis/datasource/pooled/PooledDataSource.java b/src/main/java/org/apache/ibatis/datasource/pooled/PooledDataSource.java index 7cd9c2c826a..28e40619e87 100644 --- a/src/main/java/org/apache/ibatis/datasource/pooled/PooledDataSource.java +++ b/src/main/java/org/apache/ibatis/datasource/pooled/PooledDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -73,22 +73,26 @@ public PooledDataSource(UnpooledDataSource dataSource) { public PooledDataSource(String driver, String url, String username, String password) { dataSource = new UnpooledDataSource(driver, url, username, password); - expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), dataSource.getPassword()); + expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), + dataSource.getPassword()); } public PooledDataSource(String driver, String url, Properties driverProperties) { dataSource = new UnpooledDataSource(driver, url, driverProperties); - expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), dataSource.getPassword()); + expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), + dataSource.getPassword()); } public PooledDataSource(ClassLoader driverClassLoader, String driver, String url, String username, String password) { dataSource = new UnpooledDataSource(driverClassLoader, driver, url, username, password); - expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), dataSource.getPassword()); + expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), + dataSource.getPassword()); } public PooledDataSource(ClassLoader driverClassLoader, String driver, String url, Properties driverProperties) { dataSource = new UnpooledDataSource(driverClassLoader, driver, url, driverProperties); - expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), dataSource.getPassword()); + expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), + dataSource.getPassword()); } @Override @@ -157,10 +161,12 @@ public void setDriverProperties(Properties driverProps) { } /** - * Sets the default network timeout value to wait for the database operation to complete. See {@link Connection#setNetworkTimeout(java.util.concurrent.Executor, int)} + * Sets the default network timeout value to wait for the database operation to complete. See + * {@link Connection#setNetworkTimeout(java.util.concurrent.Executor, int)} * * @param milliseconds * The time in milliseconds to wait for the database operation to complete. + * * @since 3.5.2 */ public void setDefaultNetworkTimeout(Integer milliseconds) { @@ -191,22 +197,20 @@ public void setPoolMaximumIdleConnections(int poolMaximumIdleConnections) { } /** - * The maximum number of tolerance for bad connection happens in one thread - * which are applying for new {@link PooledConnection}. + * The maximum number of tolerance for bad connection happens in one thread which are applying for new + * {@link PooledConnection}. * * @param poolMaximumLocalBadConnectionTolerance * max tolerance for bad connection happens in one thread * * @since 3.4.5 */ - public void setPoolMaximumLocalBadConnectionTolerance( - int poolMaximumLocalBadConnectionTolerance) { + public void setPoolMaximumLocalBadConnectionTolerance(int poolMaximumLocalBadConnectionTolerance) { this.poolMaximumLocalBadConnectionTolerance = poolMaximumLocalBadConnectionTolerance; } /** - * The maximum time a connection can be used before it *may* be - * given away again. + * The maximum time a connection can be used before it *may* be given away again. * * @param poolMaximumCheckoutTime * The maximum time @@ -250,8 +254,8 @@ public void setPoolPingEnabled(boolean poolPingEnabled) { } /** - * If a connection has not been used in this many milliseconds, ping the - * database to make sure the connection is still good. + * If a connection has not been used in this many milliseconds, ping the database to make sure the connection is still + * good. * * @param milliseconds * the number of milliseconds of inactivity that will trigger a ping @@ -293,6 +297,7 @@ public Properties getDriverProperties() { * Gets the default network timeout. * * @return the default network timeout + * * @since 3.5.2 */ public Integer getDefaultNetworkTimeout() { @@ -337,7 +342,8 @@ public int getPoolPingConnectionsNotUsedFor() { public void forceCloseAll() { lock.lock(); try { - expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), dataSource.getPassword()); + expectedConnectionTypeCode = assembleConnectionTypeCode(dataSource.getUrl(), dataSource.getUsername(), + dataSource.getPassword()); for (int i = state.activeConnections.size(); i > 0; i--) { try { PooledConnection conn = state.activeConnections.remove(i - 1); @@ -388,7 +394,8 @@ protected void pushConnection(PooledConnection conn) throws SQLException { try { state.activeConnections.remove(conn); if (conn.isValid()) { - if (state.idleConnections.size() < poolMaximumIdleConnections && conn.getConnectionTypeCode() == expectedConnectionTypeCode) { + if (state.idleConnections.size() < poolMaximumIdleConnections + && conn.getConnectionTypeCode() == expectedConnectionTypeCode) { state.accumulatedCheckoutTime += conn.getCheckoutTime(); if (!conn.getRealConnection().getAutoCommit()) { conn.getRealConnection().rollback(); @@ -415,7 +422,8 @@ protected void pushConnection(PooledConnection conn) throws SQLException { } } else { if (log.isDebugEnabled()) { - log.debug("A bad connection (" + conn.getRealHashCode() + ") attempted to return to the pool, discarding connection."); + log.debug("A bad connection (" + conn.getRealHashCode() + + ") attempted to return to the pool, discarding connection."); } state.badConnectionCount++; } @@ -462,12 +470,10 @@ private PooledConnection popConnection(String username, String password) throws oldestActiveConnection.getRealConnection().rollback(); } catch (SQLException e) { /* - Just log a message for debug and continue to execute the following - statement like nothing happened. - Wrap the bad connection with a new PooledConnection, this will help - to not interrupt current executing thread and give current thread a - chance to join the next competition for another valid/good database - connection. At the end of this loop, bad {@link @conn} will be set as null. + * Just log a message for debug and continue to execute the following statement like nothing happened. + * Wrap the bad connection with a new PooledConnection, this will help to not interrupt current + * executing thread and give current thread a chance to join the next competition for another + * valid/good database connection. At the end of this loop, bad {@link @conn} will be set as null. */ log.debug("Bad connection. Could not roll back"); } @@ -537,7 +543,8 @@ private PooledConnection popConnection(String username, String password) throws if (log.isDebugEnabled()) { log.debug("PooledDataSource: Unknown severe error condition. The connection pool returned a null connection."); } - throw new SQLException("PooledDataSource: Unknown severe error condition. The connection pool returned a null connection."); + throw new SQLException( + "PooledDataSource: Unknown severe error condition. The connection pool returned a null connection."); } return conn; @@ -548,6 +555,7 @@ private PooledConnection popConnection(String username, String password) throws * * @param conn * - the connection to check + * * @return True if the connection is still usable */ protected boolean pingConnection(PooledConnection conn) { @@ -600,6 +608,7 @@ protected boolean pingConnection(PooledConnection conn) { * * @param conn * - the pooled connection to unwrap + * * @return The 'real' connection */ public static Connection unwrapConnection(Connection conn) { diff --git a/src/main/java/org/apache/ibatis/datasource/unpooled/UnpooledDataSource.java b/src/main/java/org/apache/ibatis/datasource/unpooled/UnpooledDataSource.java index 9cb0d82bc8c..61c0e125a76 100644 --- a/src/main/java/org/apache/ibatis/datasource/unpooled/UnpooledDataSource.java +++ b/src/main/java/org/apache/ibatis/datasource/unpooled/UnpooledDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -188,6 +188,7 @@ public void setDefaultTransactionIsolationLevel(Integer defaultTransactionIsolat * Gets the default network timeout. * * @return the default network timeout + * * @since 3.5.2 */ public Integer getDefaultNetworkTimeout() { @@ -199,6 +200,7 @@ public Integer getDefaultNetworkTimeout() { * * @param defaultNetworkTimeout * The time in milliseconds to wait for the database operation to complete. + * * @since 3.5.2 */ public void setDefaultNetworkTimeout(Integer defaultNetworkTimeout) { diff --git a/src/main/java/org/apache/ibatis/executor/BaseExecutor.java b/src/main/java/org/apache/ibatis/executor/BaseExecutor.java index 834690abfd9..1c2b14b06c5 100644 --- a/src/main/java/org/apache/ibatis/executor/BaseExecutor.java +++ b/src/main/java/org/apache/ibatis/executor/BaseExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -292,9 +292,12 @@ protected void closeStatement(Statement statement) { * * @param statement * a current statement + * * @throws SQLException * if a database access error occurs, this method is called on a closed Statement + * * @since 3.4.0 + * * @see StatementUtil#applyTransactionTimeout(Statement, Integer, Integer) */ protected void applyTransactionTimeout(Statement statement) throws SQLException { diff --git a/src/main/java/org/apache/ibatis/executor/BatchExecutor.java b/src/main/java/org/apache/ibatis/executor/BatchExecutor.java index f40e08e7b3f..c14bd9760f4 100644 --- a/src/main/java/org/apache/ibatis/executor/BatchExecutor.java +++ b/src/main/java/org/apache/ibatis/executor/BatchExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -68,7 +68,7 @@ public int doUpdate(MappedStatement ms, Object parameterObject) throws SQLExcept } else { Connection connection = getConnection(ms.getStatementLog()); stmt = handler.prepare(connection, transaction.getTimeout()); - handler.parameterize(stmt); // fix Issues 322 + handler.parameterize(stmt); // fix Issues 322 currentSql = sql; currentStatement = ms; statementList.add(stmt); diff --git a/src/main/java/org/apache/ibatis/executor/ResultExtractor.java b/src/main/java/org/apache/ibatis/executor/ResultExtractor.java index 290bcb6defd..3bd96312427 100644 --- a/src/main/java/org/apache/ibatis/executor/ResultExtractor.java +++ b/src/main/java/org/apache/ibatis/executor/ResultExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -51,7 +51,7 @@ public Object extractObjectFromList(List list, Class targetType) { } value = array; } else { - value = list.toArray((Object[])array); + value = list.toArray((Object[]) array); } } else { if (list != null && list.size() > 1) { diff --git a/src/main/java/org/apache/ibatis/executor/loader/cglib/CglibProxyFactory.java b/src/main/java/org/apache/ibatis/executor/loader/cglib/CglibProxyFactory.java index 0c35121c696..3ad3be57959 100644 --- a/src/main/java/org/apache/ibatis/executor/loader/cglib/CglibProxyFactory.java +++ b/src/main/java/org/apache/ibatis/executor/loader/cglib/CglibProxyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -41,6 +41,7 @@ /** * @author Clinton Begin + * * @deprecated Since 3.5.10, use Javassist instead. */ @Deprecated diff --git a/src/main/java/org/apache/ibatis/executor/loader/cglib/CglibSerialStateHolder.java b/src/main/java/org/apache/ibatis/executor/loader/cglib/CglibSerialStateHolder.java index 92f6fc5e743..b47db0e635c 100644 --- a/src/main/java/org/apache/ibatis/executor/loader/cglib/CglibSerialStateHolder.java +++ b/src/main/java/org/apache/ibatis/executor/loader/cglib/CglibSerialStateHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -24,6 +24,7 @@ /** * @author Eduardo Macarron + * * @deprecated Since 3.5.10, use Javassist instead. */ @Deprecated diff --git a/src/main/java/org/apache/ibatis/executor/resultset/ResultSetWrapper.java b/src/main/java/org/apache/ibatis/executor/resultset/ResultSetWrapper.java index e51a4b67fc5..48d81d5ed46 100644 --- a/src/main/java/org/apache/ibatis/executor/resultset/ResultSetWrapper.java +++ b/src/main/java/org/apache/ibatis/executor/resultset/ResultSetWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -89,14 +89,14 @@ public JdbcType getJdbcType(String columnName) { } /** - * Gets the type handler to use when reading the result set. - * Tries to get from the TypeHandlerRegistry by searching for the property type. - * If not found it gets the column JDBC type and tries to get a handler for it. + * Gets the type handler to use when reading the result set. Tries to get from the TypeHandlerRegistry by searching + * for the property type. If not found it gets the column JDBC type and tries to get a handler for it. * * @param propertyType * the property type * @param columnName * the column name + * * @return the type handler */ public TypeHandler getTypeHandler(Class propertyType, String columnName) { diff --git a/src/main/java/org/apache/ibatis/executor/statement/BaseStatementHandler.java b/src/main/java/org/apache/ibatis/executor/statement/BaseStatementHandler.java index 0094890a319..fea6667f28c 100644 --- a/src/main/java/org/apache/ibatis/executor/statement/BaseStatementHandler.java +++ b/src/main/java/org/apache/ibatis/executor/statement/BaseStatementHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -131,7 +131,7 @@ protected void closeStatement(Statement statement) { statement.close(); } } catch (SQLException e) { - //ignore + // ignore } } diff --git a/src/main/java/org/apache/ibatis/executor/statement/StatementHandler.java b/src/main/java/org/apache/ibatis/executor/statement/StatementHandler.java index 8d64438d631..7cb30750414 100644 --- a/src/main/java/org/apache/ibatis/executor/statement/StatementHandler.java +++ b/src/main/java/org/apache/ibatis/executor/statement/StatementHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -30,23 +30,17 @@ */ public interface StatementHandler { - Statement prepare(Connection connection, Integer transactionTimeout) - throws SQLException; + Statement prepare(Connection connection, Integer transactionTimeout) throws SQLException; - void parameterize(Statement statement) - throws SQLException; + void parameterize(Statement statement) throws SQLException; - void batch(Statement statement) - throws SQLException; + void batch(Statement statement) throws SQLException; - int update(Statement statement) - throws SQLException; + int update(Statement statement) throws SQLException; - List query(Statement statement, ResultHandler resultHandler) - throws SQLException; + List query(Statement statement, ResultHandler resultHandler) throws SQLException; - Cursor queryCursor(Statement statement) - throws SQLException; + Cursor queryCursor(Statement statement) throws SQLException; BoundSql getBoundSql(); diff --git a/src/main/java/org/apache/ibatis/executor/statement/StatementUtil.java b/src/main/java/org/apache/ibatis/executor/statement/StatementUtil.java index 2e0be9d75a1..7bfa1f2c7f5 100644 --- a/src/main/java/org/apache/ibatis/executor/statement/StatementUtil.java +++ b/src/main/java/org/apache/ibatis/executor/statement/StatementUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -22,6 +22,7 @@ * Utility for {@link java.sql.Statement}. * * @since 3.4.0 + * * @author Kazuki Shimizu */ public class StatementUtil { @@ -35,12 +36,19 @@ private StatementUtil() { *

* Update a query timeout to apply a transaction timeout. *

- * @param statement a target statement - * @param queryTimeout a query timeout - * @param transactionTimeout a transaction timeout - * @throws SQLException if a database access error occurs, this method is called on a closed Statement + * + * @param statement + * a target statement + * @param queryTimeout + * a query timeout + * @param transactionTimeout + * a transaction timeout + * + * @throws SQLException + * if a database access error occurs, this method is called on a closed Statement */ - public static void applyTransactionTimeout(Statement statement, Integer queryTimeout, Integer transactionTimeout) throws SQLException { + public static void applyTransactionTimeout(Statement statement, Integer queryTimeout, Integer transactionTimeout) + throws SQLException { if (transactionTimeout == null) { return; } diff --git a/src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java b/src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java index 7ff8d1655a3..53c5b7f691e 100644 --- a/src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java +++ b/src/main/java/org/apache/ibatis/io/ClassLoaderWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -39,7 +39,9 @@ public class ClassLoaderWrapper { /** * Get a resource as a URL using the current class path * - * @param resource - the resource to locate + * @param resource + * - the resource to locate + * * @return the resource or null */ public URL getResourceAsURL(String resource) { @@ -49,8 +51,11 @@ public URL getResourceAsURL(String resource) { /** * Get a resource from the classpath, starting with a specific class loader * - * @param resource - the resource to find - * @param classLoader - the first classloader to try + * @param resource + * - the resource to find + * @param classLoader + * - the first classloader to try + * * @return the stream or null */ public URL getResourceAsURL(String resource, ClassLoader classLoader) { @@ -60,7 +65,9 @@ public URL getResourceAsURL(String resource, ClassLoader classLoader) { /** * Get a resource from the classpath * - * @param resource - the resource to find + * @param resource + * - the resource to find + * * @return the stream or null */ public InputStream getResourceAsStream(String resource) { @@ -70,8 +77,11 @@ public InputStream getResourceAsStream(String resource) { /** * Get a resource from the classpath, starting with a specific class loader * - * @param resource - the resource to find - * @param classLoader - the first class loader to try + * @param resource + * - the resource to find + * @param classLoader + * - the first class loader to try + * * @return the stream or null */ public InputStream getResourceAsStream(String resource, ClassLoader classLoader) { @@ -81,9 +91,13 @@ public InputStream getResourceAsStream(String resource, ClassLoader classLoader) /** * Find a class on the classpath (or die trying) * - * @param name - the class to look for + * @param name + * - the class to look for + * * @return - the class - * @throws ClassNotFoundException Duh. + * + * @throws ClassNotFoundException + * Duh. */ public Class classForName(String name) throws ClassNotFoundException { return classForName(name, getClassLoaders(null)); @@ -92,10 +106,15 @@ public Class classForName(String name) throws ClassNotFoundException { /** * Find a class on the classpath, starting with a specific classloader (or die trying) * - * @param name - the class to look for - * @param classLoader - the first classloader to try + * @param name + * - the class to look for + * @param classLoader + * - the first classloader to try + * * @return - the class - * @throws ClassNotFoundException Duh. + * + * @throws ClassNotFoundException + * Duh. */ public Class classForName(String name, ClassLoader classLoader) throws ClassNotFoundException { return classForName(name, getClassLoaders(classLoader)); @@ -104,8 +123,11 @@ public Class classForName(String name, ClassLoader classLoader) throws ClassN /** * Try to get a resource from a group of classloaders * - * @param resource - the resource to get - * @param classLoader - the classloaders to examine + * @param resource + * - the resource to get + * @param classLoader + * - the classloaders to examine + * * @return the resource or null */ InputStream getResourceAsStream(String resource, ClassLoader[] classLoader) { @@ -131,8 +153,11 @@ InputStream getResourceAsStream(String resource, ClassLoader[] classLoader) { /** * Get a resource as a URL using the current class path * - * @param resource - the resource to locate - * @param classLoader - the class loaders to examine + * @param resource + * - the resource to locate + * @param classLoader + * - the class loaders to examine + * * @return the resource or null */ URL getResourceAsURL(String resource, ClassLoader[] classLoader) { @@ -170,10 +195,15 @@ URL getResourceAsURL(String resource, ClassLoader[] classLoader) { /** * Attempt to load a class from a group of classloaders * - * @param name - the class to load - * @param classLoader - the group of classloaders to examine + * @param name + * - the class to load + * @param classLoader + * - the group of classloaders to examine + * * @return the class - * @throws ClassNotFoundException - Remember the wisdom of Judge Smails: Well, the world needs ditch diggers, too. + * + * @throws ClassNotFoundException + * - Remember the wisdom of Judge Smails: Well, the world needs ditch diggers, too. */ Class classForName(String name, ClassLoader[] classLoader) throws ClassNotFoundException { diff --git a/src/main/java/org/apache/ibatis/io/DefaultVFS.java b/src/main/java/org/apache/ibatis/io/DefaultVFS.java index a8d4b03f70f..aacaef535ce 100644 --- a/src/main/java/org/apache/ibatis/io/DefaultVFS.java +++ b/src/main/java/org/apache/ibatis/io/DefaultVFS.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -79,7 +79,7 @@ public List list(URL url, String path) throws IOException { if (log.isDebugEnabled()) { log.debug("Listing " + url); } - for (JarEntry entry; (entry = jarInput.getNextJarEntry()) != null; ) { + for (JarEntry entry; (entry = jarInput.getNextJarEntry()) != null;) { if (log.isDebugEnabled()) { log.debug("Jar entry: " + entry.getName()); } @@ -88,12 +88,11 @@ public List list(URL url, String path) throws IOException { } } else { /* - * Some servlet containers allow reading from directory resources like a - * text file, listing the child resources one per line. However, there is no - * way to differentiate between directory and file resources just by reading - * them. To work around that, as each line is read, try to look it up via - * the class loader as a child of the current resource. If any line fails - * then we assume the current resource is not a directory. + * Some servlet containers allow reading from directory resources like a text file, listing the child + * resources one per line. However, there is no way to differentiate between directory and file resources + * just by reading them. To work around that, as each line is read, try to look it up via the class loader + * as a child of the current resource. If any line fails then we assume the current resource is not a + * directory. */ is = url.openStream(); List lines = new ArrayList<>(); @@ -121,9 +120,8 @@ public List list(URL url, String path) throws IOException { } } catch (FileNotFoundException e) { /* - * For file URLs the openStream() call might fail, depending on the servlet - * container, because directories can't be opened for reading. If that happens, - * then list the directory directly instead. + * For file URLs the openStream() call might fail, depending on the servlet container, because directories + * can't be opened for reading. If that happens, then list the directory directly instead. */ if ("file".equals(url.getProtocol())) { File file = new File(url.getFile()); @@ -170,13 +168,18 @@ public List list(URL url, String path) throws IOException { } /** - * List the names of the entries in the given {@link JarInputStream} that begin with the - * specified {@code path}. Entries will match with or without a leading slash. + * List the names of the entries in the given {@link JarInputStream} that begin with the specified {@code path}. + * Entries will match with or without a leading slash. + * + * @param jar + * The JAR input stream + * @param path + * The leading path to match * - * @param jar The JAR input stream - * @param path The leading path to match * @return The names of all the matching entries - * @throws IOException If I/O errors occur + * + * @throws IOException + * If I/O errors occur */ protected List listResources(JarInputStream jar, String path) throws IOException { // Include the leading and trailing slash when matching names @@ -211,13 +214,15 @@ protected List listResources(JarInputStream jar, String path) throws IOE } /** - * Attempts to deconstruct the given URL to find a JAR file containing the resource referenced - * by the URL. That is, assuming the URL references a JAR entry, this method will return a URL - * that references the JAR file containing the entry. If the JAR cannot be located, then this - * method returns null. + * Attempts to deconstruct the given URL to find a JAR file containing the resource referenced by the URL. That is, + * assuming the URL references a JAR entry, this method will return a URL that references the JAR file containing the + * entry. If the JAR cannot be located, then this method returns null. + * + * @param url + * The URL of the JAR entry. * - * @param url The URL of the JAR entry. * @return The URL of the JAR file, if one is found. Null if not. + * * @throws MalformedURLException * the malformed URL exception */ @@ -303,6 +308,7 @@ protected URL findJarForResource(URL url) throws MalformedURLException { * * @param packageName * The Java package name to convert to a path + * * @return the package path */ protected String getPackagePath(String packageName) { @@ -314,6 +320,7 @@ protected String getPackagePath(String packageName) { * * @param url * The URL of the resource to test. + * * @return true, if is jar */ protected boolean isJar(URL url) { @@ -328,6 +335,7 @@ protected boolean isJar(URL url) { * @param buffer * A buffer into which the first few bytes of the resource are read. The buffer must be at least the size of * {@link #JAR_MAGIC}. (The same buffer may be reused for multiple calls as an optimization.) + * * @return true, if is jar */ protected boolean isJar(URL url, byte[] buffer) { diff --git a/src/main/java/org/apache/ibatis/io/ExternalResources.java b/src/main/java/org/apache/ibatis/io/ExternalResources.java index a8ba98694dd..b713133d4c8 100644 --- a/src/main/java/org/apache/ibatis/io/ExternalResources.java +++ b/src/main/java/org/apache/ibatis/io/ExternalResources.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -44,13 +44,14 @@ public static void copyExternalResource(File sourceFile, File destFile) throws I } try (FileInputStream source = new FileInputStream(sourceFile); - FileOutputStream destination = new FileOutputStream(destFile)) { + FileOutputStream destination = new FileOutputStream(destFile)) { destination.getChannel().transferFrom(source.getChannel(), 0, source.getChannel().size()); } } - public static String getConfiguredTemplate(String templatePath, String templateProperty) throws FileNotFoundException { + public static String getConfiguredTemplate(String templatePath, String templateProperty) + throws FileNotFoundException { String templateName = ""; Properties migrationProperties = new Properties(); diff --git a/src/main/java/org/apache/ibatis/io/JBoss6VFS.java b/src/main/java/org/apache/ibatis/io/JBoss6VFS.java index 54279577b05..c2e6ca2f8cb 100644 --- a/src/main/java/org/apache/ibatis/io/JBoss6VFS.java +++ b/src/main/java/org/apache/ibatis/io/JBoss6VFS.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -108,13 +108,14 @@ protected static synchronized void initialize() { } /** - * Verifies that the provided object reference is null. If it is null, then this VFS is marked - * as invalid for the current environment. + * Verifies that the provided object reference is null. If it is null, then this VFS is marked as invalid for the + * current environment. * * @param * the generic type * @param object * The object reference to check for null. + * * @return the t */ protected static T checkNotNull(T object) { @@ -125,11 +126,14 @@ protected static T checkNotNull(T object) { } /** - * Verifies that the return type of method is what it is expected to be. If it is not, then - * this VFS is marked as invalid for the current environment. + * Verifies that the return type of method is what it is expected to be. If it is not, then this VFS is marked as + * invalid for the current environment. + * + * @param method + * The method whose return type is to be checked. + * @param expected + * A type to which the method's return type must be assignable. * - * @param method The method whose return type is to be checked. - * @param expected A type to which the method's return type must be assignable. * @see Class#isAssignableFrom(Class) */ protected static void checkReturnType(Method method, Class expected) { diff --git a/src/main/java/org/apache/ibatis/io/ResolverUtil.java b/src/main/java/org/apache/ibatis/io/ResolverUtil.java index 2f27158c7ad..c20db21a2ab 100644 --- a/src/main/java/org/apache/ibatis/io/ResolverUtil.java +++ b/src/main/java/org/apache/ibatis/io/ResolverUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -25,25 +25,22 @@ import org.apache.ibatis.logging.LogFactory; /** - *

ResolverUtil is used to locate classes that are available in the/a class path and meet - * arbitrary conditions. The two most common conditions are that a class implements/extends - * another class, or that is it annotated with a specific annotation. However, through the use - * of the {@link Test} class it is possible to search using arbitrary conditions.

- * - *

A ClassLoader is used to locate all locations (directories and jar files) in the class - * path that contain classes within certain packages, and then to load those classes and - * check them. By default the ClassLoader returned by - * {@code Thread.currentThread().getContextClassLoader()} is used, but this can be overridden - * by calling {@link #setClassLoader(ClassLoader)} prior to invoking any of the {@code find()} - * methods.

- * - *

General searches are initiated by calling the {@link #find(Test, String)} and supplying - * a package name and a Test instance. This will cause the named package and all sub-packages - * to be scanned for classes that meet the test. There are also utility methods for the common - * use cases of scanning multiple packages for extensions of particular classes, or classes - * annotated with a specific annotation.

- * - *

The standard usage pattern for the ResolverUtil class is as follows:

+ *

+ * ResolverUtil is used to locate classes that are available in the/a class path and meet arbitrary conditions. The two + * most common conditions are that a class implements/extends another class, or that is it annotated with a specific + * annotation. However, through the use of the {@link Test} class it is possible to search using arbitrary conditions. + *

+ * A ClassLoader is used to locate all locations (directories and jar files) in the class path that contain classes + * within certain packages, and then to load those classes and check them. By default the ClassLoader returned by + * {@code Thread.currentThread().getContextClassLoader()} is used, but this can be overridden by calling + * {@link #setClassLoader(ClassLoader)} prior to invoking any of the {@code find()} methods. + *

+ * General searches are initiated by calling the {@link #find(Test, String)} and supplying a package name and a Test + * instance. This will cause the named package and all sub-packages to be scanned for classes that meet the test. + * There are also utility methods for the common use cases of scanning multiple packages for extensions of particular + * classes, or classes annotated with a specific annotation. + *

+ * The standard usage pattern for the ResolverUtil class is as follows: * *

  * ResolverUtil<ActionBean> resolver = new ResolverUtil<ActionBean>();
@@ -54,6 +51,7 @@
  * 
* * @author Tim Fennell + * * @param * the generic type */ @@ -65,25 +63,26 @@ public class ResolverUtil { private static final Log log = LogFactory.getLog(ResolverUtil.class); /** - * A simple interface that specifies how to test classes to determine if they - * are to be included in the results produced by the ResolverUtil. + * A simple interface that specifies how to test classes to determine if they are to be included in the results + * produced by the ResolverUtil. */ public interface Test { /** - * Will be called repeatedly with candidate classes. Must return True if a class - * is to be included in the results, false otherwise. + * Will be called repeatedly with candidate classes. Must return True if a class is to be included in the results, + * false otherwise. * * @param type * the type + * * @return true, if successful */ boolean matches(Class type); } /** - * A Test that checks to see if each class is assignable to the provided class. Note - * that this test will match the parent type itself if it is presented for matching. + * A Test that checks to see if each class is assignable to the provided class. Note that this test will match the + * parent type itself if it is presented for matching. */ public static class IsA implements Test { @@ -113,8 +112,8 @@ public String toString() { } /** - * A Test that checks to see if each class is annotated with a specific annotation. If it - * is, then the test returns true, otherwise false. + * A Test that checks to see if each class is annotated with a specific annotation. If it is, then the test returns + * true, otherwise false. */ public static class AnnotatedWith implements Test { @@ -147,14 +146,14 @@ public String toString() { private Set> matches = new HashSet<>(); /** - * The ClassLoader to use when looking for classes. If null then the ClassLoader returned - * by Thread.currentThread().getContextClassLoader() will be used. + * The ClassLoader to use when looking for classes. If null then the ClassLoader returned by + * Thread.currentThread().getContextClassLoader() will be used. */ private ClassLoader classloader; /** - * Provides access to the classes discovered so far. If no calls have been made to - * any of the {@code find()} methods, this set will be empty. + * Provides access to the classes discovered so far. If no calls have been made to any of the {@code find()} methods, + * this set will be empty. * * @return the set of classes that have been discovered. */ @@ -163,8 +162,8 @@ public Set> getClasses() { } /** - * Returns the classloader that will be used for scanning for classes. If no explicit - * ClassLoader has been set by the calling, the context class loader will be used. + * Returns the classloader that will be used for scanning for classes. If no explicit ClassLoader has been set by the + * calling, the context class loader will be used. * * @return the ClassLoader that will be used to scan for classes */ @@ -173,25 +172,26 @@ public ClassLoader getClassLoader() { } /** - * Sets an explicit ClassLoader that should be used when scanning for classes. If none - * is set then the context classloader will be used. + * Sets an explicit ClassLoader that should be used when scanning for classes. If none is set then the context + * classloader will be used. * - * @param classloader a ClassLoader to use when scanning for classes + * @param classloader + * a ClassLoader to use when scanning for classes */ public void setClassLoader(ClassLoader classloader) { this.classloader = classloader; } /** - * Attempts to discover classes that are assignable to the type provided. In the case - * that an interface is provided this method will collect implementations. In the case - * of a non-interface class, subclasses will be collected. Accumulated classes can be - * accessed by calling {@link #getClasses()}. + * Attempts to discover classes that are assignable to the type provided. In the case that an interface is provided + * this method will collect implementations. In the case of a non-interface class, subclasses will be collected. + * Accumulated classes can be accessed by calling {@link #getClasses()}. * * @param parent * the class of interface to find subclasses or implementations of * @param packageNames * one or more package names to scan (including subpackages) for classes + * * @return the resolver util */ public ResolverUtil findImplementations(Class parent, String... packageNames) { @@ -208,13 +208,14 @@ public ResolverUtil findImplementations(Class parent, String... packageNam } /** - * Attempts to discover classes that are annotated with the annotation. Accumulated - * classes can be accessed by calling {@link #getClasses()}. + * Attempts to discover classes that are annotated with the annotation. Accumulated classes can be accessed by calling + * {@link #getClasses()}. * * @param annotation * the annotation that should be present on matching classes * @param packageNames * one or more package names to scan (including subpackages) for classes + * * @return the resolver util */ public ResolverUtil findAnnotated(Class annotation, String... packageNames) { @@ -231,15 +232,15 @@ public ResolverUtil findAnnotated(Class annotation, Str } /** - * Scans for classes starting at the package provided and descending into subpackages. - * Each class is offered up to the Test as it is discovered, and if the Test returns - * true the class is retained. Accumulated classes can be fetched by calling - * {@link #getClasses()}. + * Scans for classes starting at the package provided and descending into subpackages. Each class is offered up to the + * Test as it is discovered, and if the Test returns true the class is retained. Accumulated classes can be fetched by + * calling {@link #getClasses()}. * * @param test * an instance of {@link Test} that will be used to filter classes * @param packageName * the name of the package from which to start scanning for classes, e.g. {@code net.sourceforge.stripes} + * * @return the resolver util */ public ResolverUtil find(Test test, String packageName) { @@ -265,6 +266,7 @@ public ResolverUtil find(Test test, String packageName) { * * @param packageName * The Java package name to convert to a path + * * @return the package path */ protected String getPackagePath(String packageName) { diff --git a/src/test/java/org/apache/ibatis/session/AutoMappingUnknownColumnBehaviorTest.java b/src/test/java/org/apache/ibatis/session/AutoMappingUnknownColumnBehaviorTest.java index 486d1645364..a9cbb27f338 100644 --- a/src/test/java/org/apache/ibatis/session/AutoMappingUnknownColumnBehaviorTest.java +++ b/src/test/java/org/apache/ibatis/session/AutoMappingUnknownColumnBehaviorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2022 the original author or authors. + * Copyright 2009-2023 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. @@ -17,12 +17,13 @@ import static org.assertj.core.api.Assertions.assertThat; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.UnsynchronizedAppenderBase; + import java.util.concurrent.atomic.AtomicInteger; import javax.sql.DataSource; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.UnsynchronizedAppenderBase; import org.apache.ibatis.BaseDataTest; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.domain.blog.Author; diff --git a/src/test/java/org/apache/ibatis/submitted/no_result_type_map/Mapper.java b/src/test/java/org/apache/ibatis/submitted/no_result_type_map/Mapper.java index 18b3926ed04..b2b965d25ee 100644 --- a/src/test/java/org/apache/ibatis/submitted/no_result_type_map/Mapper.java +++ b/src/test/java/org/apache/ibatis/submitted/no_result_type_map/Mapper.java @@ -15,10 +15,10 @@ */ package org.apache.ibatis.submitted.no_result_type_map; -import org.apache.ibatis.annotations.Param; - import java.util.List; +import org.apache.ibatis.annotations.Param; + public interface Mapper extends ParentMapper{ User getUser(@Param("id") Integer id);