Skip to content

Commit 446428e

Browse files
cache DatabaseMetaData fixed value and Connection getSchema value. for master (#362)
* #360 for master * fix review comment.
1 parent 19761e7 commit 446428e

16 files changed

+1833
-20
lines changed

src/main/java/jp/co/future/uroborosql/SqlAgent.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ interface UpdatesCondition<E> {
170170
*/
171171
SqlAgent setInsertsType(InsertsType insertsType);
172172

173+
/**
174+
* スキーマ名をキャッシュするかどうかを設定する.
175+
*
176+
* @param cache スキーマ名をキャッシュするかどうか. キャッシュする場合<code>true</code>
177+
* @return SqlAgent
178+
* @exception SQLException スキーマ名のキャッシュ指定に失敗した場合の例外.
179+
*/
180+
SqlAgent setCacheSchema(boolean cache) throws SQLException;
181+
173182
/**
174183
* クエリ実行処理。
175184
*

src/main/java/jp/co/future/uroborosql/SqlAgentImpl.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import jp.co.future.uroborosql.config.SqlConfig;
4040
import jp.co.future.uroborosql.connection.ConnectionContext;
41+
import jp.co.future.uroborosql.connection.MetadataCachedConnectionWrapper;
4142
import jp.co.future.uroborosql.context.ExecutionContext;
4243
import jp.co.future.uroborosql.context.ExecutionContextImpl;
4344
import jp.co.future.uroborosql.converter.MapResultSetConverter;
@@ -2794,6 +2795,23 @@ public SqlAgent setInsertsType(final InsertsType defaultInsertsType) {
27942795
return this;
27952796
}
27962797

2798+
/**
2799+
*
2800+
* {@inheritDoc}
2801+
*
2802+
* @see jp.co.future.uroborosql.SqlAgent#setCacheSchema(boolean)
2803+
*/
2804+
@Override
2805+
public SqlAgent setCacheSchema(final boolean cache) throws SQLException {
2806+
var conn = getConnection();
2807+
if (conn.isWrapperFor(MetadataCachedConnectionWrapper.class)) {
2808+
((MetadataCachedConnectionWrapper) conn).setCacheSchema(cache);
2809+
} else {
2810+
throw new SQLException("Cannot set cacheSchema option.");
2811+
}
2812+
return this;
2813+
}
2814+
27972815
/**
27982816
* SQLリソース管理クラスを取得します。
27992817
*

0 commit comments

Comments
 (0)