Skip to content

Commit

Permalink
Add Cache Clear API for DefaultEntityHandler and MappingUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
HidekiSugimoto189 committed Sep 14, 2022
1 parent 3012885 commit b828746
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Expand Up @@ -870,4 +870,11 @@ public SqlConfig getSqlConfig() {
return this.sqlConfig;
}

/**
* TableMetadataのLRUキャッシュをクリアします.
*/
public static void clearCache() {
CACHE.clear();
}

}
Expand Up @@ -455,6 +455,13 @@ public static Optional<MappingColumn> getVersionMappingColumn(String schema, fin
.findFirst();
}

/**
* MappingColumnのキャッシュをクリアします.
*/
public static void clearCache() {
CACHE.clear();
}

private static void walkFields(final Class<?> type, final JavaType.ImplementClass implementClass,
final Map<SqlKind, Map<String, MappingColumn>> fieldsMap) {
if (type.equals(Object.class)) {
Expand Down
@@ -1,8 +1,11 @@
package jp.co.future.uroborosql.mapping;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
import static org.junit.Assert.fail;

import java.lang.reflect.Field;
import java.sql.Connection;
Expand Down Expand Up @@ -2021,6 +2024,18 @@ public void testAddAndRemovePropertyMapper() throws Exception {

}

@Test
public void testClearCache() throws Exception {
EntityHandler<?> handler = config.getEntityHandler();

if (handler instanceof DefaultEntityHandler) {
DefaultEntityHandler.clearCache();
} else {
fail();
}

}

public static class Name {
private final String s;

Expand Down
Expand Up @@ -198,6 +198,11 @@ public void testGetVersionMappingColumn() throws Exception {
}
}

@Test
public void testClearCache() throws Exception {
MappingUtils.clearCache();
}

@Table(name = "TEST")
public static class Test1 {
@Id
Expand Down

0 comments on commit b828746

Please sign in to comment.