|
21 | 21 | import org.seasar.doma.jdbc.CommentContext;
|
22 | 22 | import org.seasar.doma.jdbc.Config;
|
23 | 23 |
|
| 24 | +/** |
| 25 | + * The base abstract class for all query implementations. |
| 26 | + * |
| 27 | + * <p>This class provides common functionality for all query types. |
| 28 | + */ |
24 | 29 | public abstract class AbstractQuery implements Query {
|
25 | 30 |
|
| 31 | + /** The class name of the caller. */ |
26 | 32 | protected String callerClassName;
|
27 | 33 |
|
| 34 | + /** The method name of the caller. */ |
28 | 35 | protected String callerMethodName;
|
29 | 36 |
|
| 37 | + /** The configuration. */ |
30 | 38 | protected Config config;
|
31 | 39 |
|
| 40 | + /** The method that defines the query. */ |
32 | 41 | protected Method method;
|
33 | 42 |
|
| 43 | + /** The query timeout in seconds. */ |
34 | 44 | protected int queryTimeout;
|
35 | 45 |
|
| 46 | + /** The message to be included in SQL comments. */ |
36 | 47 | protected String message;
|
37 | 48 |
|
| 49 | + /** The context for SQL comments. */ |
38 | 50 | private CommentContext commentContext;
|
39 | 51 |
|
| 52 | + /** Creates a new instance. */ |
40 | 53 | protected AbstractQuery() {}
|
41 | 54 |
|
| 55 | + /** {@inheritDoc} */ |
42 | 56 | @Override
|
43 | 57 | public String getClassName() {
|
44 | 58 | return callerClassName;
|
45 | 59 | }
|
46 | 60 |
|
| 61 | + /** |
| 62 | + * Sets the class name of the caller. |
| 63 | + * |
| 64 | + * @param callerClassName the class name |
| 65 | + */ |
47 | 66 | public void setCallerClassName(String callerClassName) {
|
48 | 67 | this.callerClassName = callerClassName;
|
49 | 68 | }
|
50 | 69 |
|
| 70 | + /** {@inheritDoc} */ |
51 | 71 | @Override
|
52 | 72 | public String getMethodName() {
|
53 | 73 | return callerMethodName;
|
54 | 74 | }
|
55 | 75 |
|
| 76 | + /** |
| 77 | + * Sets the method name of the caller. |
| 78 | + * |
| 79 | + * @param callerMethodName the method name |
| 80 | + */ |
56 | 81 | public void setCallerMethodName(String callerMethodName) {
|
57 | 82 | this.callerMethodName = callerMethodName;
|
58 | 83 | }
|
59 | 84 |
|
| 85 | + /** {@inheritDoc} */ |
60 | 86 | @Override
|
61 | 87 | public Config getConfig() {
|
62 | 88 | return config;
|
63 | 89 | }
|
64 | 90 |
|
| 91 | + /** |
| 92 | + * Sets the configuration. |
| 93 | + * |
| 94 | + * @param config the configuration |
| 95 | + */ |
65 | 96 | public void setConfig(Config config) {
|
66 | 97 | this.config = config;
|
67 | 98 | }
|
68 | 99 |
|
| 100 | + /** {@inheritDoc} */ |
69 | 101 | @Override
|
70 | 102 | public Method getMethod() {
|
71 | 103 | return method;
|
72 | 104 | }
|
73 | 105 |
|
| 106 | + /** |
| 107 | + * Sets the method that defines the query. |
| 108 | + * |
| 109 | + * @param method the method |
| 110 | + */ |
74 | 111 | public void setMethod(Method method) {
|
75 | 112 | this.method = method;
|
76 | 113 | }
|
77 | 114 |
|
| 115 | + /** {@inheritDoc} */ |
78 | 116 | @Override
|
79 | 117 | public int getQueryTimeout() {
|
80 | 118 | return queryTimeout;
|
81 | 119 | }
|
82 | 120 |
|
| 121 | + /** |
| 122 | + * Sets the query timeout in seconds. |
| 123 | + * |
| 124 | + * @param queryTimeout the query timeout |
| 125 | + */ |
83 | 126 | public void setQueryTimeout(int queryTimeout) {
|
84 | 127 | this.queryTimeout = queryTimeout;
|
85 | 128 | }
|
86 | 129 |
|
| 130 | + /** |
| 131 | + * Sets the message to be included in SQL comments. |
| 132 | + * |
| 133 | + * @param message the message |
| 134 | + */ |
87 | 135 | public void setMessage(String message) {
|
88 | 136 | this.message = message;
|
89 | 137 | }
|
90 | 138 |
|
| 139 | + /** {@inheritDoc} */ |
91 | 140 | @Override
|
92 | 141 | public void prepare() {
|
93 | 142 | assertNotNull(callerClassName, callerMethodName, config);
|
94 | 143 | commentContext = new CommentContext(callerClassName, callerMethodName, config, method, message);
|
95 | 144 | }
|
96 | 145 |
|
| 146 | + /** {@inheritDoc} */ |
97 | 147 | @Override
|
98 | 148 | public String comment(String sql) {
|
99 | 149 | assertNotNull(sql, config, commentContext);
|
|
0 commit comments