Skip to content

Commit 85b6247

Browse files
authored
Improve Javadoc for org.seasar.doma.jdbc package (#1332)
2 parents 229c502 + 5897136 commit 85b6247

File tree

9 files changed

+655
-50
lines changed

9 files changed

+655
-50
lines changed

doma-core/src/main/java/org/seasar/doma/jdbc/CommandImplementors.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,22 @@
5252
import org.seasar.doma.jdbc.query.SqlProcessorQuery;
5353
import org.seasar.doma.jdbc.query.UpdateQuery;
5454

55-
/** A factory for the {@link Command} implementation classes. */
55+
/**
56+
* A factory interface for creating {@link Command} implementation objects.
57+
*
58+
* <p>This interface provides factory methods for instantiating various types of database commands
59+
* used in the Doma framework. Each method creates a specific type of command object that is
60+
* responsible for executing a corresponding {@link org.seasar.doma.jdbc.query.Query} object.
61+
*
62+
* <p>Implementations of this interface are responsible for creating the appropriate command objects
63+
* based on the DAO method being executed. These command objects handle the execution of database
64+
* operations (select, insert, update, delete, batch operations, etc.) and process the results.
65+
*
66+
* <p>The default implementations of these methods create standard command objects, but custom
67+
* implementations can override these methods to provide specialized behavior or extended
68+
* functionality for specific command types, such as custom transaction handling, logging, or
69+
* performance monitoring.
70+
*/
5671
public interface CommandImplementors {
5772

5873
/**

doma-core/src/main/java/org/seasar/doma/jdbc/Config.java

Lines changed: 298 additions & 37 deletions
Large diffs are not rendered by default.

doma-core/src/main/java/org/seasar/doma/jdbc/ConfigProvider.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,27 @@
1515
*/
1616
package org.seasar.doma.jdbc;
1717

18-
/** A provider for a {@link Config} object. */
18+
/**
19+
* A provider for a {@link Config} object.
20+
*
21+
* <p>This interface defines a contract for objects that can provide access to a {@link Config}
22+
* instance, which contains all the configuration settings needed for database operations in Doma.
23+
*
24+
* <p>The {@link Config#get(Object)} method can be used to extract a {@link Config} instance from
25+
* any object that implements this interface.
26+
*
27+
* <p>Typically, applications don't need to implement this interface directly, as Doma automatically
28+
* generates implementations for DAO interfaces annotated with {@code @Dao}.
29+
*
30+
* @see Config
31+
* @see Config#get(Object)
32+
*/
1933
public interface ConfigProvider {
2034

2135
/**
2236
* Returns the configuration.
2337
*
24-
* @return the configuration
38+
* @return the configuration instance containing database operation settings
2539
*/
2640
Config getConfig();
2741
}

doma-core/src/main/java/org/seasar/doma/jdbc/ConfigSupport.java

Lines changed: 151 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,191 @@
1818
import org.seasar.doma.jdbc.statistic.DefaultStatisticManager;
1919
import org.seasar.doma.jdbc.statistic.StatisticManager;
2020

21-
/** Default values for {@link Config} objects. */
21+
/**
22+
* Provides default implementations for the {@link Config} interface.
23+
*
24+
* <p>This class serves as a central repository of default implementations for various components
25+
* used by the Doma framework. These default implementations are used when a custom {@link Config}
26+
* implementation does not override the corresponding methods.
27+
*
28+
* <p>Each field in this class represents a default implementation of a specific interface or
29+
* component that can be used by {@link Config} implementations. The default implementations provide
30+
* reasonable behavior for most applications, but can be replaced with custom implementations when
31+
* needed.
32+
*
33+
* <p>For example, the {@link Config#getSqlFileRepository()} method returns {@link
34+
* #defaultSqlFileRepository} by default, but a custom {@link Config} implementation can override
35+
* this method to provide a different {@link SqlFileRepository} implementation.
36+
*
37+
* <p>This design allows applications to customize only the components they need while using the
38+
* default implementations for everything else, promoting a flexible and modular architecture.
39+
*
40+
* <p>All fields in this class are public, static, and final, making them effectively constants that
41+
* can be referenced directly if needed, though they are typically accessed through the default
42+
* methods of the {@link Config} interface.
43+
*/
2244
public final class ConfigSupport {
2345

46+
/**
47+
* Default implementation of {@link SqlFileRepository} that caches SQL files aggressively.
48+
*
49+
* <p>This implementation uses a {@link GreedyCacheSqlFileRepository} which loads and caches SQL
50+
* files when they are first accessed. The cached SQL files are kept in memory for the lifetime of
51+
* the application, which improves performance but increases memory usage.
52+
*
53+
* <p>Used by {@link Config#getSqlFileRepository()} as the default return value.
54+
*/
2455
public static final SqlFileRepository defaultSqlFileRepository =
2556
new GreedyCacheSqlFileRepository();
2657

58+
/**
59+
* Default implementation of {@link ScriptFileLoader} that provides basic script loading
60+
* capabilities.
61+
*
62+
* <p>This implementation uses an anonymous inner class of {@link ScriptFileLoader} with default
63+
* behavior for loading SQL script files.
64+
*
65+
* <p>Used by {@link Config#getScriptFileLoader()} as the default return value.
66+
*/
2767
public static final ScriptFileLoader defaultScriptFileLoader = new ScriptFileLoader() {};
2868

69+
/**
70+
* Default implementation of {@link JdbcLogger} that logs using java.util.logging.
71+
*
72+
* <p>This implementation uses {@link UtilLoggingJdbcLogger} which delegates to the standard Java
73+
* logging framework (java.util.logging) for logging SQL statements, parameters, and execution
74+
* times.
75+
*
76+
* <p>Used by {@link Config#getJdbcLogger()} as the default return value.
77+
*/
2978
public static final JdbcLogger defaultJdbcLogger = new UtilLoggingJdbcLogger();
3079

80+
/**
81+
* Default implementation of {@link RequiresNewController} for transaction control.
82+
*
83+
* <p>This implementation uses an anonymous inner class of {@link RequiresNewController} with
84+
* default behavior for managing transactions with the REQUIRES_NEW attribute.
85+
*
86+
* <p>Used by {@link Config#getRequiresNewController()} as the default return value.
87+
*/
3188
public static final RequiresNewController defaultRequiresNewController =
3289
new RequiresNewController() {};
3390

91+
/**
92+
* Default implementation of {@link ClassHelper} for class loading and instantiation.
93+
*
94+
* <p>This implementation uses an anonymous inner class of {@link ClassHelper} with default
95+
* behavior for loading classes and creating instances.
96+
*
97+
* <p>Used by {@link Config#getClassHelper()} as the default return value.
98+
*/
3499
public static final ClassHelper defaultClassHelper = new ClassHelper() {};
35100

101+
/**
102+
* Default implementation of {@link CommandImplementors} for creating command objects.
103+
*
104+
* <p>This implementation uses an anonymous inner class of {@link CommandImplementors} with
105+
* default behavior for creating implementations of the {@link
106+
* org.seasar.doma.jdbc.command.Command} interface.
107+
*
108+
* <p>Used by {@link Config#getCommandImplementors()} as the default return value.
109+
*/
36110
public static final CommandImplementors defaultCommandImplementors = new CommandImplementors() {};
37111

112+
/**
113+
* Default implementation of {@link QueryImplementors} for creating query objects.
114+
*
115+
* <p>This implementation uses an anonymous inner class of {@link QueryImplementors} with default
116+
* behavior for creating implementations of the {@link org.seasar.doma.jdbc.query.Query}
117+
* interface.
118+
*
119+
* <p>Used by {@link Config#getQueryImplementors()} as the default return value.
120+
*/
38121
public static final QueryImplementors defaultQueryImplementors = new QueryImplementors() {};
39122

123+
/**
124+
* Default implementation of {@link UnknownColumnHandler} that throws an exception.
125+
*
126+
* <p>This implementation uses an anonymous inner class of {@link UnknownColumnHandler} which
127+
* throws an {@link UnknownColumnException} when it encounters a column in a result set that
128+
* doesn't match any property in the corresponding entity class.
129+
*
130+
* <p>Used by {@link Config#getUnknownColumnHandler()} as the default return value.
131+
*/
40132
public static final UnknownColumnHandler defaultUnknownColumnHandler =
41133
new UnknownColumnHandler() {};
42134

135+
/**
136+
* Default implementation of {@link DuplicateColumnHandler} that uses the last occurrence.
137+
*
138+
* <p>This implementation uses an anonymous inner class of {@link DuplicateColumnHandler} which
139+
* silently accepts duplicate columns in a result set and uses the last occurrence of each
140+
* duplicate column when mapping to entity properties.
141+
*
142+
* <p>Used by {@link Config#getDuplicateColumnHandler()} as the default return value.
143+
*/
43144
public static final DuplicateColumnHandler defaultDuplicateColumnHandler =
44145
new DuplicateColumnHandler() {};
45146

147+
/**
148+
* Default implementation of {@link Naming} for name conversion between Java and databases.
149+
*
150+
* <p>This implementation uses {@link Naming#DEFAULT} which provides the default naming convention
151+
* for converting between Java property names and database column names.
152+
*
153+
* <p>Used by {@link Config#getNaming()} as the default return value.
154+
*/
46155
public static final Naming defaultNaming = Naming.DEFAULT;
47156

157+
/**
158+
* Default implementation of {@link MapKeyNaming} for map key naming conventions.
159+
*
160+
* <p>This implementation uses an anonymous inner class of {@link MapKeyNaming} with default
161+
* behavior for converting between database column names and keys in Map objects.
162+
*
163+
* <p>Used by {@link Config#getMapKeyNaming()} as the default return value.
164+
*/
48165
public static final MapKeyNaming defaultMapKeyNaming = new MapKeyNaming() {};
49166

167+
/**
168+
* Default implementation of {@link Commenter} for adding comments to SQL statements.
169+
*
170+
* <p>This implementation uses an anonymous inner class of {@link Commenter} which adds no
171+
* comments to SQL statements by default.
172+
*
173+
* <p>Used by {@link Config#getCommenter()} as the default return value.
174+
*/
50175
public static final Commenter defaultCommenter = new Commenter() {};
51176

177+
/**
178+
* Default implementation of {@link EntityListenerProvider} for entity listeners.
179+
*
180+
* <p>This implementation uses an anonymous inner class of {@link EntityListenerProvider} which
181+
* creates one instance of each listener class per entity class. This means that the same listener
182+
* instance is reused for all operations on entities of the same class.
183+
*
184+
* <p>Used by {@link Config#getEntityListenerProvider()} as the default return value.
185+
*/
52186
public static final EntityListenerProvider defaultEntityListenerProvider =
53187
new EntityListenerProvider() {};
54188

189+
/**
190+
* Default implementation of {@link SqlBuilderSettings} for SQL generation.
191+
*
192+
* <p>This implementation uses a new instance of {@link SqlBuilderSettings} with default settings
193+
* for SQL generation.
194+
*
195+
* <p>Used by {@link Config#getSqlBuilderSettings()} as the default return value.
196+
*/
55197
public static final SqlBuilderSettings defaultSqlBuilderSettings = new SqlBuilderSettings() {};
56198

199+
/**
200+
* Default implementation of {@link StatisticManager} for collecting SQL execution statistics.
201+
*
202+
* <p>This implementation uses {@link DefaultStatisticManager} which provides basic functionality
203+
* for collecting and managing statistics about SQL execution.
204+
*
205+
* <p>Used by {@link Config#getStatisticManager()} as the default return value.
206+
*/
57207
public static final StatisticManager defaultStatisticManager = new DefaultStatisticManager() {};
58208
}

doma-core/src/main/java/org/seasar/doma/jdbc/DuplicateColumnHandler.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,26 @@
1717

1818
import org.seasar.doma.jdbc.query.Query;
1919

20-
/** A handler for the column that is duplicated in a result set. */
20+
/**
21+
* A handler for columns that are duplicated in a result set.
22+
*
23+
* <p>This interface defines how to handle situations where the same column name appears multiple
24+
* times in a result set. Implementations can choose to ignore duplicates, throw exceptions, or
25+
* handle them in custom ways.
26+
*
27+
* <p>The default implementation does nothing, effectively ignoring duplicate columns.
28+
*
29+
* @see ThrowingDuplicateColumnHandler
30+
* @see DuplicateColumnException
31+
*/
2132
public interface DuplicateColumnHandler {
2233

2334
/**
24-
* Handles the duplicate column.
35+
* Handles a duplicate column found in a result set.
2536
*
26-
* @param query the query
27-
* @param duplicateColumnName the name of the unknown column
37+
* @param query the query being executed
38+
* @param duplicateColumnName the name of the duplicate column
39+
* @throws DuplicateColumnException if the implementation chooses to reject duplicate columns
2840
*/
2941
default void handle(Query query, String duplicateColumnName) {}
3042
}

doma-core/src/main/java/org/seasar/doma/jdbc/JdbcException.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,40 @@
1818
import org.seasar.doma.DomaException;
1919
import org.seasar.doma.message.MessageResource;
2020

21-
/** Thrown to indicate a JDBC related error. */
21+
/**
22+
* Thrown to indicate a JDBC related error during database operations.
23+
*
24+
* <p>This is the base exception class for all JDBC-related exceptions in Doma. It provides common
25+
* functionality for handling SQL-related errors and formatting SQL statements for error messages.
26+
*
27+
* <p>Specific subclasses provide more detailed information about particular types of JDBC errors,
28+
* such as SQL syntax errors, constraint violations, or mapping problems.
29+
*
30+
* @see SqlExecutionException
31+
* @see UniqueConstraintException
32+
* @see OptimisticLockException
33+
*/
2234
public class JdbcException extends DomaException {
2335

2436
private static final long serialVersionUID = 1L;
2537

38+
/**
39+
* Constructs a new JdbcException with the specified message code and arguments.
40+
*
41+
* @param messageCode the message code that identifies the error message
42+
* @param args the arguments to format the error message
43+
*/
2644
public JdbcException(MessageResource messageCode, Object... args) {
2745
super(messageCode, args);
2846
}
2947

48+
/**
49+
* Constructs a new JdbcException with the specified message code, cause, and arguments.
50+
*
51+
* @param messageCode the message code that identifies the error message
52+
* @param cause the cause of this exception
53+
* @param args the arguments to format the error message
54+
*/
3055
public JdbcException(MessageResource messageCode, Throwable cause, Object... args) {
3156
super(messageCode, cause, args);
3257
}

0 commit comments

Comments
 (0)