From 48924643b3fffe827b252a33a8caa87f150b31d8 Mon Sep 17 00:00:00 2001 From: Yuu NAKAJIMA Date: Mon, 27 Nov 2023 11:39:43 +0900 Subject: [PATCH 1/4] Modify methods for creating TableMappedOrmConnection. --- .../src/main/java/org/nkjmlab/sorm4j/Orm.java | 133 ++++++++---------- .../org/nkjmlab/sorm4j/OrmConnection.java | 20 +-- .../nkjmlab/sorm4j/context/SormContext.java | 41 +++--- .../TableMappedOrmConnectionImpl.java | 2 - .../org/nkjmlab/sorm4j/table/BasicTable.java | 1 - .../nkjmlab/sorm4j/table/TableMappedOrm.java | 64 ++++----- .../table/TableMappedOrmConnection.java | 19 ++- .../sf/persist/tests/common/TestSimple.java | 75 ++++++---- 8 files changed, 168 insertions(+), 187 deletions(-) diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/Orm.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/Orm.java index 4ac70ae4..00f31692 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/Orm.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/Orm.java @@ -4,6 +4,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.List; + import org.nkjmlab.sorm4j.annotation.Experimental; import org.nkjmlab.sorm4j.annotation.OrmColumnAliasPrefix; import org.nkjmlab.sorm4j.common.FunctionHandler; @@ -22,12 +23,10 @@ import org.nkjmlab.sorm4j.result.RowMap; import org.nkjmlab.sorm4j.sql.ParameterizedSql; - /** * Main API for object relation mapping. * * @author nkjm - * */ public interface Orm { @@ -46,6 +45,18 @@ public interface Orm { */ Connection getJdbcConnection(); + /** + * Create a {@link OrmConnection} wrapping a JDBC Connection. + * + *

You should always use try-with-resources block to ensure the database connection is + * released. + * + * @return + */ + default OrmConnection getOrmConnection() { + return OrmConnection.of(getJdbcConnection(), getContext()); + } + /** * Deletes objects from the table corresponding to the class of the given objects. * @@ -55,7 +66,6 @@ public interface Orm { */ int[] delete(List objects); - /** * Deletes an object from the table corresponding to the class of the given objects. * @@ -65,7 +75,6 @@ public interface Orm { */ int delete(T object); - /** * Deletes objects. * @@ -75,7 +84,6 @@ public interface Orm { */ int[] delete(@SuppressWarnings("unchecked") T... objects); - /** * Deletes all objects in the table corresponding to the given class. * @@ -134,7 +142,6 @@ public interface Orm { */ int deleteIn(String tableName, T object); - /** * Deletes objects in the table of the given table name. * @@ -151,12 +158,11 @@ public interface Orm { @Experimental boolean execute(String sql, Object... parameters); - /** - * Executes the query with the given PreparedStatement and applies the given - * {@link ResultSetTraverser}. If you want to set parameters to a PreparedStatement object by - * yourself, you can use this method. You can use your {@link ResultSetTraverser} or the object - * getting by {@link Orm#getResultSetTraverser(Class)}; + * Executes the query with the given PreparedStatement and applies the given {@link + * ResultSetTraverser}. If you want to set parameters to a PreparedStatement object by yourself, + * you can use this method. You can use your {@link ResultSetTraverser} or the object getting by + * {@link Orm#getResultSetTraverser(Class)}; * * @param * @param statementSupplier initialize and supplies PreparedStatement @@ -164,7 +170,8 @@ public interface Orm { * @return */ @Experimental - T executeQuery(FunctionHandler statementSupplier, + T executeQuery( + FunctionHandler statementSupplier, ResultSetTraverser traverser); /** @@ -178,16 +185,16 @@ T executeQuery(FunctionHandler statementSuppl * @return */ @Experimental - List executeQuery(FunctionHandler statementSupplier, - RowMapper rowMapper); + List executeQuery( + FunctionHandler statementSupplier, RowMapper rowMapper); /** * Executes a query and apply the given {@link ResultSetTraverser} to the returned result set. - *

- * This method wraps {@link PreparedStatement#executeQuery(String)} - *

- * Parameters will be set according with the correspondence defined in - * {@link SqlParametersSetter#setParameters(PreparedStatement, Object...)} + * + *

This method wraps {@link PreparedStatement#executeQuery(String)} + * + *

Parameters will be set according with the correspondence defined in {@link + * SqlParametersSetter#setParameters(PreparedStatement, Object...)} * * @param * @param sql SQL code to be executed. @@ -216,18 +223,17 @@ List executeQuery(FunctionHandler statemen /** * Executes an update and returns the number of rows modified. - *

- * This method wraps {@link PreparedStatement#executeUpdate(String)} - *

- * Parameters will be set according with the correspondence defined in - * {@link SqlParametersSetter#setParameters(PreparedStatement, Object...)} + * + *

This method wraps {@link PreparedStatement#executeUpdate(String)} + * + *

Parameters will be set according with the correspondence defined in {@link + * SqlParametersSetter#setParameters(PreparedStatement, Object...)} * * @param sql SQL code to be executed. * @param parameters Parameters to be used in the PreparedStatement. */ int executeUpdate(String sql, Object... parameters); - /** * Returns the object which has same primary key exists or not. * @@ -248,7 +254,6 @@ List executeQuery(FunctionHandler statemen boolean exists(T object); /** - * * @param * @param tableName * @param primaryKeyValues the order should be the same as the column order. @@ -257,7 +262,6 @@ List executeQuery(FunctionHandler statemen boolean exists(String tableName, Object... primaryKeyValues); /** - * * @param * @param type * @param primaryKeyValues the order should be the same as the column order. @@ -275,7 +279,6 @@ List executeQuery(FunctionHandler statemen */ ResultSetTraverser> getResultSetTraverser(Class type); - /** * Gets a function which maps one row in the resultSet to an object. The method does not call * {@link ResultSet#next()}. @@ -286,8 +289,6 @@ List executeQuery(FunctionHandler statemen */ RowMapper getRowMapper(Class type); - - /** * Gets table metadata corresponding to the given object class. * @@ -304,7 +305,6 @@ List executeQuery(FunctionHandler statemen */ JdbcTableMetaData getJdbcTableMetaData(String tableName); - /** * Gets table metadata corresponding to the given object class. * @@ -363,7 +363,6 @@ List executeQuery(FunctionHandler statemen */ int[] insert(@SuppressWarnings("unchecked") T... objects); - /** * Inserts objects and get the last insert result. * @@ -391,7 +390,6 @@ List executeQuery(FunctionHandler statemen */ InsertResult insertAndGet(@SuppressWarnings("unchecked") T... objects); - /** * Inserts objects and get the last insert result. * @@ -433,7 +431,6 @@ List executeQuery(FunctionHandler statemen int[] insertMapIn(String tableName, List result); /** - * * @param tableName * @param object * @return @@ -485,9 +482,8 @@ List executeQuery(FunctionHandler statemen List> join(Class t1, Class t2, String sql, Object... parameters); @Experimental - List> join(Class t1, Class t2, Class t3, String sql, - Object... parameters); - + List> join( + Class t1, Class t2, Class t3, String sql, Object... parameters); @Experimental List> joinOn(Class t1, Class t2, String onCondition); @@ -496,15 +492,15 @@ List> join(Class t1, Class t2, Class List> joinUsing(Class t1, Class t2, String... columns); @Experimental - List> joinOn(Class t1, Class t2, Class t3, - String t1T2OnCondition, String t2T3OnCondition); + List> joinOn( + Class t1, Class t2, Class t3, String t1T2OnCondition, String t2T3OnCondition); @Experimental List> leftJoinOn(Class t1, Class t2, String onCondition); @Experimental - List> leftJoinOn(Class t1, Class t2, Class t3, - String t1T2OnCondition, String t2T3OnCondition); + List> leftJoinOn( + Class t1, Class t2, Class t3, String t1T2OnCondition, String t2T3OnCondition); /** * Merges by objects in the table corresponding to the class of the given objects. @@ -518,13 +514,12 @@ List> leftJoinOn(Class t1, Class t2, Cla /** * Merges by an object in the table corresponding to the class of the given object. - *

- * Merge methods execute a SQL sentence as MERGE INTO of the H2 grammar. This operation may be not - * working the other database system. * - * See, MERGE INTO - + *

Merge methods execute a SQL sentence as MERGE INTO of the H2 grammar. This operation may be + * not working the other database system. + * + *

See, MERGE INTO - * Commands - *

* * @param * @param object @@ -542,8 +537,6 @@ List> leftJoinOn(Class t1, Class t2, Cla */ int[] merge(@SuppressWarnings("unchecked") T... objects); - - /** * Merges by objects in the table corresponding to the given table name. * @@ -584,26 +577,24 @@ List> leftJoinOn(Class t1, Class t2, Cla */ T readFirst(Class type, ParameterizedSql sql); - /** * Reads an object from the database. * * @param * @param type * @param sql with ordered parameter. The other type parameters (e.g. named parameter, list - * parameter) could not be used. + * parameter) could not be used. * @param parameters are ordered parameter. * @return */ T readFirst(Class type, String sql, Object... parameters); - /** * Reads a list of objects from the database by mapping the results of the parameterized SQL query * into instances of the given object class. Only the columns returned from the SQL query will be * set into the object instance. * - * Example: + *

Example: * *

    * ParameterizedSql sql = ParameterizedSql.from("select * from customer");
@@ -615,22 +606,18 @@  List> leftJoinOn(Class t1, Class t2, Cla
    * @param sql
    * @return
    */
-
    List readList(Class type, ParameterizedSql sql);
 
   /**
    * Reads a list of objects from the database by mapping the results of the parameterized SQL query
    * into instances of the given object class. Only the columns returned from the SQL query will be
    * set into the object instance.
-   * 

- * Parameters will be set according with the correspondence defined in - * {@link SqlParametersSetter#setParameters(PreparedStatement, Object[])} * + *

Parameters will be set according with the correspondence defined in {@link + * SqlParametersSetter#setParameters(PreparedStatement, Object[])} */ List readList(Class type, String sql, Object... parameters); - - /** * Reads only one object from the database. * @@ -647,7 +634,7 @@ List> leftJoinOn(Class t1, Class t2, Cla * @param the type to map the result set rows to * @param type the type to map the result set rows to * @param sql with ordered parameter. The other type parameters (e.g. named parameter, list - * parameter) could not be used. + * parameter) could not be used. * @param parameters are ordered parameter. * @return */ @@ -657,7 +644,6 @@ List> leftJoinOn(Class t1, Class t2, Cla * Reads results as List of {@link Tuple3} for reading JOIN SQL results typically. * * @see {@link OrmColumnAliasPrefix} for use column alias prefix. - * * @param * @param * @param @@ -668,14 +654,13 @@ List> leftJoinOn(Class t1, Class t2, Cla * @return */ @Experimental - List> readTupleList(Class t1, Class t2, Class t3, - ParameterizedSql sql); + List> readTupleList( + Class t1, Class t2, Class t3, ParameterizedSql sql); /** * Reads results as List of {@link Tuple3} for reading JOIN SQL results typically. * * @see {@link OrmColumnAliasPrefix} for use column alias prefix. - * * @param * @param * @param t1 @@ -684,16 +669,14 @@ List> readTupleList(Class t1, Class t2, * @param parameters * @return */ - @Experimental - List> readTupleList(Class t1, Class t2, Class t3, - String sql, Object... parameters); + List> readTupleList( + Class t1, Class t2, Class t3, String sql, Object... parameters); /** * Reads results as List of {@link Tuple2} for reading JOIN SQL results typically. * * @see {@link OrmColumnAliasPrefix} for use column alias prefix. - * * @param * @param * @param t1 @@ -708,7 +691,6 @@ List> readTupleList(Class t1, Class t2, * Reads results as List of {@link Tuple2} for reading JOIN SQL results typically. * * @see {@link OrmColumnAliasPrefix} for use column alias prefix. - * * @param * @param * @param t1 @@ -718,8 +700,8 @@ List> readTupleList(Class t1, Class t2, * @return */ @Experimental - List> readTupleList(Class t1, Class t2, String sql, - Object... parameters); + List> readTupleList( + Class t1, Class t2, String sql, Object... parameters); /** * Reads all rows from the table indicated by object class. @@ -741,7 +723,6 @@ List> readTupleList(Class t1, Class t2, String s T selectByPrimaryKey(Class type, Object... primaryKeyValues); /** - * * Updates by objects in the table corresponding to the class of the given objects. * * @param @@ -769,7 +750,6 @@ List> readTupleList(Class t1, Class t2, String s int[] update(@SuppressWarnings("unchecked") T... objects); /** - * * @param * @param clazz * @param object @@ -780,7 +760,6 @@ List> readTupleList(Class t1, Class t2, String s int updateByPrimaryKey(Class clazz, RowMap object, Object... primaryKeyValues); /** - * * @param tableName * @param object * @param primaryKeyValues the order should be the same as the column order. @@ -840,9 +819,9 @@ List> readTupleList(Class t1, Class t2, String s /** * Returns an {@link ResultSetStream}. It is able to convert to Stream, List, and so on. - *

- * Parameters will be set according with the correspondence defined in - * {@link SqlParametersSetter#setParameters(PreparedStatement,Object[])} * + * + *

Parameters will be set according with the correspondence defined in {@link + * SqlParametersSetter#setParameters(PreparedStatement,Object[])} * * * @param * @param type @@ -851,6 +830,4 @@ List> readTupleList(Class t1, Class t2, String s * @return */ ResultSetStream stream(Class type, String sql, Object... parameters); - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmConnection.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmConnection.java index 9f1ce09b..c981f3ce 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmConnection.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmConnection.java @@ -7,29 +7,27 @@ import org.nkjmlab.sorm4j.internal.SormImpl; import org.nkjmlab.sorm4j.table.TableMappedOrmConnection; -/** - * - * @author yuu_nkjm - * - */ +/** @author yuu_nkjm */ public interface OrmConnection extends Orm, AutoCloseable { /** * Create a {@link OrmConnection} wrapping the given JDBC Connection. * - * You should always use try-with-resources block to ensure the database connection is released. + *

You should always use try-with-resources block to ensure the database connection is + * released. * * @param connection * @return */ static OrmConnection of(Connection connection) { - return new OrmConnectionImpl(connection, SormImpl.DEFAULT_CONTEXT); + return of(connection, SormImpl.DEFAULT_CONTEXT); } /** * Create a {@link OrmConnection} wrapping the given JDBC Connection and the given context. * - * You should always use try-with-resources block to ensure the database connection is released. + *

You should always use try-with-resources block to ensure the database connection is + * released. * * @param connection * @param sormContext @@ -39,12 +37,10 @@ static OrmConnection of(Connection connection, SormContext sormContext) { return new OrmConnectionImpl(connection, SormContextImpl.class.cast(sormContext)); } - /** * Closes the {@link java.sql.Connection Connection} associated with this instance. * * @see java.sql.Connection#close() - * */ @Override void close(); @@ -53,7 +49,6 @@ static OrmConnection of(Connection connection, SormContext sormContext) { * Commits the {@link java.sql.Connection Connection} associated with this instance. * * @see java.sql.Connection#commit() - * */ void commit(); @@ -61,7 +56,6 @@ static OrmConnection of(Connection connection, SormContext sormContext) { * Roll back the {@link java.sql.Connection Connection} associated with this instance. * * @see java.sql.Connection#rollback() - * */ void rollback(); @@ -70,7 +64,6 @@ static OrmConnection of(Connection connection, SormContext sormContext) { * this instance. * * @see java.sql.Connection#setAutoCommit(boolean) - * */ void setAutoCommit(boolean autoCommit); @@ -93,5 +86,4 @@ static OrmConnection of(Connection connection, SormContext sormContext) { * @return */ TableMappedOrmConnection mapToTable(Class type, String tableName); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SormContext.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SormContext.java index 3bdd24cc..ea6e2484 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SormContext.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SormContext.java @@ -2,14 +2,14 @@ import org.nkjmlab.sorm4j.Sorm; import org.nkjmlab.sorm4j.internal.SormContextImpl; +import org.nkjmlab.sorm4j.internal.SormImpl; import org.nkjmlab.sorm4j.util.logger.LoggerContext; /** - * A context for a {@link Sorm} instance. An instance of this class could be built by - * {{@link Builder#build()}. The instance of this class should be thread-safe. + * A context for a {@link Sorm} instance. An instance of this class could be built by {{@link + * Builder#build()}. The instance of this class should be thread-safe. * * @author yuu_nkjm - * */ public interface SormContext { @@ -23,13 +23,12 @@ public interface SormContext { LoggerContext getLoggerContext(); - /** * Returns new {@link Builder} which has set values from the given {@link SormContext} * * @return */ - public static Builder builder(SormContext context) { + static Builder builder(SormContext context) { SormContextImpl ctx = (SormContextImpl) context; return ctx.builder(); } @@ -39,10 +38,14 @@ public static Builder builder(SormContext context) { * * @return */ - public static Builder builder() { + static Builder builder() { return new Builder(); } + static SormContext getDefaultContext() { + return SormImpl.DEFAULT_CONTEXT; + } + public static class Builder { private static final MultiRowProcessorFactory DEFAULT_MULTI_ROW_PROCESSOR_FACTORY = @@ -57,8 +60,8 @@ public static class Builder { private static final ColumnValueToJavaObjectConverters DEFAULT_RESULT_SET_CONVERTERS = new DefaultColumnValueToJavaObjectConverters(); - public static final ColumnValueToMapValueConverters DEFAULT_COLUMN_VALUE_TO_MAP_VALUE_CONVERTERS = - new DefaultColumnValueToMapValueConverters(); + public static final ColumnValueToMapValueConverters + DEFAULT_COLUMN_VALUE_TO_MAP_VALUE_CONVERTERS = new DefaultColumnValueToMapValueConverters(); private static final TableNameMapper DEFAULT_TABLE_NAME_MAPPER = new DefaultTableNameMapper(); @@ -84,29 +87,31 @@ public static class Builder { private PreparedStatementSupplier statementSupplier = DEFAULT_STATEMENT_SUPPLIER; - - private Builder() {} public SormContext build() { - return new SormContextImpl(loggerContext, columnFieldMapper, tableNameMapper, - columnValueToJavaObjectConverters, columnValueToMapValueConverter, sqlParametersSetter, - statementSupplier, tableSqlFactory, multiRowProcessorFactory); + return new SormContextImpl( + loggerContext, + columnFieldMapper, + tableNameMapper, + columnValueToJavaObjectConverters, + columnValueToMapValueConverter, + sqlParametersSetter, + statementSupplier, + tableSqlFactory, + multiRowProcessorFactory); } - public Builder setColumnToFieldAccessorMapper(ColumnToFieldAccessorMapper fieldNameMapper) { this.columnFieldMapper = fieldNameMapper; return this; } - public Builder setTableNameMapper(TableNameMapper tableNameMapper) { this.tableNameMapper = tableNameMapper; return this; } - public Builder setColumnValueToJavaObjectConverters( ColumnValueToJavaObjectConverters converters) { this.columnValueToJavaObjectConverters = converters; @@ -129,7 +134,6 @@ public Builder setPreparedStatementSupplier( return this; } - public Builder setTableSqlFactory(TableSqlFactory tableSqlFactory) { this.tableSqlFactory = tableSqlFactory; return this; @@ -140,12 +144,9 @@ public Builder setMultiRowProcessorFactory(MultiRowProcessorFactory multiRowProc return this; } - public Builder setLoggerContext(LoggerContext loggerContext) { this.loggerContext = loggerContext; return this; } - } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/TableMappedOrmConnectionImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/TableMappedOrmConnectionImpl.java index 4a41e919..14fbe46e 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/TableMappedOrmConnectionImpl.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/TableMappedOrmConnectionImpl.java @@ -20,7 +20,6 @@ public TableMappedOrmConnectionImpl(OrmConnection ormConn, Class valueType, S * * @param sorm * @param valueType - * */ public TableMappedOrmConnectionImpl(OrmConnection ormConn, Class valueType) { this(ormConn, valueType, ormConn.getTableName(valueType)); @@ -40,5 +39,4 @@ public String getTableName() { public Class getValueType() { return valueType; } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java index 2f16b7e6..8b3e1a7f 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java @@ -20,7 +20,6 @@ public BasicTable(Sorm sorm, Class valueType, String tableName) { * * @param sorm * @param valueType - * */ public BasicTable(Sorm sorm, Class valueType) { this(sorm, valueType, sorm.getTableName(valueType)); diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrm.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrm.java index 4f553fd5..a2cdfe47 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrm.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrm.java @@ -1,8 +1,11 @@ package org.nkjmlab.sorm4j.table; -import static org.nkjmlab.sorm4j.util.sql.SqlKeyword.*; +import static org.nkjmlab.sorm4j.util.sql.SqlKeyword.AND; +import static org.nkjmlab.sorm4j.util.sql.SqlKeyword.WHERE; + import java.sql.PreparedStatement; import java.util.List; + import org.nkjmlab.sorm4j.Orm; import org.nkjmlab.sorm4j.annotation.Experimental; import org.nkjmlab.sorm4j.common.TableMetaData; @@ -22,7 +25,18 @@ public interface TableMappedOrm { /** - * Gets Sorm objects + * Create a {@link TableMappedOrmConnection} wrapping a JDBC Connection. + * + *

You should always use try-with-resources block to ensure the database connection is + * released. + * + * @return + */ + default TableMappedOrmConnection getTableMappedOrmConnection() { + return TableMappedOrmConnection.of(getOrm().getOrmConnection(), getValueType()); + } + /** + * Gets {@link Orm} object * * @return */ @@ -46,12 +60,10 @@ default T readFirst(ParameterizedSql sql) { return getOrm().readFirst(getValueType(), sql); } - default T readFirst(String sql, Object... parameters) { return getOrm().readFirst(getValueType(), sql, parameters); } - default List readList(ParameterizedSql sql) { return getOrm().readList(getValueType(), sql); } @@ -64,7 +76,6 @@ default T readOne(ParameterizedSql sql) { return getOrm().readOne(getValueType(), sql); } - default T readOne(String sql, Object... parameters) { return getOrm().readOne(getValueType(), sql, parameters); } @@ -73,12 +84,10 @@ default RowMapper getRowMapper() { return getOrm().getRowMapper(getValueType()); } - default ResultSetTraverser> getResultSetTraverser() { return getOrm().getResultSetTraverser(getValueType()); } - default TableMetaData getTableMetaData() { return getOrm().getTableMetaData(getValueType()); } @@ -91,22 +100,18 @@ default boolean exists(Object... primaryKeyValues) { return getOrm().exists(getValueType(), primaryKeyValues); } - default int[] delete(List objects) { return getOrm().deleteIn(getTableName(), objects); } - default int delete(T object) { return getOrm().deleteIn(getTableName(), object); } - default int[] delete(@SuppressWarnings("unchecked") T... objects) { return getOrm().deleteIn(getTableName(), objects); } - default int deleteAll() { return getOrm().deleteAllIn(getTableName()); } @@ -125,12 +130,10 @@ default int[] insert(List objects) { return getOrm().insertIn(getTableName(), objects); } - default int insert(T object) { return getOrm().insertIn(getTableName(), object); } - default int[] insert(@SuppressWarnings("unchecked") T... objects) { return getOrm().insertIn(getTableName(), objects); } @@ -155,37 +158,30 @@ default InsertResult insertAndGet(T object) { return getOrm().insertAndGetIn(getTableName(), object); } - default InsertResult insertAndGet(@SuppressWarnings("unchecked") T... objects) { return getOrm().insertAndGetIn(getTableName(), objects); } - default int[] merge(List objects) { return getOrm().mergeIn(getTableName(), objects); } - default int merge(T object) { return getOrm().mergeIn(getTableName(), object); } - default int[] merge(@SuppressWarnings("unchecked") T... objects) { return getOrm().mergeIn(getTableName(), objects); } - default int[] update(List objects) { return getOrm().updateIn(getTableName(), objects); } - default int update(T object) { return getOrm().updateIn(getTableName(), object); } - default int[] update(@SuppressWarnings("unchecked") T... objects) { return getOrm().updateIn(getTableName(), objects); } @@ -216,7 +212,6 @@ default T selectByPrimaryKey(Object... primaryKeyValues) { /** * @see {@link #getAllEqualSql(List)} - * * @param tupplesOfNameAndValue * @return */ @@ -224,11 +219,8 @@ default List selectListAllEqual(Object... tupplesOfNameAndValue) { return getOrm().readList(getValueType(), getAllEqualSql(tupplesOfNameAndValue)); } - - /** * @see {@link #getAllEqualSql(Object...)} - * * @param tupplesOfNameAndValue * @return */ @@ -236,10 +228,8 @@ default T selectFirstAllEqual(Object... tupplesOfNameAndValue) { return getOrm().readFirst(getValueType(), getAllEqualSql(tupplesOfNameAndValue)); } - /** * @see {@link #getAllEqualSql(Object...))} - * * @param tupplesOfNameAndValue * @return */ @@ -247,15 +237,13 @@ default T selectOneAllEqual(Object... tupplesOfNameAndValue) { return getOrm().readOne(getValueType(), getAllEqualSql(tupplesOfNameAndValue)); } - - /** * Creates a SQL statement selecting rows which are satisfied all equal condition corresponding to * the given arguments. * - * Note: All the rows will be selected, if length of arguments is zero + *

Note: All the rows will be selected, if length of arguments is zero * - * Example + *

Example * *

    * getAllEqualSql("address", "Tokyo", "age", 20)
@@ -299,7 +287,6 @@ default int count() {
    *
    * @return
    */
-
   default ResultSetStream streamAll() {
     return getOrm().streamAll(getValueType());
   }
@@ -316,9 +303,9 @@ default ResultSetStream stream(ParameterizedSql sql) {
 
   /**
    * Returns an {@link ResultSetStream}.
-   * 

- * Parameters will be set according with the correspondence defined in - * {@link SqlParametersSetter#setParameters(PreparedStatement,Object[])} + * + *

Parameters will be set according with the correspondence defined in {@link + * SqlParametersSetter#setParameters(PreparedStatement,Object[])} * * @param sql * @param parameters @@ -334,15 +321,14 @@ default List> join(TableMappedOrm second, String sql, Object } @Experimental - default List> join(TableMappedOrm second, TableMappedOrm third, - String sql, Object... parameters) { - return getOrm().join(getValueType(), second.getValueType(), third.getValueType(), sql, - parameters); + default List> join( + TableMappedOrm second, TableMappedOrm third, String sql, Object... parameters) { + return getOrm() + .join(getValueType(), second.getValueType(), third.getValueType(), sql, parameters); } @Experimental default JoinSql.Builder joinSqlBuilder() { return JoinSql.builder(this); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrmConnection.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrmConnection.java index bc650dfe..be26182b 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrmConnection.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrmConnection.java @@ -2,16 +2,31 @@ import org.nkjmlab.sorm4j.OrmConnection; import org.nkjmlab.sorm4j.annotation.Experimental; +import org.nkjmlab.sorm4j.internal.TableMappedOrmConnectionImpl; @Experimental public interface TableMappedOrmConnection extends TableMappedOrm { /** - * Gets Sorm objects + * Gets OrmConnection object * * @return */ - @Override OrmConnection getOrm(); + /** + * Create a {@link TableMappedOrmConnection} wrapping the given JDBC Connection and the given + * context. + * + *

You should always use try-with-resources block to ensure the database connection is + * released. + * + * @param + * @param connection + * @param valueType + * @return + */ + static TableMappedOrmConnection of(OrmConnection connection, Class valueType) { + return new TableMappedOrmConnectionImpl(connection, valueType); + } } diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/TestSimple.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/TestSimple.java index 634f9015..b34dfcc3 100644 --- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/TestSimple.java +++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/TestSimple.java @@ -41,8 +41,6 @@ private static void dropAndCreateSimpleTable() { } } - - @BeforeEach void beforeEach() throws SQLException { dropAndCreateSimpleTable(); @@ -74,7 +72,6 @@ public void testNoTable() throws SQLException { } } - @Test public void testExecuteUpdate() throws SQLException { @@ -84,14 +81,20 @@ public void testExecuteUpdate() throws SQLException { Simple createdSimple = buildSimple(); // insert and check count of rows returned - int n = ormConn.executeUpdate("insert into simple (long_col, string_col) values(?,?)", - createdSimple.getLongCol(), createdSimple.getStringCol()); + int n = + ormConn.executeUpdate( + "insert into simple (long_col, string_col) values(?,?)", + createdSimple.getLongCol(), + createdSimple.getStringCol()); assertEquals(1, n); // read object and compare with inserted data Simple simpleRead = - ormConn.readFirst(Simple.class, "select * from simple where long_col=? and string_col=?", - createdSimple.getLongCol(), createdSimple.getStringCol()); + ormConn.readFirst( + Simple.class, + "select * from simple where long_col=? and string_col=?", + createdSimple.getLongCol(), + createdSimple.getStringCol()); assertNotNull(simpleRead); assertEquals(createdSimple.getLongCol(), simpleRead.getLongCol()); @@ -100,8 +103,11 @@ public void testExecuteUpdate() throws SQLException { // delete object and check it was removed ormConn.delete(simpleRead); simpleRead = - ormConn.readFirst(Simple.class, "select * from simple where long_col=? and string_col=?", - createdSimple.getLongCol(), createdSimple.getStringCol()); + ormConn.readFirst( + Simple.class, + "select * from simple where long_col=? and string_col=?", + createdSimple.getLongCol(), + createdSimple.getStringCol()); assertNull(simpleRead); } } @@ -138,16 +144,24 @@ public void testExecuteUpdateAutoGeneratedKeys() throws SQLException { assertEquals(1, ret.getRowsModified()[0]); // read object and compare with inserted data - Simple simpleRead = ormConn.readFirst(Simple.class, - "select * from simple where long_col=? and string_col=?", longCol, stringCol); + Simple simpleRead = + ormConn.readFirst( + Simple.class, + "select * from simple where long_col=? and string_col=?", + longCol, + stringCol); assertNotNull(simpleRead); assertEquals(longCol, simpleRead.getLongCol()); assertEquals(stringCol, simpleRead.getStringCol()); // delete object and check it was removed ormConn.delete(simpleRead); - simpleRead = ormConn.readFirst(Simple.class, - "select * from simple where long_col=? and string_col=?", longCol, stringCol); + simpleRead = + ormConn.readFirst( + Simple.class, + "select * from simple where long_col=? and string_col=?", + longCol, + stringCol); assertNull(simpleRead); } } @@ -179,10 +193,12 @@ public void testReturnNativeTypes() throws SQLException { Simple simple = buildSimple(); ormConn.insert(simple); - long longCol = ormConn.readFirst(long.class, "select long_col from simple where long_col=?", - simple.getLongCol()); - String stringCol = ormConn.readFirst(String.class, - "select string_col from simple where long_col=?", simple.getLongCol()); + long longCol = + ormConn.readFirst( + long.class, "select long_col from simple where long_col=?", simple.getLongCol()); + String stringCol = + ormConn.readFirst( + String.class, "select string_col from simple where long_col=?", simple.getLongCol()); assertEquals(simple.getLongCol(), longCol); assertEquals(simple.getStringCol(), stringCol); @@ -192,7 +208,7 @@ public void testReturnNativeTypes() throws SQLException { @Test public void testBatch() throws SQLException { try (Connection conn = dataSource.getConnection(); - OrmConnection ormConn = OrmConnection.of(conn, SormContext.builder().build());) { + OrmConnection ormConn = OrmConnection.of(conn, SormContext.builder().build()); ) { Simple simple1 = buildSimple(); Simple simple2 = buildSimple(); @@ -267,7 +283,6 @@ private static String randomString(int i) { return String.valueOf(ThreadLocalRandom.current().nextInt(i)); } - @Test public void testObjectList() throws SQLException { try (Connection conn = dataSource.getConnection(); @@ -295,7 +310,6 @@ public void testObjectList() throws SQLException { } } - @Test public void testMap() throws SQLException { try (Connection conn = dataSource.getConnection(); @@ -306,8 +320,9 @@ public void testMap() throws SQLException { long id = ormConn.readFirst(long.class, "select id from simple limit 1"); - Map simpleMap1 = ormConn.readFirst(RowMap.class, - "select id, long_col, string_col from simple where id=?", id); + Map simpleMap1 = + ormConn.readFirst( + RowMap.class, "select id, long_col, string_col from simple where id=?", id); assertEquals(id, simpleMap1.get("id")); assertEquals(simple.getLongCol(), simpleMap1.get("long_col")); assertEquals(simple.getStringCol(), simpleMap1.get("string_col")); @@ -319,7 +334,7 @@ public void testMap() throws SQLException { @Test public void testMapList() throws SQLException { try (Connection conn = dataSource.getConnection(); - OrmConnection ormConn = OrmConnection.of(conn)) { + OrmConnection ormConn = OrmConnection.of(conn, SormContext.getDefaultContext())) { ormConn.executeUpdate("DELETE FROM SIMPLE"); Simple simple1 = buildSimple(); @@ -335,8 +350,12 @@ public void testMapList() throws SQLException { simple3.setId(ids.get(2)); List simpleList = - ormConn.readList(RowMap.class, "select * from simple where id in (?,?,?)", - simple1.getId(), simple2.getId(), simple3.getId()); + ormConn.readList( + RowMap.class, + "select * from simple where id in (?,?,?)", + simple1.getId(), + simple2.getId(), + simple3.getId()); assertEquals(simple1.getId(), simpleList.get(0).get("id")); assertEquals(simple1.getLongCol(), simpleList.get(0).get("long_col")); assertEquals(simple1.getStringCol(), simpleList.get(0).get("string_col")); @@ -355,7 +374,6 @@ public void testMapList() throws SQLException { } } - @Test public void testMappingSimple01() { // Simple01 specifies an invalid column name but field is used. @@ -380,7 +398,6 @@ public void testMappingSimple02() { failBecauseExceptionWasNotThrown(Exception.class); } catch (Exception e) { assertThat(e.getMessage()).contains("does not match any existing table"); - } } @@ -397,7 +414,6 @@ public void testMappingSimple03() { } } - @Test public void testMappingSimple04() { // Simple04 has incompatible setter @@ -411,7 +427,6 @@ public void testMappingSimple04() { } } - @Test public void testMappingSimple05() { // Simple05 doesn't specify a table name and guessed names won't work @@ -513,6 +528,4 @@ public void testMapping() throws SQLException { } } } - - } From 404ee3970f99c65a44d5512b8817c4d2c1e8b04d Mon Sep 17 00:00:00 2001 From: Yuu NAKAJIMA Date: Mon, 27 Nov 2023 11:40:21 +0900 Subject: [PATCH 2/4] Modify source formatting. --- .../org/nkjmlab/sorm4j/OrmTransaction.java | 6 +- .../main/java/org/nkjmlab/sorm4j/Sorm.java | 53 +- .../sorm4j/annotation/Experimental.java | 4 +- .../nkjmlab/sorm4j/annotation/OrmColumn.java | 8 +- .../annotation/OrmColumnAliasPrefix.java | 6 +- .../sorm4j/annotation/OrmConstructor.java | 5 +- .../nkjmlab/sorm4j/annotation/OrmGetter.java | 9 +- .../nkjmlab/sorm4j/annotation/OrmIgnore.java | 9 +- .../nkjmlab/sorm4j/annotation/OrmRecord.java | 9 +- .../nkjmlab/sorm4j/annotation/OrmSetter.java | 10 +- .../nkjmlab/sorm4j/annotation/OrmTable.java | 9 +- .../nkjmlab/sorm4j/common/ColumnMetaData.java | 47 +- .../org/nkjmlab/sorm4j/common/ColumnName.java | 12 +- .../sorm4j/common/ConsumerHandler.java | 2 +- .../common/DriverManagerDataSource.java | 6 +- .../sorm4j/common/JdbcTableMetaData.java | 1 - .../nkjmlab/sorm4j/common/SormException.java | 5 +- .../nkjmlab/sorm4j/common/TableMetaData.java | 11 +- .../java/org/nkjmlab/sorm4j/common/Tuple.java | 35 +- .../context/ColumnToFieldAccessorMapper.java | 5 +- .../ColumnValueToJavaObjectConverter.java | 14 +- .../ColumnValueToJavaObjectConverters.java | 17 +- .../ColumnValueToMapValueConverters.java | 7 +- .../DefaultColumnToFieldAccessorMapper.java | 56 +- ...aultColumnValueToJavaObjectConverters.java | 228 +++--- ...efaultColumnValueToMapValueConverters.java | 72 +- .../DefaultPreparedStatementSupplier.java | 7 +- .../context/DefaultSqlParametersSetter.java | 61 +- .../context/DefaultTableMetaDataParser.java | 20 +- .../context/DefaultTableNameMapper.java | 43 +- .../context/DefaultTableSqlFactory.java | 109 ++- .../nkjmlab/sorm4j/context/FieldAccessor.java | 36 +- .../context/MultiRowProcessorFactory.java | 32 +- .../context/NameToFieldAccessorMapper.java | 1 - .../context/PreparedStatementSupplier.java | 6 +- .../sorm4j/context/SqlParameterSetter.java | 2 - .../sorm4j/context/SqlParametersSetter.java | 4 - .../sorm4j/context/TableMetaDataParser.java | 4 - .../sorm4j/context/TableNameMapper.java | 2 - .../org/nkjmlab/sorm4j/context/TableSql.java | 61 +- .../sorm4j/context/TableSqlFactory.java | 1 - .../sorm4j/internal/OrmConnectionImpl.java | 496 ++++++++----- .../sorm4j/internal/OrmTransactionImpl.java | 9 +- .../nkjmlab/sorm4j/internal/SormConfig.java | 41 +- .../sorm4j/internal/SormContextImpl.java | 271 +++++--- .../org/nkjmlab/sorm4j/internal/SormImpl.java | 78 +-- .../internal/common/TableMetaDataImpl.java | 72 +- .../mapping/ColumnToAccessorMapping.java | 117 +++- .../mapping/SqlParametersToTableMapping.java | 76 +- .../mapping/SqlResultToColumnsMapping.java | 127 ++-- .../mapping/SqlResultToContainerMapping.java | 30 +- ...sultToContainerMappingWithConstructor.java | 104 +-- ...SqlResultToContainerMappingWithSetter.java | 66 +- .../sorm4j/internal/mapping/TableName.java | 13 +- ...atchOfMultiRowInOneStatementProcessor.java | 47 +- .../MultiRowInOneStatementProcessor.java | 47 +- .../mapping/multirow/MultiRowProcessor.java | 83 ++- .../MultiRowProcessorFactoryImpl.java | 52 +- .../multirow/SimpleBatchProcessor.java | 8 +- .../result/AbstractResultSetStream.java | 20 +- .../internal/result/InsertResultImpl.java | 17 +- .../internal/result/ResultSetIterator.java | 10 +- .../result/ResultSetStreamOrmConnection.java | 7 +- .../internal/result/ResultSetStreamSorm.java | 6 +- .../sql/NamedParameterSqlParserImpl.java | 8 +- .../sql/OrderedParameterSqlParserImpl.java | 3 - .../internal/sql/ParameterizedSqlImpl.java | 56 +- .../sorm4j/internal/util/ArrayUtils.java | 20 +- .../sorm4j/internal/util/ClassUtils.java | 18 +- .../sorm4j/internal/util/ConcurrentCache.java | 12 +- .../sorm4j/internal/util/JdbcTypeUtils.java | 1 - .../internal/util/MethodInvokerInfoUtils.java | 42 +- .../util/ParameterizedStringFormatter.java | 14 +- .../sorm4j/internal/util/StringCache.java | 8 +- .../internal/util/SystemPropertyUtils.java | 55 +- .../org/nkjmlab/sorm4j/internal/util/Try.java | 128 ++-- .../util/command/AbstractCommand.java | 5 +- .../util/command/BasicCommandImpl.java | 2 - .../command/NamedParameterCommandImpl.java | 4 +- .../command/OrderedParameterCommandImpl.java | 1 - .../util/logger/AbstractSormLogger.java | 38 +- .../internal/util/logger/JulSormLogger.java | 3 - .../internal/util/logger/Log4jSormLogger.java | 26 +- .../internal/util/logger/Slf4jSormLogger.java | 68 +- .../sorm4j/mapping/ResultSetTraverser.java | 2 - .../org/nkjmlab/sorm4j/mapping/RowMapper.java | 2 - .../nkjmlab/sorm4j/result/BasicRowMap.java | 65 +- .../nkjmlab/sorm4j/result/InsertResult.java | 9 +- .../sorm4j/result/JdbcDatabaseMetaData.java | 150 ++-- .../sorm4j/result/ResultSetStream.java | 2 - .../sorm4j/sql/NamedParameterSqlParser.java | 13 +- .../sorm4j/sql/OrderedParameterSqlParser.java | 6 +- .../nkjmlab/sorm4j/sql/ParameterizedSql.java | 7 +- .../sorm4j/sql/ParameterizedSqlParser.java | 31 +- .../org/nkjmlab/sorm4j/table/BasicTable.java | 1 - .../java/org/nkjmlab/sorm4j/table/Table.java | 2 - .../sorm4j/util/command/BasicCommand.java | 2 - .../nkjmlab/sorm4j/util/command/Command.java | 21 +- .../util/command/NamedParameterCommand.java | 4 - .../util/command/OrderedParameterCommand.java | 2 - .../sorm4j/util/datatype/GeometryString.java | 13 +- .../sorm4j/util/datatype/JsonByte.java | 1 - .../util/datatype/OrmJsonColumnContainer.java | 3 +- .../nkjmlab/sorm4j/util/h2/BasicH2Table.java | 2 - .../org/nkjmlab/sorm4j/util/h2/H2Table.java | 40 +- .../datasource/H2LocalDataSourceFactory.java | 62 +- .../util/h2/server/H2ServerProcess.java | 32 +- .../util/h2/server/H2ServerProperties.java | 4 - .../h2/server/H2ServerPropertiesBuilder.java | 4 - .../util/h2/server/H2TcpServerProcess.java | 14 +- .../util/h2/server/H2TcpServerProperties.java | 13 +- .../util/h2/server/H2WebBrowsingService.java | 15 +- .../h2/server/H2WebConsoleServerProcess.java | 3 - .../server/H2WebConsoleServerProperties.java | 12 +- .../nkjmlab/sorm4j/util/h2/sql/CsvColumn.java | 14 +- .../sorm4j/util/h2/sql/H2CsvFunctions.java | 72 +- .../sorm4j/util/h2/sql/H2CsvReadSql.java | 101 +-- .../sorm4j/util/h2/sql/SkipCsvRead.java | 6 +- ...cksonColumnValueToJavaObjectConverter.java | 17 +- .../util/jackson/JacksonSormContext.java | 17 +- .../jackson/JacksonSqlParameterSetter.java | 17 +- .../nkjmlab/sorm4j/util/jts/GeometryJts.java | 9 +- .../JtsColumnValueToJavaObjectConverter.java | 11 +- .../sorm4j/util/jts/JtsSormContext.java | 1 - .../util/jts/JtsSqlParameterSetter.java | 10 +- .../nkjmlab/sorm4j/util/logger/LogPoint.java | 12 +- .../sorm4j/util/logger/LoggerContext.java | 39 +- .../sorm4j/util/logger/SormLogger.java | 5 +- .../org/nkjmlab/sorm4j/util/sql/JoinSql.java | 19 +- .../nkjmlab/sorm4j/util/sql/SelectSql.java | 76 +- .../nkjmlab/sorm4j/util/sql/SqlKeyword.java | 12 +- .../table_def/BasicTableWithDefinition.java | 1 - .../util/table_def/TableDefinition.java | 185 +++-- .../util/table_def/TableWithDefinition.java | 2 - .../table_def/annotation/AutoIncrement.java | 4 +- .../table_def/annotation/CheckConstraint.java | 9 +- .../util/table_def/annotation/Index.java | 4 +- .../table_def/annotation/IndexColumns.java | 9 +- .../util/table_def/annotation/NotNull.java | 4 +- .../util/table_def/annotation/PrimaryKey.java | 4 +- .../annotation/PrimaryKeyColumns.java | 1 - .../util/table_def/annotation/Unique.java | 4 +- .../table_def/annotation/UniqueColumns.java | 1 - .../sorm4j/common/ColumnMetaDataTest.java | 10 +- .../org/nkjmlab/sorm4j/common/TupleTest.java | 1 - ...ColumnValueToJavaObjectConvertersTest.java | 104 +-- .../DefaultSqlParametersSetterTest.java | 33 +- .../context/DefaultTableNameMapperTest.java | 35 +- .../sorm4j/context/FieldAccessorTest.java | 14 +- .../sorm4j/context/ResultSetMapperTest.java | 18 +- .../engine/TestPostgreSQLSqlMapper.java | 152 ++-- .../internal/OrmConnectionImplTest.java | 658 ++++++++++-------- .../nkjmlab/sorm4j/internal/OrmImplTest.java | 81 +-- .../sorm4j/internal/OrmStreamTest.java | 3 - .../sorm4j/internal/SormContextImplTest.java | 57 +- .../nkjmlab/sorm4j/internal/SormImplTest.java | 42 +- .../sorm4j/internal/ValuesObjectTest.java | 5 - .../mapping/ColumnToAccessorMappingTest.java | 77 +- .../DefaultResultSetValueGetterTest.java | 59 +- ...OfMultiRowInOneStatementProcessorTest.java | 37 +- .../MultiRowInOneStatementProcessorTest.java | 80 ++- .../mapping/multirow/OrmConfigStoreTest.java | 27 +- .../multirow/SimpleBatchProcessorTest.java | 39 +- .../result/TableMetaDataImplTest.java | 2 - .../sorm4j/internal/util/ArrayUtilsTest.java | 19 +- .../sorm4j/internal/util/ClassUtilsTest.java | 56 +- .../internal/util/ConcurrentCacheTest.java | 2 - .../util/DriverManagerDataSourceTest.java | 1 - .../internal/util/JdbcTypeUtilsTest.java | 1 - .../util/MethodInvokerInfoUtilsTest.java | 7 +- .../util/ParameterizedStringUtilsTest.java | 2 - .../sorm4j/internal/util/StringCacheTest.java | 1 - .../sorm4j/internal/util/StringUtilsTest.java | 5 +- .../nkjmlab/sorm4j/internal/util/TryTest.java | 256 ++++--- .../internal/util/logger/SormLoggerTest.java | 34 +- .../result/JdbcDatabaseMetaDataTest.java | 1 - .../org/nkjmlab/sorm4j/result/RowMapTest.java | 7 - .../sorm4j/sql/NamedParameterSqlTest.java | 32 +- .../sorm4j/sql/OrderedParameterSqlTest.java | 14 +- .../sorm4j/sql/ParameterizedSqlTest.java | 15 +- .../sorm4j/table/TableSchemaKeywordTest.java | 1 - .../nkjmlab/sorm4j/table/TableSchemaTest.java | 71 +- .../org/nkjmlab/sorm4j/table/TableTest.java | 73 +- .../nkjmlab/sorm4j/test/common/Customer.java | 4 - .../org/nkjmlab/sorm4j/test/common/Guest.java | 14 +- .../nkjmlab/sorm4j/test/common/Player.java | 14 +- .../sorm4j/test/common/SormTestUtils.java | 166 +++-- .../org/nkjmlab/sorm4j/test/common/Sport.java | 5 +- .../nkjmlab/sorm4j/test/common/TestUtils.java | 2 - .../sorm4j/util/command/CommandTest.java | 259 ++++--- .../sorm4j/util/h2/BasicH2TableTest.java | 5 +- .../H2LocalDataSourceFactoryTest.java | 19 +- .../h2/server/H2TcpServerProcessTest.java | 13 +- .../h2/server/H2WebBrowsingServiceTest.java | 2 - .../server/H2WebConsoleServerProcessTest.java | 12 +- .../sorm4j/util/h2/server/ProcessUtils.java | 112 +-- .../sorm4j/util/h2/sql/H2CsvReadSqlTest.java | 34 +- .../util/jackson/JacksonSormContextTest.java | 35 +- .../nkjmlab/sorm4j/util/jts/GeometryTest.java | 15 +- .../sorm4j/util/sql/SelectSqlTest.java | 41 +- .../sorm4j/util/sql/SqlKeywordTest.java | 69 +- .../util/table_def/TableDefinitionTest.java | 108 ++- .../net/sf/persist/tests/common/Simple.java | 21 +- .../net/sf/persist/tests/common/Simple01.java | 5 - .../net/sf/persist/tests/common/Simple02.java | 4 - .../net/sf/persist/tests/common/Simple03.java | 4 - .../net/sf/persist/tests/common/Simple04.java | 6 +- .../net/sf/persist/tests/common/Simple05.java | 3 - .../net/sf/persist/tests/common/Simple06.java | 4 +- .../net/sf/persist/tests/common/Simple07.java | 11 +- .../net/sf/persist/tests/common/Simple08.java | 7 +- .../net/sf/persist/tests/common/Simple09.java | 7 +- .../net/sf/persist/tests/common/Simple10.java | 2 - .../net/sf/persist/tests/common/Simple11.java | 3 - .../net/sf/persist/tests/common/Simple12.java | 3 - .../persist/tests/common/SimpleNoTable.java | 7 - .../tests/engine/framework/BeanMap.java | 9 +- .../tests/engine/framework/BeanTest.java | 110 ++- .../tests/engine/framework/BytesBlob.java | 5 +- .../engine/framework/DbEngineTestUtils.java | 37 +- .../tests/engine/framework/DynamicBean.java | 375 ++++------ .../tests/engine/framework/FieldMap.java | 18 +- .../tests/engine/framework/StringClob.java | 2 - .../sf/persist/tests/engine/h2/TestH2.java | 196 +++--- .../persist/tests/engine/mysql/TestMysql.java | 202 +++--- .../tests/engine/oracle/TestOracle.java | 192 ++--- .../sf/persist/tests/engine/package-info.java | 7 +- .../engine/postgresql/TestPostgreSQL.java | 190 +++-- .../tests/engine/sqlserver/TestSqlserver.java | 170 +++-- 229 files changed, 4994 insertions(+), 4214 deletions(-) diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmTransaction.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmTransaction.java index f59edb1a..b3d16d9c 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmTransaction.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmTransaction.java @@ -4,21 +4,17 @@ * An transaction with object relation mapping. * * @author nkjm - * */ public interface OrmTransaction extends OrmConnection { /** * Closes the {@link java.sql.Connection} associated with this instance. * - *

- * Note: If you do not explicitly commit in a opened transaction, it will be + *

Note: If you do not explicitly commit in a opened transaction, it will be * rolled back. * * @see java.sql.Connection#close() - * */ @Override void close(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/Sorm.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/Sorm.java index b5de55fe..ca4a346c 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/Sorm.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/Sorm.java @@ -16,21 +16,19 @@ * the function, after that closes the connection immediately. * * @author nkjm - * */ public interface Sorm extends Orm { /** * Create a {@link Sorm} object which uses {@link DataSource}. * - *

- * For example, + *

For example, * *

    *  *   
    *  *  *  *    * DataSource dataSource = org.h2.jdbcx.JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;","sa","");
-         * Sorm.create(dataSource);
-         *
+ * Sorm.create(dataSource); + *
* * @param dataSource * @return @@ -54,11 +52,10 @@ static Sorm create(DataSource dataSource, SormContext context) { /** * Creates a {@link Sorm} instance which uses the given {@link DriverManagerDataSource}. * - * If you want specified more precise configuration of database access, create {@link DataSource} - * yourself and use {@link #create(DataSource)} method. + *

If you want specified more precise configuration of database access, create {@link + * DataSource} yourself and use {@link #create(DataSource)} method. * - *

- * For example, + *

For example, * *

    * 
@@ -76,7 +73,7 @@ static Sorm create(String jdbcUrl) {
   /**
    * Creates an instance of {@link DriverManagerDataSource}
    *
-   * Example:
+   * 

Example: * *

    * Sorm.createDataSource("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;", null, null);
@@ -87,12 +84,11 @@ static Sorm create(String jdbcUrl) {
    * @param password
    * @return
    */
-  static DriverManagerDataSource createDataSource(String jdbcUrl, String username,
-      String password) {
+  static DriverManagerDataSource createDataSource(
+      String jdbcUrl, String username, String password) {
     return DriverManagerDataSource.create(jdbcUrl, username, password);
   }
 
-
   /**
    * Gets the default {@link SormContext} instance.
    *
@@ -102,7 +98,6 @@ static SormContext getDefaultContext() {
     return SormImpl.DEFAULT_CONTEXT;
   }
 
-
   /**
    * Accepts a {@link OrmConnection} handler for a task with object-relation mapping. The connection
    * will be closed after the process of handler.
@@ -114,8 +109,7 @@ static SormContext getDefaultContext() {
   /**
    * Accepts a {@link OrmTransaction} handler for a task with object-relation mapping.
    *
-   * 

- * Note: The transaction will be closed after the process of handler. The transaction will be + *

Note: The transaction will be closed after the process of handler. The transaction will be * rolled back if the transaction closes before commit. When an exception throws in the * transaction, the transaction will be rollback. * @@ -124,7 +118,6 @@ static SormContext getDefaultContext() { */ void acceptHandler(int isolationLevel, ConsumerHandler transactionHandler); - /** * Applies a {@link OrmConnection} handler for a task with object-relation mapping and gets the * result. The connection will be closed after the process of handler. @@ -135,18 +128,16 @@ static SormContext getDefaultContext() { */ R applyHandler(FunctionHandler connectionHandler); - /** * Applies a {@link OrmTransaction} handler for a task with object-relation mapping and gets the * result. - *

- * Note: The transaction will be closed after the process of handler. The transaction will be + * + *

Note: The transaction will be closed after the process of handler. The transaction will be * rolled back if the transaction closes before commit. When an exception throws in the * transaction, the transaction will be rolled back. * * @param isolationLevel * @param transactionHandler - * * @param * @return */ @@ -159,14 +150,12 @@ static SormContext getDefaultContext() { */ DataSource getDataSource(); - /** * Open {@link OrmConnection}. You should always use try-with-resources block to * ensure the database connection is released. * - *

- * You cold also use {@link Sorm#acceptHandler(ConsumerHandler)} or - * {@link Sorm#applyHandler(FunctionHandler)} . + *

You cold also use {@link Sorm#acceptHandler(ConsumerHandler)} or {@link + * Sorm#applyHandler(FunctionHandler)} . * * @return */ @@ -176,17 +165,14 @@ static SormContext getDefaultContext() { * Open {@link OrmTransaction}. You should always use try-with-resources block to ensure the * database connection is released. * - *

- * You could also use {@link Sorm#acceptHandler(int, ConsumerHandler)} or - * {@link Sorm#applyHandler(int, FunctionHandler)}. + *

You could also use {@link Sorm#acceptHandler(int, ConsumerHandler)} or {@link + * Sorm#applyHandler(int, FunctionHandler)}. * - *

- * Note: If you do not explicitly commit in a opened transaction, it will be + *

Note: If you do not explicitly commit in a opened transaction, it will be * rolled back. * - * @param isolationLevel {@link Connection#TRANSACTION_READ_COMMITTED}, - * {@link Connection#TRANSACTION_READ_UNCOMMITTED}, ...,and so on. - * + * @param isolationLevel {@link Connection#TRANSACTION_READ_COMMITTED}, {@link + * Connection#TRANSACTION_READ_UNCOMMITTED}, ...,and so on. * @return */ OrmTransaction open(int isolationLevel); @@ -211,5 +197,4 @@ static SormContext getDefaultContext() { */ @Experimental Table getTable(Class type, String tableName); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/Experimental.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/Experimental.java index 19da9da7..51f2bcfa 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/Experimental.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/Experimental.java @@ -10,6 +10,4 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) -public @interface Experimental { - -} +public @interface Experimental {} diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmColumn.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmColumn.java index 370b3843..0c54d20a 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmColumn.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmColumn.java @@ -5,15 +5,11 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Defines a column mapping to a field. - */ +/** Defines a column mapping to a field. */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface OrmColumn { - /** - * Name of the column mapped to the field. - */ + /** Name of the column mapped to the field. */ String value(); } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmColumnAliasPrefix.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmColumnAliasPrefix.java index 10ddca5e..03725f1a 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmColumnAliasPrefix.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmColumnAliasPrefix.java @@ -10,16 +10,12 @@ * Defines a prefix for field alias. When "name" field mapped to "name" column and the value of * {@link OrmColumnAliasPrefix}} is "customer", "customername" column also mapped to "name" field. * It is mainly designed for {@link Orm#readTupleList} method. - * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Experimental public @interface OrmColumnAliasPrefix { - /** - * Prefix for field alias. - */ + /** Prefix for field alias. */ String value(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmConstructor.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmConstructor.java index d1b40e5f..ea3abf4d 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmConstructor.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmConstructor.java @@ -13,9 +13,6 @@ @Experimental public @interface OrmConstructor { - /** - * Name of the columns. - */ + /** Name of the columns. */ String[] value(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmGetter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmGetter.java index 2731a785..f47e119e 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmGetter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmGetter.java @@ -5,16 +5,11 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Defines a getter method for mapping column to field. - */ +/** Defines a getter method for mapping column to field. */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) public @interface OrmGetter { - /** - * Name of the getter mapped to the field. - */ + /** Name of the getter mapped to the field. */ String value(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmIgnore.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmIgnore.java index 1aa6d703..2a65f804 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmIgnore.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmIgnore.java @@ -5,12 +5,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Defines an ignored field to map column. - */ - +/** Defines an ignored field to map column. */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.METHOD}) -public @interface OrmIgnore { - -} +public @interface OrmIgnore {} diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmRecord.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmRecord.java index 52485f43..7e38dd58 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmRecord.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmRecord.java @@ -5,13 +5,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Defines a record for mapping. - */ +/** Defines a record for mapping. */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) @Experimental -public @interface OrmRecord { - - -} +public @interface OrmRecord {} diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmSetter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmSetter.java index 09dfba82..c4492c28 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmSetter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmSetter.java @@ -5,17 +5,11 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Defines a setter method for mapping column to field. - */ +/** Defines a setter method for mapping column to field. */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) public @interface OrmSetter { - - /** - * Name of the setter mapped to the field. - */ + /** Name of the setter mapped to the field. */ String value(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmTable.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmTable.java index e68c18dd..bb909907 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmTable.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/annotation/OrmTable.java @@ -5,16 +5,11 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Defines a table mapping for a given class. - */ +/** Defines a table mapping for a given class. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface OrmTable { - /** - * Name of the table mapped to the class. - */ + /** Name of the table mapped to the class. */ String value(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ColumnMetaData.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ColumnMetaData.java index ca533e77..a2ad6d28 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ColumnMetaData.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ColumnMetaData.java @@ -7,11 +7,9 @@ * ColumnName name and data type for message. * * @author yuu_nkjm - * */ public final class ColumnMetaData implements Comparable { - private final String msg; private final String typeName; private final int dataType; @@ -21,9 +19,14 @@ public final class ColumnMetaData implements Comparable { private final String isGenerated; private final String name; - - public ColumnMetaData(String name, int dataType, String typeName, int ordinalPosition, - String isNullable, String isAutoIncremented, String isGenerated) { + public ColumnMetaData( + String name, + int dataType, + String typeName, + int ordinalPosition, + String isNullable, + String isAutoIncremented, + String isGenerated) { this.name = name; this.typeName = typeName; this.dataType = dataType; @@ -31,8 +34,18 @@ public ColumnMetaData(String name, int dataType, String typeName, int ordinalPos this.isNullable = isNullable; this.isAutoIncremented = isAutoIncremented; this.isGenerated = isGenerated; - Object[] params = {String.format("%02d", getOrdinalPosition()), getName(), getTypeName(), getDataType(), getIsNullable(), getIsAutoIncremented(), getIsGenerated()}; - this.msg = ParameterizedStringFormatter.LENGTH_256.format("{{}: {} [{}({})] [n={},a={},g={}]}", params); + Object[] params = { + String.format("%02d", getOrdinalPosition()), + getName(), + getTypeName(), + getDataType(), + getIsNullable(), + getIsAutoIncremented(), + getIsGenerated() + }; + this.msg = + ParameterizedStringFormatter.LENGTH_256.format( + "{{}: {} [{}({})] [n={},a={},g={}]}", params); } private int getDataType() { @@ -80,22 +93,22 @@ public String getName() { @Override public int hashCode() { - return Objects.hash(dataType, isAutoIncremented, isGenerated, isNullable, msg, name, - ordinalPosition, typeName); + return Objects.hash( + dataType, isAutoIncremented, isGenerated, isNullable, msg, name, ordinalPosition, typeName); } @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof ColumnMetaData)) - return false; + if (this == obj) return true; + if (!(obj instanceof ColumnMetaData)) return false; ColumnMetaData other = (ColumnMetaData) obj; - return dataType == other.dataType && Objects.equals(isAutoIncremented, other.isAutoIncremented) + return dataType == other.dataType + && Objects.equals(isAutoIncremented, other.isAutoIncremented) && Objects.equals(isGenerated, other.isGenerated) - && Objects.equals(isNullable, other.isNullable) && Objects.equals(msg, other.msg) - && Objects.equals(name, other.name) && ordinalPosition == other.ordinalPosition + && Objects.equals(isNullable, other.isNullable) + && Objects.equals(msg, other.msg) + && Objects.equals(name, other.name) + && ordinalPosition == other.ordinalPosition && Objects.equals(typeName, other.typeName); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ColumnName.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ColumnName.java index 0a2dd164..136bbb53 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ColumnName.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ColumnName.java @@ -6,7 +6,6 @@ * Value object of column. * * @author nkjm - * */ public class ColumnName implements Comparable { @@ -23,10 +22,8 @@ public int compareTo(ColumnName o) { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof ColumnName)) - return false; + if (this == obj) return true; + if (!(obj instanceof ColumnName)) return false; ColumnName other = (ColumnName) obj; return Objects.equals(name, other.name); } @@ -45,12 +42,9 @@ public int hashCode() { return Objects.hash(name); } - /** - * Uses {@link #getName()} when you want to get name. - */ + /** Uses {@link #getName()} when you want to get name. */ @Override public String toString() { return name; } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ConsumerHandler.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ConsumerHandler.java index 5af25081..33926477 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ConsumerHandler.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/ConsumerHandler.java @@ -5,7 +5,7 @@ /** * Interface for handling without a return value. * - * This interface is only designed for {@link Sorm} interface. + *

This interface is only designed for {@link Sorm} interface. * * @param */ diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/DriverManagerDataSource.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/DriverManagerDataSource.java index 2d64734a..34a97420 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/DriverManagerDataSource.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/DriverManagerDataSource.java @@ -12,9 +12,7 @@ * A database connection source wrapped a {@link DriverManager} * * @author nkjm - * */ - public final class DriverManagerDataSource implements DataSource { private final String jdbcUrl; @@ -33,7 +31,8 @@ public static DriverManagerDataSource create(String jdbcUrl, String username, St @Override public Connection getConnection() throws SQLException { - return username != null ? DriverManager.getConnection(jdbcUrl, username, password) + return username != null + ? DriverManager.getConnection(jdbcUrl, username, password) : DriverManager.getConnection(jdbcUrl); } @@ -76,5 +75,4 @@ public void setLoginTimeout(int seconds) throws SQLException { public int getLoginTimeout() throws SQLException { return DriverManager.getLoginTimeout(); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/JdbcTableMetaData.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/JdbcTableMetaData.java index 64e08413..6ea6c4d2 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/JdbcTableMetaData.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/JdbcTableMetaData.java @@ -28,5 +28,4 @@ public interface JdbcTableMetaData { boolean hasAutoGeneratedColumns(); boolean hasPrimaryKey(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/SormException.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/SormException.java index e2a7fa31..dafab271 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/SormException.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/SormException.java @@ -1,8 +1,6 @@ package org.nkjmlab.sorm4j.common; -/** - * Represents an exception thrown by Sorm4j. - */ +/** Represents an exception thrown by Sorm4j. */ public final class SormException extends RuntimeException { private static final long serialVersionUID = -3645955311944195665L; @@ -15,4 +13,3 @@ public SormException(String message, Throwable cause) { super(message, cause); } } - diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/TableMetaData.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/TableMetaData.java index 1b25fc5a..a219370e 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/TableMetaData.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/TableMetaData.java @@ -7,23 +7,16 @@ * An instance of this class contains table metadata. * * @author yuu_nkjm - * */ public interface TableMetaData extends JdbcTableMetaData { - /** - *

* Creates a list of column aliases. * - *

- * For example, if the "customer" table has "id" and "name" columns, and - * {@link OrmColumnAliasPrefix} is "c" returns - * "customer.id as cid, customer.name as cname". + *

For example, if the "customer" table has "id" and "name" columns, and {@link + * OrmColumnAliasPrefix} is "c" returns "customer.id as cid, customer.name as cname". * * @return column aliases (e.g. "customer.id as cid, customer.name as cname") */ - List getColumnAliases(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/Tuple.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/Tuple.java index 27cfa3a1..b59f6f7a 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/Tuple.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/common/Tuple.java @@ -6,7 +6,6 @@ * Represents a tuple of objects * * @author yuu_nkjm - * */ public final class Tuple { private Tuple() {} @@ -40,7 +39,6 @@ public T1 getT1() { return t1; } - @Override public String toString() { return "(" + getT1() + ")"; @@ -53,15 +51,11 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof Tuple1)) - return false; + if (this == obj) return true; + if (!(obj instanceof Tuple1)) return false; Tuple1 other = (Tuple1) obj; return Objects.equals(t1, other.t1); } - - } /** @@ -103,22 +97,17 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (!(obj instanceof Tuple2)) - return false; + if (this == obj) return true; + if (!super.equals(obj)) return false; + if (!(obj instanceof Tuple2)) return false; Tuple2 other = (Tuple2) obj; return Objects.equals(t2, other.t2); } - } /** * Represents a tuple of three objects * * @author yuu_nkjm - * * @param * @param * @param @@ -132,7 +121,6 @@ public static class Tuple3 extends Tuple2 { this.t3 = t3; } - /** * Gets a t3. * @@ -142,13 +130,11 @@ public T3 getT3() { return t3; } - @Override public String toString() { return "(" + getT1() + ", " + getT2() + ", " + getT3() + ")"; } - @Override public int hashCode() { final int prime = 31; @@ -157,18 +143,13 @@ public int hashCode() { return result; } - @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (!(obj instanceof Tuple3)) - return false; + if (this == obj) return true; + if (!super.equals(obj)) return false; + if (!(obj instanceof Tuple3)) return false; Tuple3 other = (Tuple3) obj; return Objects.equals(t3, other.t3); } - } } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnToFieldAccessorMapper.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnToFieldAccessorMapper.java index e1ccd8a2..6c90759f 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnToFieldAccessorMapper.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnToFieldAccessorMapper.java @@ -6,10 +6,8 @@ * A mapper from column to field name. * * @author nkjm - * */ -public interface ColumnToFieldAccessorMapper extends NameToFieldAccessorMapper{ - +public interface ColumnToFieldAccessorMapper extends NameToFieldAccessorMapper { /** * Gets column alias prefix based on {@link OrmColumnAliasPrefix} annotation or the given object @@ -19,5 +17,4 @@ public interface ColumnToFieldAccessorMapper extends NameToFieldAccessorMapper{ * @return */ String getColumnAliasPrefix(Class objectClass); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToJavaObjectConverter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToJavaObjectConverter.java index f206afb9..0d88da61 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToJavaObjectConverter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToJavaObjectConverter.java @@ -11,13 +11,13 @@ public interface ColumnValueToJavaObjectConverter { * Reads a column from the current row in the provided {@link java.sql.ResultSet} and returns an * instance of the specified Java {@link java.lang.Class} containing the values read. * - * This method is mainly used for converting the result of query. i.e. Convert from Sql to Java by - * the specified class. + *

This method is mainly used for converting the result of query. i.e. Convert from Sql to Java + * by the specified class. * - * This method is used while converting {@link java.sql.ResultSet} rows to objects. The class type - * is the field type in the target bean. + *

This method is used while converting {@link java.sql.ResultSet} rows to objects. The class + * type is the field type in the target bean. * - * null's will be respected for any non-native types. This means that if a field is of type + *

null's will be respected for any non-native types. This means that if a field is of type * Integer it will be able to receive a null value from the ResultSet; on the other hand, if a * field is of type int it will receive 0 for a null value from the {@link java.sql.ResultSet}. * @@ -25,12 +25,8 @@ public interface ColumnValueToJavaObjectConverter { * @param columnIndex column index in the result set (starting with 1) * @param columnType * @param toType {@link java.lang.Class} of the object to be returned - * * @throws SQLException - * */ Object convertTo(ResultSet resultSet, int columnIndex, int columnType, Class toType) throws SQLException; - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToJavaObjectConverters.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToJavaObjectConverters.java index 5f992fb1..cabf7cd6 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToJavaObjectConverters.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToJavaObjectConverters.java @@ -3,12 +3,10 @@ import java.sql.ResultSet; import java.sql.SQLException; - /** * Convert {@link ResultSet} from database to specified objects. * * @author nkjm - * */ public interface ColumnValueToJavaObjectConverters { @@ -16,13 +14,13 @@ public interface ColumnValueToJavaObjectConverters { * Reads a column from the current row in the provided {@link java.sql.ResultSet} and returns an * instance of the specified Java {@link java.lang.Class} containing the values read. * - * This method is mainly used for converting the result of query. i.e. Convert from Sql to Java by - * the specified class. + *

This method is mainly used for converting the result of query. i.e. Convert from Sql to Java + * by the specified class. * - * This method is used while converting {@link java.sql.ResultSet} rows to objects. The class type - * is the field type in the target bean. + *

This method is used while converting {@link java.sql.ResultSet} rows to objects. The class + * type is the field type in the target bean. * - * null's will be respected for any non-native types. This means that if a field is of type + *

null's will be respected for any non-native types. This means that if a field is of type * Integer it will be able to receive a null value from the ResultSet; on the other hand, if a * field is of type int it will receive 0 for a null value from the {@link java.sql.ResultSet}. * @@ -30,9 +28,7 @@ public interface ColumnValueToJavaObjectConverters { * @param columnIndex column index in the result set (starting with 1) * @param columnType * @param toType {@link java.lang.Class} of the object to be returned - * * @throws SQLException - * */ T convertTo(ResultSet resultSet, int columnIndex, int columnType, Class toType); @@ -40,10 +36,7 @@ public interface ColumnValueToJavaObjectConverters { * Returns the given type could be converted to Java object or not. * * @param objectClass - * * @return */ - boolean isSupportedReturnedType(Class objectClass); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToMapValueConverters.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToMapValueConverters.java index 74ec73c5..723bed89 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToMapValueConverters.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/ColumnValueToMapValueConverters.java @@ -10,10 +10,10 @@ public interface ColumnValueToMapValueConverters { * Reads a column from the current row in the provided {@link java.sql.ResultSet} and returns an * instance of the specified Java {@link SQLType} containing the values read. * - * This method is mainly used for "SEARCH SQL AND READ TO MAP". i.e. Convert from SQL to Java by - * the SQL type. + *

This method is mainly used for "SEARCH SQL AND READ TO MAP". i.e. Convert from SQL to Java + * by the SQL type. * - * This method is used while converting {@link java.sql.ResultSet} rows to Map. + *

This method is used while converting {@link java.sql.ResultSet} rows to Map. * * @param resultSet * @param column @@ -22,5 +22,4 @@ public interface ColumnValueToMapValueConverters { * @throws SQLException */ Object convertToValue(ResultSet resultSet, int column, int sqlType) throws SQLException; - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnToFieldAccessorMapper.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnToFieldAccessorMapper.java index 2078e07d..d2c14e74 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnToFieldAccessorMapper.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnToFieldAccessorMapper.java @@ -1,4 +1,3 @@ - package org.nkjmlab.sorm4j.context; import static java.util.Objects.*; @@ -24,12 +23,9 @@ * Default implementation of {@link ColumnToFieldAccessorMapper} * * @author nkjm - * */ - public final class DefaultColumnToFieldAccessorMapper implements ColumnToFieldAccessorMapper { - private static final Set IGNORE_METHODS = Set.of("NOTIFY", "NOTIFYALL", "WAIT", "TOSTRING", "HASHCODE"); @@ -47,14 +43,18 @@ public Map createMapping(Class objectClass) { Map ret = new HashMap<>(); for (String acceptableColName : acceptableColumnNames) { Field f = - nonNull(annotatedFields.get(acceptableColName)) ? annotatedFields.get(acceptableColName) + nonNull(annotatedFields.get(acceptableColName)) + ? annotatedFields.get(acceptableColName) : fields.get(acceptableColName); Method g = - nonNull(annotatedGetters.get(acceptableColName)) ? annotatedGetters.get(acceptableColName) - : nonNull(getters.get(acceptableColName)) ? getters.get(acceptableColName) + nonNull(annotatedGetters.get(acceptableColName)) + ? annotatedGetters.get(acceptableColName) + : nonNull(getters.get(acceptableColName)) + ? getters.get(acceptableColName) : allMethods.get(acceptableColName); Method s = - nonNull(annotatedSetters.get(acceptableColName)) ? annotatedSetters.get(acceptableColName) + nonNull(annotatedSetters.get(acceptableColName)) + ? annotatedSetters.get(acceptableColName) : setters.get(acceptableColName); if (f == null && (g == null && s == null)) { @@ -68,14 +68,19 @@ public Map createMapping(Class objectClass) { private Map extractedMethodStartWith(Class objectClass, String prefix) { Class ignoreAnn = OrmIgnore.class; return Arrays.stream(objectClass.getMethods()) - .filter(m -> Objects.isNull(m.getAnnotation(ignoreAnn)) - && !Modifier.isStatic(m.getModifiers()) && m.getName().length() > prefix.length() - && m.getName().substring(0, prefix.length()).equals(prefix)) - .collect(Collectors.toMap(m -> toCanonicalCase(m.getName().substring(prefix.length())), - m -> m, (v1, v2) -> v2)); + .filter( + m -> + Objects.isNull(m.getAnnotation(ignoreAnn)) + && !Modifier.isStatic(m.getModifiers()) + && m.getName().length() > prefix.length() + && m.getName().substring(0, prefix.length()).equals(prefix)) + .collect( + Collectors.toMap( + m -> toCanonicalCase(m.getName().substring(prefix.length())), + m -> m, + (v1, v2) -> v2)); } - private static Map getAllFields(final Class objectClass) { Class ignoreAnn = OrmIgnore.class; return Arrays.stream(objectClass.getFields()) @@ -84,7 +89,6 @@ private static Map getAllFields(final Class objectClass) { .collect(Collectors.toMap(f -> toCanonicalCase(f.getName()), f -> f)); } - private Map getAllGetters(Class objectClass) { return extractedMethodStartWith(objectClass, "get").entrySet().stream() .filter(e -> nonNull(isValidGetter(e.getValue()))) @@ -112,11 +116,11 @@ private Map getAnnotatatedSettersMap(Class objectClass) { private Map getAnnotatedFieldsMap(Class objectClass) { Class ann = OrmColumn.class; - return Arrays.stream(objectClass.getFields()).filter(f -> Objects.nonNull(f.getAnnotation(ann))) + return Arrays.stream(objectClass.getFields()) + .filter(f -> Objects.nonNull(f.getAnnotation(ann))) .collect(Collectors.toMap(f -> toCanonicalCase(f.getAnnotation(ann).value()), f -> f)); } - private Map getAnnotatedGettersMap(Class objectClass) { Class ann = OrmGetter.class; return Arrays.stream(objectClass.getMethods()) @@ -125,15 +129,18 @@ private Map getAnnotatedGettersMap(Class objectClass) { } private Method isValidGetter(Method getter) { - return (getter == null || getter.getName().equals("getClass") || getter.getParameterCount() != 0 - || getter.getReturnType() == void.class) ? null : getter; + return (getter == null + || getter.getName().equals("getClass") + || getter.getParameterCount() != 0 + || getter.getReturnType() == void.class) + ? null + : getter; } private Method isValidSetter(Method setter) { return (setter == null || setter.getParameterCount() != 1) ? null : setter; } - private Set createAcceptableColumnNames(Class objectClass) { Set acceptableColumnNames = new HashSet<>(); acceptableColumnNames.addAll(getAllFields(objectClass).keySet()); @@ -150,8 +157,8 @@ private Set createAcceptableColumnNames(Class objectClass) { /** * Gets column alias prefix based on {@link OrmColumnAliasPrefix} annotation. If the give object - * class has no {@link OrmColumnAliasPrefix} annotation, the column alias prefix is - * objectClass.getSimpleName() + "DOT" + * class has no {@link OrmColumnAliasPrefix} annotation, the column alias prefix is + * objectClass.getSimpleName() + "DOT" * * @param objectClass * @return @@ -159,8 +166,7 @@ private Set createAcceptableColumnNames(Class objectClass) { @Override public String getColumnAliasPrefix(Class objectClass) { return Optional.ofNullable(objectClass.getAnnotation(OrmColumnAliasPrefix.class)) - .map(a -> a.value()).orElse(objectClass.getSimpleName() + "DOT"); + .map(a -> a.value()) + .orElse(objectClass.getSimpleName() + "DOT"); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToJavaObjectConverters.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToJavaObjectConverters.java index e55619be..12d57c45 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToJavaObjectConverters.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToJavaObjectConverters.java @@ -21,13 +21,10 @@ * Default implementation of {@link ColumnValueToJavaObjectConverters} * * @author nkjm - * */ - public final class DefaultColumnValueToJavaObjectConverters implements ColumnValueToJavaObjectConverters { - private final Map, ColumnValueToJavaObjectConverter> convertersHitCache; private final List converters; private final Set> supportedReturnedTypes; @@ -48,39 +45,65 @@ public Object convertTo(ResultSet resultSet, int columnIndex, int columnType, Cl } } - private static final Set> DEFAULT_SUPPORTED_RETURNED_TYPES = Set.of(boolean.class, - byte.class, short.class, int.class, long.class, float.class, double.class, char.class, - java.io.InputStream.class, java.io.Reader.class, java.lang.Boolean.class, - java.lang.Byte.class, java.lang.Short.class, java.lang.Integer.class, java.lang.Long.class, - java.lang.Float.class, java.lang.Double.class, java.lang.Character.class, - java.lang.String.class, java.lang.Object.class, java.math.BigDecimal.class, - java.sql.Clob.class, java.sql.Blob.class, java.sql.Date.class, java.sql.Time.class, - java.sql.Timestamp.class, java.time.Instant.class, java.time.LocalDate.class, - java.time.LocalTime.class, java.time.LocalDateTime.class, java.time.OffsetTime.class, - java.time.OffsetDateTime.class, java.util.Date.class, java.util.UUID.class, - org.nkjmlab.sorm4j.util.datatype.JsonByte.class, - org.nkjmlab.sorm4j.util.datatype.GeometryString.class); + private static final Set> DEFAULT_SUPPORTED_RETURNED_TYPES = + Set.of( + boolean.class, + byte.class, + short.class, + int.class, + long.class, + float.class, + double.class, + char.class, + java.io.InputStream.class, + java.io.Reader.class, + java.lang.Boolean.class, + java.lang.Byte.class, + java.lang.Short.class, + java.lang.Integer.class, + java.lang.Long.class, + java.lang.Float.class, + java.lang.Double.class, + java.lang.Character.class, + java.lang.String.class, + java.lang.Object.class, + java.math.BigDecimal.class, + java.sql.Clob.class, + java.sql.Blob.class, + java.sql.Date.class, + java.sql.Time.class, + java.sql.Timestamp.class, + java.time.Instant.class, + java.time.LocalDate.class, + java.time.LocalTime.class, + java.time.LocalDateTime.class, + java.time.OffsetTime.class, + java.time.OffsetDateTime.class, + java.util.Date.class, + java.util.UUID.class, + org.nkjmlab.sorm4j.util.datatype.JsonByte.class, + org.nkjmlab.sorm4j.util.datatype.GeometryString.class); private final Map, Boolean> supportedTypeCache = new ConcurrentHashMap<>(); @Override public boolean isSupportedReturnedType(Class objectClass) { - return supportedTypeCache.computeIfAbsent(objectClass, - key -> supportedReturnedTypes.contains(objectClass) || (objectClass.isArray() - && supportedReturnedTypes - .contains(ArrayUtils.getInternalComponentType(objectClass.getComponentType())) - || getHitConverter(objectClass) != DUMMY_CONVERTER)); + return supportedTypeCache.computeIfAbsent( + objectClass, + key -> + supportedReturnedTypes.contains(objectClass) + || (objectClass.isArray() + && supportedReturnedTypes.contains( + ArrayUtils.getInternalComponentType(objectClass.getComponentType())) + || getHitConverter(objectClass) != DUMMY_CONVERTER)); } - - /** - * * @param converters the converter which corresponding to the key class is applied to the column - * value. + * value. */ - public DefaultColumnValueToJavaObjectConverters(Set> supportedReturnedTypes, - ColumnValueToJavaObjectConverter... converters) { + public DefaultColumnValueToJavaObjectConverters( + Set> supportedReturnedTypes, ColumnValueToJavaObjectConverter... converters) { this.supportedReturnedTypes = supportedReturnedTypes; this.converters = Arrays.asList(converters); this.convertersHitCache = @@ -99,16 +122,23 @@ public T convertTo(ResultSet resultSet, int columnIndex, int columnType, Cla } catch (Exception e) { String tableName = Try.getOrElse(() -> resultSet.getMetaData().getTableName(columnIndex), "UNKNOWN_TABLE"); - String columnLabel = Try.getOrElse(() -> resultSet.getMetaData().getColumnLabel(columnIndex), - "UNKNOWN_COLUMN"); - Object[] params = {tableName, columnLabel, columnIndex, JdbcTypeUtils.convert(columnType), toType}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("tableName=[{}], columnLabel=[{}], columnIndex=[{}], columnType=[{}], toType=[{}]", params), e); + String columnLabel = + Try.getOrElse( + () -> resultSet.getMetaData().getColumnLabel(columnIndex), "UNKNOWN_COLUMN"); + Object[] params = { + tableName, columnLabel, columnIndex, JdbcTypeUtils.convert(columnType), toType + }; + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "tableName=[{}], columnLabel=[{}], columnIndex=[{}], columnType=[{}], toType=[{}]", + params), + e); } } @SuppressWarnings({"rawtypes", "unchecked"}) - private Object convertToHelper(ResultSet resultSet, int columnIndex, int columnType, - Class toType) throws SQLException { + private Object convertToHelper( + ResultSet resultSet, int columnIndex, int columnType, Class toType) throws SQLException { final ColumnValueToJavaObjectConverter converter = getHitConverter(toType); if (!converter.equals(DUMMY_CONVERTER)) { @@ -118,53 +148,61 @@ private Object convertToHelper(ResultSet resultSet, int columnIndex, int columnT switch (toType.getName()) { case "boolean": return resultSet.getBoolean(columnIndex); - case "java.lang.Boolean": { - final boolean ret = resultSet.getBoolean(columnIndex); - return (!ret && resultSet.wasNull()) ? null : ret; - } + case "java.lang.Boolean": + { + final boolean ret = resultSet.getBoolean(columnIndex); + return (!ret && resultSet.wasNull()) ? null : ret; + } case "byte": return resultSet.getByte(columnIndex); - case "java.lang.Byte": { - final byte ret = resultSet.getByte(columnIndex); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case "java.lang.Byte": + { + final byte ret = resultSet.getByte(columnIndex); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case "short": return resultSet.getShort(columnIndex); - case "java.lang.Short": { - final short ret = resultSet.getShort(columnIndex); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case "java.lang.Short": + { + final short ret = resultSet.getShort(columnIndex); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case "int": return resultSet.getInt(columnIndex); - case "java.lang.Integer": { - final int ret = resultSet.getInt(columnIndex); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case "java.lang.Integer": + { + final int ret = resultSet.getInt(columnIndex); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case "long": return resultSet.getLong(columnIndex); - case "java.lang.Long": { - final long ret = resultSet.getLong(columnIndex); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case "java.lang.Long": + { + final long ret = resultSet.getLong(columnIndex); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case "float": return resultSet.getFloat(columnIndex); - case "java.lang.Float": { - final float ret = resultSet.getFloat(columnIndex); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case "java.lang.Float": + { + final float ret = resultSet.getFloat(columnIndex); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case "double": return resultSet.getDouble(columnIndex); - case "java.lang.Double": { - final double ret = resultSet.getDouble(columnIndex); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case "java.lang.Double": + { + final double ret = resultSet.getDouble(columnIndex); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case "java.lang.String": return resultSet.getString(columnIndex); case "java.lang.Character": - case "char": { - final String str = resultSet.getString(columnIndex); - return (str == null || str.length() == 0) ? null : str.charAt(0); - } + case "char": + { + final String str = resultSet.getString(columnIndex); + return (str == null || str.length() == 0) ? null : str.charAt(0); + } case "java.lang.Object": return resultSet.getObject(columnIndex); case "java.io.InputStream": @@ -202,49 +240,63 @@ private Object convertToHelper(ResultSet resultSet, int columnIndex, int columnT try { return Enum.valueOf((Class) toType, str); } catch (Exception e) { - String tableName = Try.getOrElse( - () -> resultSet.getMetaData().getTableName(columnIndex), "UNKNOWN_TABLE"); - String columnLabel = Try.getOrElse( - () -> resultSet.getMetaData().getColumnLabel(columnIndex), "UNKNOWN_COLUMN"); + String tableName = + Try.getOrElse( + () -> resultSet.getMetaData().getTableName(columnIndex), "UNKNOWN_TABLE"); + String columnLabel = + Try.getOrElse( + () -> resultSet.getMetaData().getColumnLabel(columnIndex), "UNKNOWN_COLUMN"); Object[] params = {str, JDBCType.valueOf(columnType), toType, tableName, columnLabel}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("Could not convert [{}] in column [{}] to Enum [{}], tableName=[{}], columnLabel=[{}]", params), e); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Could not convert [{}] in column [{}] to Enum [{}], tableName=[{}], columnLabel=[{}]", + params), + e); } } else if (toType.isArray()) { if (toType.getComponentType().getName().equals("byte")) { return resultSet.getBytes(columnIndex); } try { - return ArrayUtils.convertSqlArrayToArray(toType.getComponentType(), - resultSet.getArray(columnIndex)); + return ArrayUtils.convertSqlArrayToArray( + toType.getComponentType(), resultSet.getArray(columnIndex)); } catch (Exception e) { - String tableName = Try.getOrElse( - () -> resultSet.getMetaData().getTableName(columnIndex), "UNKNOWN_TABLE"); - String columnLabel = Try.getOrElse( - () -> resultSet.getMetaData().getColumnLabel(columnIndex), "UNKNOWN_COLUMN"); + String tableName = + Try.getOrElse( + () -> resultSet.getMetaData().getTableName(columnIndex), "UNKNOWN_TABLE"); + String columnLabel = + Try.getOrElse( + () -> resultSet.getMetaData().getColumnLabel(columnIndex), "UNKNOWN_COLUMN"); Object[] params = {JdbcTypeUtils.convert(columnType), toType, tableName, columnLabel}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("Could not convert column [{}] to array [{}], tableName=[{}], columnLabel=[{}]", params), e); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Could not convert column [{}] to array [{}], tableName=[{}], columnLabel=[{}]", + params), + e); } } else { return resultSet.getObject(columnIndex, toType); } } - } - private ColumnValueToJavaObjectConverter getHitConverter(Class toType) { if (converters.isEmpty()) { return DUMMY_CONVERTER; } - return convertersHitCache.computeIfAbsent(toType, key -> converters.stream().filter(conv -> { - try { - return conv.test(toType); - } catch (SQLException e) { - throw Try.rethrow(e); - } - }).findFirst().orElse(DUMMY_CONVERTER)); + return convertersHitCache.computeIfAbsent( + toType, + key -> + converters.stream() + .filter( + conv -> { + try { + return conv.test(toType); + } catch (SQLException e) { + throw Try.rethrow(e); + } + }) + .findFirst() + .orElse(DUMMY_CONVERTER)); } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToMapValueConverters.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToMapValueConverters.java index 69905449..83a131f3 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToMapValueConverters.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToMapValueConverters.java @@ -6,7 +6,8 @@ import java.util.Collections; import java.util.Map; -public final class DefaultColumnValueToMapValueConverters implements ColumnValueToMapValueConverters { +public final class DefaultColumnValueToMapValueConverters + implements ColumnValueToMapValueConverters { private final Map converters; @@ -23,10 +24,10 @@ public DefaultColumnValueToMapValueConverters( * Reads a column from the current row in the provided {@link java.sql.ResultSet} and returns an * instance of the specified Java {@link SQLType} containing the values read. * - * This method is mainly used for "SEARCH SQL AND READ TO MAP". i.e. Convert from SQL to Java by - * the SQL type. + *

This method is mainly used for "SEARCH SQL AND READ TO MAP". i.e. Convert from SQL to Java + * by the SQL type. * - * This method is used while converting {@link java.sql.ResultSet} rows to Map. + *

This method is used while converting {@link java.sql.ResultSet} rows to Map. * * @param resultSet * @param column @@ -44,20 +45,22 @@ public Object convertToValue(ResultSet resultSet, int column, int sqlType) throw switch (sqlType) { case java.sql.Types.ARRAY: return resultSet.getArray(column).getArray(); - case java.sql.Types.BIGINT: { - final long ret = resultSet.getLong(column); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case java.sql.Types.BIGINT: + { + final long ret = resultSet.getLong(column); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case java.sql.Types.BINARY: case java.sql.Types.BLOB: case java.sql.Types.VARBINARY: case java.sql.Types.LONGVARBINARY: return resultSet.getBytes(column); case java.sql.Types.BIT: - case java.sql.Types.BOOLEAN: { - final boolean ret = resultSet.getBoolean(column); - return (!ret && resultSet.wasNull()) ? null : ret; - } + case java.sql.Types.BOOLEAN: + { + final boolean ret = resultSet.getBoolean(column); + return (!ret && resultSet.wasNull()) ? null : ret; + } case java.sql.Types.CHAR: case java.sql.Types.CLOB: case java.sql.Types.LONGVARCHAR: @@ -71,38 +74,43 @@ public Object convertToValue(ResultSet resultSet, int column, int sqlType) throw case java.sql.Types.NUMERIC: return resultSet.getBigDecimal(column); case java.sql.Types.REAL: - case java.sql.Types.DOUBLE: { - final double ret = resultSet.getDouble(column); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } - case java.sql.Types.FLOAT: { - final float ret = resultSet.getFloat(column); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } - case java.sql.Types.INTEGER: { - final int ret = resultSet.getInt(column); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case java.sql.Types.DOUBLE: + { + final double ret = resultSet.getDouble(column); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } + case java.sql.Types.FLOAT: + { + final float ret = resultSet.getFloat(column); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } + case java.sql.Types.INTEGER: + { + final int ret = resultSet.getInt(column); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case java.sql.Types.NULL: return null; case java.sql.Types.REF: return resultSet.getRef(column); case java.sql.Types.ROWID: return resultSet.getRowId(column); - case java.sql.Types.SMALLINT: { - final short ret = (short) resultSet.getInt(column); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case java.sql.Types.SMALLINT: + { + final short ret = (short) resultSet.getInt(column); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case java.sql.Types.TIME: return resultSet.getTime(column); case java.sql.Types.TIMESTAMP: return resultSet.getTimestamp(column); case java.sql.Types.TIMESTAMP_WITH_TIMEZONE: return resultSet.getObject(column); - case java.sql.Types.TINYINT: { - final byte ret = resultSet.getByte(column); - return (ret == 0 && resultSet.wasNull()) ? null : ret; - } + case java.sql.Types.TINYINT: + { + final byte ret = resultSet.getByte(column); + return (ret == 0 && resultSet.wasNull()) ? null : ret; + } case java.sql.Types.JAVA_OBJECT: case java.sql.Types.OTHER: return resultSet.getObject(column); diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultPreparedStatementSupplier.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultPreparedStatementSupplier.java index ab32db1e..0ce73951 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultPreparedStatementSupplier.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultPreparedStatementSupplier.java @@ -9,16 +9,13 @@ public final class DefaultPreparedStatementSupplier implements PreparedStatement public DefaultPreparedStatementSupplier() {} @Override - public PreparedStatement prepareStatement(Connection connection, String sql, - String[] autoGeneratedColumnsArray) throws SQLException { + public PreparedStatement prepareStatement( + Connection connection, String sql, String[] autoGeneratedColumnsArray) throws SQLException { return connection.prepareStatement(sql, autoGeneratedColumnsArray); } - @Override public PreparedStatement prepareStatement(Connection connection, String sql) throws SQLException { return connection.prepareStatement(sql); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetter.java index 3e723b9d..19b35768 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetter.java @@ -17,15 +17,12 @@ * Default implementation of {@link SqlParametersSetter} * * @author nkjm - * */ - public final class DefaultSqlParametersSetter implements SqlParametersSetter { private final List setters; private final Map, SqlParameterSetter> settersHitCache; - private static final DummySetter DUMMY_SETTER = new DummySetter(); private static final class DummySetter implements SqlParameterSetter { @@ -36,15 +33,11 @@ public boolean test(PreparedStatement stmt, int parameterIndex, Object parameter return false; } - @Override public void setParameter(PreparedStatement stmt, int parameterIndex, Object parameter) throws SQLException {} - } - - public DefaultSqlParametersSetter(SqlParameterSetter... setters) { this.setters = Arrays.asList(setters); this.settersHitCache = @@ -64,18 +57,16 @@ public void setParameters(PreparedStatement stmt, Object... parameters) throws S /** * Sets a parameter into the given prepared statement. i.e. Convert from java objects to SQL. * - * TIME - *

- * In JDBC this data type is mapped to java.sql.Time. java.time.LocalTime is also supported and + *

TIME + * + *

In JDBC this data type is mapped to java.sql.Time. java.time.LocalTime is also supported and * recommended. See Data * Types. * * @param stmt {@link java.sql.PreparedStatement} to have parameters set into * @param parameter parameters values - * * @throws SQLException - * */ private void setParameter(PreparedStatement stmt, int parameterIndex, Object parameter) throws SQLException { @@ -88,13 +79,20 @@ private void setParameter(PreparedStatement stmt, int parameterIndex, Object par final Class type = parameter.getClass(); if (!setters.isEmpty()) { final SqlParameterSetter setter = - settersHitCache.computeIfAbsent(type, key -> setters.stream().filter(_setter -> { - try { - return _setter.test(stmt, parameterIndex, parameter); - } catch (SQLException e) { - throw Try.rethrow(e); - } - }).findFirst().orElse(DUMMY_SETTER)); + settersHitCache.computeIfAbsent( + type, + key -> + setters.stream() + .filter( + _setter -> { + try { + return _setter.test(stmt, parameterIndex, parameter); + } catch (SQLException e) { + throw Try.rethrow(e); + } + }) + .findFirst() + .orElse(DUMMY_SETTER)); if (!setter.equals(DUMMY_SETTER)) { setter.setParameter(stmt, parameterIndex, parameter); @@ -102,7 +100,6 @@ private void setParameter(PreparedStatement stmt, int parameterIndex, Object par } } - switch (type.getName()) { case "java.lang.Boolean": case "boolean": @@ -162,11 +159,12 @@ private void setParameter(PreparedStatement stmt, int parameterIndex, Object par stmt.setObject(parameterIndex, parameter); return; case "org.nkjmlab.sorm4j.util.datatype.JsonByte": - stmt.setObject(parameterIndex, - ((org.nkjmlab.sorm4j.util.datatype.JsonByte) parameter).getBytes()); + stmt.setObject( + parameterIndex, ((org.nkjmlab.sorm4j.util.datatype.JsonByte) parameter).getBytes()); return; case "org.nkjmlab.sorm4j.util.datatype.GeometryString": - stmt.setString(parameterIndex, + stmt.setString( + parameterIndex, ((org.nkjmlab.sorm4j.util.datatype.GeometryString) parameter).getText()); return; default: @@ -187,10 +185,8 @@ private void setParameter(PreparedStatement stmt, int parameterIndex, Object par stmt.setObject(parameterIndex, parameter); } } - } - /** * Treats array. * @@ -199,21 +195,22 @@ private void setParameter(PreparedStatement stmt, int parameterIndex, Object par * @param parameter * @throws SQLException */ - private void procArray(Class compType, PreparedStatement stmt, int parameterIndex, - Object parameter) throws SQLException { + private void procArray( + Class compType, PreparedStatement stmt, int parameterIndex, Object parameter) + throws SQLException { String typeName = compType.getName(); if (typeName.equals("byte")) { stmt.setBytes(parameterIndex, (byte[]) parameter); } else if (typeName.contains("[")) { - stmt.setArray(parameterIndex, stmt.getConnection().createArrayOf("java_object", - convertToObjectArray((Object[]) parameter))); + stmt.setArray( + parameterIndex, + stmt.getConnection() + .createArrayOf("java_object", convertToObjectArray((Object[]) parameter))); } else { stmt.setArray(parameterIndex, toSqlArray(typeName, stmt.getConnection(), parameter)); } } - - static java.sql.Array toSqlArray(String typeName, Connection conn, Object parameter) throws SQLException { switch (typeName) { @@ -240,6 +237,4 @@ static java.sql.Array toSqlArray(String typeName, Connection conn, Object parame return conn.createArrayOf("java_object", (Object[]) parameter); } } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableMetaDataParser.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableMetaDataParser.java index ec120d41..48189ea0 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableMetaDataParser.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableMetaDataParser.java @@ -8,9 +8,7 @@ import org.nkjmlab.sorm4j.common.ColumnMetaData; public final class DefaultTableMetaDataParser implements TableMetaDataParser { - /** - * @see DatabaseMetaData#getColumns(String, String, String, String) - */ + /** @see DatabaseMetaData#getColumns(String, String, String, String) */ @Override public List getAutoGeneratedColumns(DatabaseMetaData metaData, String tableName) throws SQLException { @@ -43,15 +41,20 @@ public List getColumnsMetaData(DatabaseMetaData metaData, String String isNullable = resultSet.getString(18); String isAutoIncremented = resultSet.getString(23); String isGenerated = resultSet.getString(24); - columnsList.add(new ColumnMetaData(columnName, dataType, typeName, ordinalPosition, - isNullable, isAutoIncremented, isGenerated)); + columnsList.add( + new ColumnMetaData( + columnName, + dataType, + typeName, + ordinalPosition, + isNullable, + isAutoIncremented, + isGenerated)); } return columnsList; } } - - @Override public List getPrimaryKeys(DatabaseMetaData metaData, String tableName) throws SQLException { @@ -77,7 +80,4 @@ private String getSchemaPattern(DatabaseMetaData metaData) throws SQLException { // oracle expects a pattern such as "%" to work return "Oracle".equalsIgnoreCase(metaData.getDatabaseProductName()) ? "%" : null; } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableNameMapper.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableNameMapper.java index 076a13d1..ee680f96 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableNameMapper.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableNameMapper.java @@ -15,30 +15,32 @@ * Default implementation of {@link TableNameMapper} * * @author nkjm - * */ - public final class DefaultTableNameMapper implements TableNameMapper { private static final String ERROR_MESSAGE = "[{}] does not match any existing table in the database. Use @{} annotation or rename the class. Table name candidates were {}"; - @Override public String getTableName(String tableName, DatabaseMetaData metaData) { List candidates = List.of(tableName); Object[] params = {tableName, OrmTable.class.getSimpleName(), candidates}; - return convertToExactTableName(metaData, candidates).orElseThrow(() -> new SormException( - ParameterizedStringFormatter.LENGTH_256.format(ERROR_MESSAGE, params))); + return convertToExactTableName(metaData, candidates) + .orElseThrow( + () -> + new SormException( + ParameterizedStringFormatter.LENGTH_256.format(ERROR_MESSAGE, params))); } - @Override public String getTableName(Class objectClass, DatabaseMetaData metaData) { List candidates = guessTableNameCandidates(objectClass); Object[] params = {objectClass.getName(), OrmTable.class.getSimpleName(), candidates}; return convertToExactTableName(metaData, candidates) - .orElseThrow(() -> new SormException(ParameterizedStringFormatter.LENGTH_256.format(ERROR_MESSAGE, params))); + .orElseThrow( + () -> + new SormException( + ParameterizedStringFormatter.LENGTH_256.format(ERROR_MESSAGE, params))); } /** @@ -59,17 +61,20 @@ private List guessTableNameCandidates(Class objectClass) { String className = objectClass.getSimpleName(); String cannonicalClassName = toCanonicalCase(className); - List candidates = new ArrayList<>(List.of(cannonicalClassName, - toCanonicalCase(cannonicalClassName + "S"), toCanonicalCase(cannonicalClassName + "ES"))); + List candidates = + new ArrayList<>( + List.of( + cannonicalClassName, + toCanonicalCase(cannonicalClassName + "S"), + toCanonicalCase(cannonicalClassName + "ES"))); if (cannonicalClassName.endsWith("Y")) { - candidates.add(toCanonicalCase( - cannonicalClassName.substring(0, cannonicalClassName.length() - 1) + "IES")); + candidates.add( + toCanonicalCase( + cannonicalClassName.substring(0, cannonicalClassName.length() - 1) + "IES")); } return candidates; - } - /** * Convert from the given table name candidates to the exact table name on the database. * @@ -77,13 +82,12 @@ private List guessTableNameCandidates(Class objectClass) { * @param tableNameCandidates * @return * @throws SQLException - * * @see {@link java.sql.DatabaseMetaData#getTables} */ - private Optional convertToExactTableName(DatabaseMetaData metaData, - List tableNameCandidates) { - try ( - ResultSet resultSet = metaData.getTables(null, null, "%", new String[] {"TABLE", "VIEW"})) { + private Optional convertToExactTableName( + DatabaseMetaData metaData, List tableNameCandidates) { + try (ResultSet resultSet = + metaData.getTables(null, null, "%", new String[] {"TABLE", "VIEW"})) { while (resultSet.next()) { // 3. TABLE_NAME String => table name String tableNameOnDb = resultSet.getString(3); @@ -96,7 +100,4 @@ private Optional convertToExactTableName(DatabaseMetaData metaData, return Optional.empty(); } } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableSqlFactory.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableSqlFactory.java index 0a832a4a..7bf530b3 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableSqlFactory.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/DefaultTableSqlFactory.java @@ -23,8 +23,10 @@ public TableSql create(JdbcTableMetaData tableMetaData, JdbcDatabaseMetaData dat List notAutoGeneratedColumns = tableMetaData.getNotAutoGeneratedColumns(); String insertSqlPrefix = "insert into " + tableName + " (" + String.join(", ", notAutoGeneratedColumns) + ") values"; - String insertPlaceholders = " (" - + generatePlaceholders(databaseMetaData, tableMetaData, notAutoGeneratedColumns) + ") "; + String insertPlaceholders = + " (" + + generatePlaceholders(databaseMetaData, tableMetaData, notAutoGeneratedColumns) + + ") "; String insertSql = insertSqlPrefix + insertPlaceholders; List primaryKeys = tableMetaData.getPrimaryKeys(); @@ -34,29 +36,55 @@ public TableSql create(JdbcTableMetaData tableMetaData, JdbcDatabaseMetaData dat String whereClauseIdentifyByPrimaryKeys = createWhereClauseIdentifyByPrimaryKeys(primaryKeys); - String existsSql = !tableMetaData.hasPrimaryKey() ? errorMsg - : "select 1 from " + tableName + whereClauseIdentifyByPrimaryKeys; - - UpdateSqlFactory updateSqlFactory = new UpdateSqlFactory(tableMetaData.hasPrimaryKey(), - errorMsg, tableName, tableMetaData.getNotPrimaryKeys(), whereClauseIdentifyByPrimaryKeys); + String existsSql = + !tableMetaData.hasPrimaryKey() + ? errorMsg + : "select 1 from " + tableName + whereClauseIdentifyByPrimaryKeys; + + UpdateSqlFactory updateSqlFactory = + new UpdateSqlFactory( + tableMetaData.hasPrimaryKey(), + errorMsg, + tableName, + tableMetaData.getNotPrimaryKeys(), + whereClauseIdentifyByPrimaryKeys); String updateSql = updateSqlFactory.create(tableMetaData.getNotPrimaryKeys()); - String deleteSql = !tableMetaData.hasPrimaryKey() ? errorMsg - : "delete from " + tableName + whereClauseIdentifyByPrimaryKeys; + String deleteSql = + !tableMetaData.hasPrimaryKey() + ? errorMsg + : "delete from " + tableName + whereClauseIdentifyByPrimaryKeys; String mergePlaceholders = " (" + generatePlaceholders(databaseMetaData, tableMetaData, columns) + ") "; - String mergeSqlPrefix = !tableMetaData.hasPrimaryKey() ? "" - : "merge into " + tableName + " (" + String.join(", ", columns) + ")" + " key (" - + String.join(",", primaryKeys) + ") values"; + String mergeSqlPrefix = + !tableMetaData.hasPrimaryKey() + ? "" + : "merge into " + + tableName + + " (" + + String.join(", ", columns) + + ")" + + " key (" + + String.join(",", primaryKeys) + + ") values"; String mergeSql = !tableMetaData.hasPrimaryKey() ? errorMsg : mergeSqlPrefix + mergePlaceholders; String selectByPrimaryKeySql = !tableMetaData.hasPrimaryKey() ? "" : selectAllSql + " " + whereClauseIdentifyByPrimaryKeys; - - return new TableSql(insertPlaceholders, mergePlaceholders, selectByPrimaryKeySql, selectAllSql, - insertSql, updateSql, deleteSql, mergeSql, existsSql, insertSqlPrefix, mergeSqlPrefix, + return new TableSql( + insertPlaceholders, + mergePlaceholders, + selectByPrimaryKeySql, + selectAllSql, + insertSql, + updateSql, + deleteSql, + mergeSql, + existsSql, + insertSqlPrefix, + mergeSqlPrefix, updateSqlFactory); } @@ -68,8 +96,12 @@ public static class UpdateSqlFactory { private final String whereClauseIdentifyByPrimaryKeys; private final Map canonicalNameToDbColumnMap; - public UpdateSqlFactory(boolean hasPrimaryKey, String errorMsg, String tableName, - List columns, String whereClauseIdentifyByPrimaryKeys) { + public UpdateSqlFactory( + boolean hasPrimaryKey, + String errorMsg, + String tableName, + List columns, + String whereClauseIdentifyByPrimaryKeys) { this.hasPrimaryKey = hasPrimaryKey; this.errorMsg = errorMsg; this.tableName = tableName; @@ -79,41 +111,46 @@ public UpdateSqlFactory(boolean hasPrimaryKey, String errorMsg, String tableName } public String create(List columns) { - return !hasPrimaryKey ? errorMsg - : "update " + tableName + createUpdateSetClause(columns) + return !hasPrimaryKey + ? errorMsg + : "update " + + tableName + + createUpdateSetClause(columns) + whereClauseIdentifyByPrimaryKeys; } private String createUpdateSetClause(List columns) { - return " set " + String.join(", ", - columns.stream() - .map(col -> canonicalNameToDbColumnMap.get(StringCache.toCanonicalCase(col)) + "=?") - .collect(Collectors.toList())); + return " set " + + String.join( + ", ", + columns.stream() + .map( + col -> + canonicalNameToDbColumnMap.get(StringCache.toCanonicalCase(col)) + "=?") + .collect(Collectors.toList())); } - } - - private static String createWhereClauseIdentifyByPrimaryKeys(List primaryKeys) { - return " where " + String.join(" and ", - primaryKeys.stream().map(pk -> pk + "=?").collect(Collectors.toList())); + return " where " + + String.join( + " and ", primaryKeys.stream().map(pk -> pk + "=?").collect(Collectors.toList())); } - protected String generatePlaceholders(JdbcDatabaseMetaData databaseMetaData, - JdbcTableMetaData tableMetaData, List targetColumns) { + protected String generatePlaceholders( + JdbcDatabaseMetaData databaseMetaData, + JdbcTableMetaData tableMetaData, + List targetColumns) { if (databaseMetaData.getDatabaseProductName().toLowerCase().contains("h2")) { - return String.join(",", + return String.join( + ",", tableMetaData.getColumnsWithMetaData().stream() .filter(c -> targetColumns.contains(c.getName())) .map(c -> c.getTypeName().equalsIgnoreCase("json") ? "? format json" : "?") .toArray(String[]::new)); } else { - return String.join(",", - Stream.generate(() -> "?").limit(targetColumns.size()).collect(Collectors.toList())); + return String.join( + ",", Stream.generate(() -> "?").limit(targetColumns.size()).collect(Collectors.toList())); } } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/FieldAccessor.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/FieldAccessor.java index 6e331070..d5240b03 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/FieldAccessor.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/FieldAccessor.java @@ -9,7 +9,6 @@ * Field accessor mapping to the columnName. * * @author nkjm - * */ public final class FieldAccessor { @@ -20,16 +19,18 @@ public final class FieldAccessor { private final SetterAccessor setter; private final String columnName; - public FieldAccessor(String columnName, Field field, Method getter, Method setter) { this.columnName = columnName; - this.getter = getter != null ? new GetterMethod(getter) - : field != null ? new FieldGetter(field) : EMPTY_GETTER; - this.setter = setter != null ? new SetterMethod(setter) - : field != null ? new FieldSetter(field) : EMPTY_SETTER; + this.getter = + getter != null + ? new GetterMethod(getter) + : field != null ? new FieldGetter(field) : EMPTY_GETTER; + this.setter = + setter != null + ? new SetterMethod(setter) + : field != null ? new FieldSetter(field) : EMPTY_SETTER; } - /** * Gets the value from the corresponding field by getter method/field access. * @@ -71,19 +72,21 @@ public final Class getGetterReturnType() { return getter.getReturnType(); } - @Override public String toString() { - return "Accessor [getterAccessor=" + getter + ", setterAccessor=" + setter + ", columnName=" - + columnName + "]"; + return "Accessor [getterAccessor=" + + getter + + ", setterAccessor=" + + setter + + ", columnName=" + + columnName + + "]"; } - public String getFormattedString() { return "getter=[" + getter + "], setter=[" + setter + "]"; } - private static interface GetterAccessor { Object get(Object object) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException; @@ -133,7 +136,6 @@ public String toString() { public Class getReturnType() { return Void.class; } - } private static final class FieldGetter implements GetterAccessor { @@ -158,7 +160,6 @@ public String toString() { public Class getReturnType() { return field.getType(); } - } private static interface SetterAccessor { @@ -167,7 +168,6 @@ void set(Object object, Object value) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException; Class getParameterType(); - } private static final class EmptySetter implements SetterAccessor { @@ -187,7 +187,6 @@ public Class getParameterType() { public String toString() { return getClass().getSimpleName(); } - } private static final class SetterMethod implements SetterAccessor { @@ -214,10 +213,8 @@ public void set(Object object, Object value) public String toString() { return setter.getName() + "(" + setter.getParameterTypes()[0].getSimpleName() + ")"; } - } - private static final class FieldSetter implements SetterAccessor { private final Field field; @@ -242,8 +239,5 @@ public void set(Object object, Object value) public String toString() { return "field " + field.getType().getSimpleName() + " " + field.getName(); } - } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/MultiRowProcessorFactory.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/MultiRowProcessorFactory.java index df1474ae..7feb0e3a 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/MultiRowProcessorFactory.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/MultiRowProcessorFactory.java @@ -7,20 +7,17 @@ public interface MultiRowProcessorFactory { - - /** - * Type of how to execute multi-row update SQL statements. - */ + /** Type of how to execute multi-row update SQL statements. */ public enum MultiRowProcessorType { - SIMPLE_BATCH, MULTI_ROW, MULTI_ROW_AND_BATCH; + SIMPLE_BATCH, + MULTI_ROW, + MULTI_ROW_AND_BATCH; } - public static Builder builder() { return new Builder(); } - public static class Builder { private MultiRowProcessorType multiRowProcessorType = MultiRowProcessorType.MULTI_ROW; @@ -28,41 +25,36 @@ public static class Builder { private int multiRowSize = 32; private int batchSizeWithMultiRow = 5; - public Builder setBatchSize(int size) { this.batchSize = size; return this; } - public Builder setMultiRowSize(int size) { this.multiRowSize = size; return this; } - public Builder setBatchSizeWithMultiRow(int size) { this.batchSizeWithMultiRow = size; return this; } - public Builder setMultiRowProcessorType(MultiRowProcessorType type) { this.multiRowProcessorType = type; return this; } public MultiRowProcessorFactory build() { - return new MultiRowProcessorFactoryImpl(multiRowProcessorType, batchSize, multiRowSize, - batchSizeWithMultiRow); + return new MultiRowProcessorFactoryImpl( + multiRowProcessorType, batchSize, multiRowSize, batchSizeWithMultiRow); } - } - - MultiRowProcessor getMultiRowProcessor(LoggerContext loggerContext, - SqlParametersSetter sqlParametersSetter, PreparedStatementSupplier statementSupplier, - Class objectClass, SqlParametersToTableMapping sqlParametersToTableMapping); - - + MultiRowProcessor getMultiRowProcessor( + LoggerContext loggerContext, + SqlParametersSetter sqlParametersSetter, + PreparedStatementSupplier statementSupplier, + Class objectClass, + SqlParametersToTableMapping sqlParametersToTableMapping); } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/NameToFieldAccessorMapper.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/NameToFieldAccessorMapper.java index 2943016b..f610188c 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/NameToFieldAccessorMapper.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/NameToFieldAccessorMapper.java @@ -10,5 +10,4 @@ public interface NameToFieldAccessorMapper { * @return Keys in map is written in the canonical case. */ Map createMapping(Class objectClass); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/PreparedStatementSupplier.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/PreparedStatementSupplier.java index 01af5b62..59717ce0 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/PreparedStatementSupplier.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/PreparedStatementSupplier.java @@ -6,10 +6,8 @@ public interface PreparedStatementSupplier { - PreparedStatement prepareStatement(Connection connection, String sql) throws SQLException; - PreparedStatement prepareStatement(Connection connection, String sql, - String[] autoGeneratedColumnsArray) throws SQLException; - + PreparedStatement prepareStatement( + Connection connection, String sql, String[] autoGeneratedColumnsArray) throws SQLException; } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SqlParameterSetter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SqlParameterSetter.java index 9dab17af..9c1743af 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SqlParameterSetter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SqlParameterSetter.java @@ -9,14 +9,12 @@ public interface SqlParameterSetter { boolean test(PreparedStatement stmt, int parameterIndex, Object parameter) throws SQLException; - /** * Sets parameter. * * @param stmt * @param parameterIndex * @param parameter - * * @throws SQLException */ void setParameter(PreparedStatement stmt, int parameterIndex, Object parameter) diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SqlParametersSetter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SqlParametersSetter.java index 7b81c808..61493686 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SqlParametersSetter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/SqlParametersSetter.java @@ -7,7 +7,6 @@ * A setter for given {@link PreparedStatement}. * * @author nkjm - * */ public interface SqlParametersSetter { @@ -16,9 +15,6 @@ public interface SqlParametersSetter { * * @param stmt {@link java.sql.PreparedStatement} to have parameters set into * @param parameters parameters values - * */ void setParameters(PreparedStatement stmt, Object... parameters) throws SQLException; - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableMetaDataParser.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableMetaDataParser.java index f125becd..67b4c448 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableMetaDataParser.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableMetaDataParser.java @@ -7,7 +7,6 @@ public interface TableMetaDataParser { /** - * * Retrieves a list of auto-generated columns of the given table name from the database metadata. * * @param metaData @@ -30,7 +29,6 @@ List getColumnsMetaData(DatabaseMetaData metaData, String tableN throws SQLException; /** - * * Retrieves a list of primary keys columns of the given table name from the database metadata. * * @param metaData @@ -38,7 +36,5 @@ List getColumnsMetaData(DatabaseMetaData metaData, String tableN * @return * @throws SQLException */ - List getPrimaryKeys(DatabaseMetaData metaData, String tableName) throws SQLException; - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableNameMapper.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableNameMapper.java index 81043431..a9c686af 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableNameMapper.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableNameMapper.java @@ -6,7 +6,6 @@ * A mapper from a class or candidates of table name to a valid table name exists on database. * * @author nkjm - * */ public interface TableNameMapper { @@ -27,5 +26,4 @@ public interface TableNameMapper { * @return table name exists in database. */ String getTableName(String tableName, DatabaseMetaData metaData); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableSql.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableSql.java index fd767b77..d5400501 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableSql.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableSql.java @@ -12,7 +12,6 @@ * SQL statements generated by {@link TableSqlFactory}. * * @author yuu_nkjm - * */ public final class TableSql { @@ -32,6 +31,8 @@ public final class TableSql { private final UpdateSqlFactory updateSqlFactory; /** + * + * *

    * selectByPrimaryKeySql=select * from GUESTS  where ID=?
    * selectAllSql=select * from GUESTS
@@ -59,9 +60,18 @@ public final class TableSql {
    * @param mergeSqlPrefix
    * @param updateSqlFactory
    */
-  public TableSql(String inserPlaceholders, String mergePlaceholders, String selectByPrimaryKeySql,
-      String selectAllSql, String insertSql, String updateSql, String deleteSql, String mergeSql,
-      String existsSql, String insertSqlPrefix, String mergeSqlPrefix,
+  public TableSql(
+      String inserPlaceholders,
+      String mergePlaceholders,
+      String selectByPrimaryKeySql,
+      String selectAllSql,
+      String insertSql,
+      String updateSql,
+      String deleteSql,
+      String mergeSql,
+      String existsSql,
+      String insertSqlPrefix,
+      String mergeSqlPrefix,
       UpdateSqlFactory updateSqlFactory) {
     this.insertPlaceholders = inserPlaceholders;
     this.mergePlaceholders = mergePlaceholders;
@@ -89,7 +99,6 @@ public String getMergeSql() {
     return mergeSql;
   }
 
-
   public String getMultirowInsertSql(int num) {
     return getSqlWithMultirowPlaceholders(insertSqlPrefix, insertPlaceholders, num);
   }
@@ -99,15 +108,21 @@ public String getMultirowMergeSql(int num) {
   }
 
   /**
-   *
    * @param sqlPrefix
    * @param placeHolders e.g. (?,?,?)
    * @param repeat
    * @return
    */
   private String getSqlWithMultirowPlaceholders(String sqlPrefix, String placeHolders, int repeat) {
-    return multiRowSqlMap.computeIfAbsent(sqlPrefix + repeat, n -> sqlPrefix + String.join(",",
-        Stream.generate(() -> placeHolders).limit(repeat).collect(Collectors.toList())));
+    return multiRowSqlMap.computeIfAbsent(
+        sqlPrefix + repeat,
+        n ->
+            sqlPrefix
+                + String.join(
+                    ",",
+                    Stream.generate(() -> placeHolders)
+                        .limit(repeat)
+                        .collect(Collectors.toList())));
   }
 
   public String getSelectAllSql() {
@@ -128,16 +143,32 @@ public String getExistsSql() {
 
   @Override
   public String toString() {
-    return "TableSql [insertPlaceholders=" + insertPlaceholders + ", mergePlaceholders="
-        + mergePlaceholders + ", selectByPrimaryKeySql=" + selectByPrimaryKeySql + ", selectAllSql="
-        + selectAllSql + ", insertSql=" + insertSql + ", updateSql=" + updateSql + ", deleteSql="
-        + deleteSql + ", mergeSql=" + mergeSql + ", existsSql=" + existsSql + ", insertSqlPrefix="
-        + insertSqlPrefix + ", mergeSqlPrefix=" + mergeSqlPrefix + "]";
+    return "TableSql [insertPlaceholders="
+        + insertPlaceholders
+        + ", mergePlaceholders="
+        + mergePlaceholders
+        + ", selectByPrimaryKeySql="
+        + selectByPrimaryKeySql
+        + ", selectAllSql="
+        + selectAllSql
+        + ", insertSql="
+        + insertSql
+        + ", updateSql="
+        + updateSql
+        + ", deleteSql="
+        + deleteSql
+        + ", mergeSql="
+        + mergeSql
+        + ", existsSql="
+        + existsSql
+        + ", insertSqlPrefix="
+        + insertSqlPrefix
+        + ", mergeSqlPrefix="
+        + mergeSqlPrefix
+        + "]";
   }
 
   public String getUpdateSql(RowMap object) {
     return updateSqlFactory.create(new ArrayList<>(object.keySet()));
   }
-
 }
-
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableSqlFactory.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableSqlFactory.java
index a894e902..30a3cb40 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableSqlFactory.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/context/TableSqlFactory.java
@@ -6,5 +6,4 @@
 public interface TableSqlFactory {
 
   TableSql create(JdbcTableMetaData tableMetaData, JdbcDatabaseMetaData databaseMetaData);
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmConnectionImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmConnectionImpl.java
index 90b557f3..0a2397b5 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmConnectionImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmConnectionImpl.java
@@ -53,11 +53,10 @@
 /**
  * A database connection with object-relation mapping function.
  *
- * This instance wraps a {@link java.sql.Connection} object. Instances of this class are not thread
- * safe.
+ * 

This instance wraps a {@link java.sql.Connection} object. Instances of this class are not + * thread safe. * * @author nkjm - * */ public class OrmConnectionImpl implements OrmConnection { @@ -84,7 +83,9 @@ public void close() { try { getJdbcConnection().close(); } catch (SQLException e) { - sormContext.getLoggerContext().getLogger(OrmConnectionImpl.class) + sormContext + .getLoggerContext() + .getLogger(OrmConnectionImpl.class) .warn("jdbc connection close error"); } } @@ -94,7 +95,6 @@ public void commit() { Try.runOrElseThrow(() -> getJdbcConnection().commit(), Try::rethrow); } - // private String createInsertSql(String tableName, List cols) { // String ps = String.join(",", // Stream.generate(() -> "?").limit(cols.size()).collect(Collectors.toList())); @@ -108,11 +108,9 @@ public int[] delete(List objects) { return applytoArray(objects, array -> delete(array)); } - /** * Deletes an object in the database. The object will be identified using its mapped table's * primary key. - * */ @Override public int delete(T object) { @@ -120,23 +118,24 @@ public int delete(T object) { return executeUpdate(mapping.getSql().getDeleteSql(), mapping.getDeleteParameters(object)); } - - /** * Updates a batch of objects in the database. The objects will be identified using their matched * table's primary keys. If no primary keys are defined in a given object, a RuntimeException will * be thrown. - * */ @Override public int[] delete(@SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(objects, mapping -> mapping.batch(connection, - mapping.getSql().getDeleteSql(), obj -> mapping.getDeleteParameters(obj), objects), + return execSqlIfParameterExists( + objects, + mapping -> + mapping.batch( + connection, + mapping.getSql().getDeleteSql(), + obj -> mapping.getDeleteParameters(obj), + objects), EMPTY_INT_SUPPLIER); } - - @Override public int deleteAll(Class objectClass) { return deleteAllIn(getTableName(objectClass)); @@ -172,18 +171,27 @@ public int deleteIn(String tableName, T object) { @Override public int[] deleteIn(String tableName, @SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(tableName, objects, mapping -> mapping.batch(connection, - mapping.getSql().getDeleteSql(), obj -> mapping.getDeleteParameters(obj), objects), + return execSqlIfParameterExists( + tableName, + objects, + mapping -> + mapping.batch( + connection, + mapping.getSql().getDeleteSql(), + obj -> mapping.getDeleteParameters(obj), + objects), EMPTY_INT_SUPPLIER); } - /** - * Execute sql function with table name. objects when objects[0] is null, - * {@code NullPointerException} are throw. + * Execute sql function with table name. objects when objects[0] is null, {@code + * NullPointerException} are throw. */ - private final R execSqlIfParameterExists(String tableName, T[] objects, - Function, R> sqlFunction, Supplier notExists) { + private final R execSqlIfParameterExists( + String tableName, + T[] objects, + Function, R> sqlFunction, + Supplier notExists) { if (objects == null || objects.length == 0) { return notExists.get(); } @@ -195,8 +203,8 @@ private final R execSqlIfParameterExists(String tableName, T[] objects, /** * Execute sql function. objects when objects[0] is null, {@code NullPointerException} are throw. */ - private final R execSqlIfParameterExists(T[] objects, - Function, R> sqlFunction, Supplier notExists) { + private final R execSqlIfParameterExists( + T[] objects, Function, R> sqlFunction, Supplier notExists) { if (objects == null || objects.length == 0) { return notExists.get(); } @@ -207,33 +215,41 @@ private final R execSqlIfParameterExists(T[] objects, @Override public boolean execute(ParameterizedSql sql) { return execute(sql.getSql(), sql.getParameters()); - } @Override public boolean execute(String sql, Object... parameters) { - return executeAndClose(getLoggerContext(), getJdbcConnection(), getPreparedStatementSupplier(), - getSqlParametersSetter(), sql, parameters); + return executeAndClose( + getLoggerContext(), + getJdbcConnection(), + getPreparedStatementSupplier(), + getSqlParametersSetter(), + sql, + parameters); } - @Override - public T executeQuery(FunctionHandler statementSupplier, + public T executeQuery( + FunctionHandler statementSupplier, ResultSetTraverser traverser) { return executeQueryAndClose(connection, traverser, statementSupplier); } - @Override - public List executeQuery(FunctionHandler statementSupplier, - RowMapper rowMapper) { + public List executeQuery( + FunctionHandler statementSupplier, RowMapper rowMapper) { return executeQueryAndClose(connection, ResultSetTraverser.of(rowMapper), statementSupplier); } @Override public T executeQuery(ParameterizedSql sql, ResultSetTraverser resultSetTraverser) { - return executeQueryAndClose(getLoggerContext(), getJdbcConnection(), - getPreparedStatementSupplier(), getSqlParametersSetter(), sql.getSql(), sql.getParameters(), + return executeQueryAndClose( + getLoggerContext(), + getJdbcConnection(), + getPreparedStatementSupplier(), + getSqlParametersSetter(), + sql.getSql(), + sql.getParameters(), resultSetTraverser); } @@ -249,19 +265,23 @@ public int executeUpdate(ParameterizedSql sql) { @Override public int executeUpdate(String sql, Object... parameters) { - final int ret = executeUpdateAndClose(getLoggerContext(), connection, getSqlParametersSetter(), - getPreparedStatementSupplier(), sql, parameters); + final int ret = + executeUpdateAndClose( + getLoggerContext(), + connection, + getSqlParametersSetter(), + getPreparedStatementSupplier(), + sql, + parameters); return ret; } - @Override public boolean exists(String tableName, T object) { SqlParametersToTableMapping mapping = getCastedTableMapping(tableName, object.getClass()); return existsHelper(mapping.getSql(), mapping.getPrimaryKeyParameters(object)); } - @Override public boolean exists(T object) { SqlParametersToTableMapping mapping = getCastedTableMapping(object.getClass()); @@ -278,20 +298,16 @@ public boolean exists(Class type, Object... primaryKeyValues) { return existsHelper(getTableSql(type), primaryKeyValues); } - private boolean existsHelper(TableSql tableSql, Object... primaryKeyValues) { final String sql = tableSql.getExistsSql(); return readFirst(Integer.class, sql, primaryKeyValues) != null; } - - - private SqlParametersToTableMapping getCastedTableMapping(String tableName, - Class objectClass) { + private SqlParametersToTableMapping getCastedTableMapping( + String tableName, Class objectClass) { return sormContext.getCastedTableMapping(connection, tableName, objectClass); } - private SqlParametersToTableMapping getCastedTableMapping(Class objectClass) { return sormContext.getCastedTableMapping(connection, objectClass); } @@ -308,19 +324,16 @@ private ColumnValueToMapValueConverters getColumnValueToMapValueConverter() { return sormContext.getColumnValueToMapValueConverter(); } - @Override public SormContext getContext() { return sormContext; } - @Override public Connection getJdbcConnection() { return connection; } - @Override public JdbcDatabaseMetaData getJdbcDatabaseMetaData() { try { @@ -335,7 +348,6 @@ private LoggerContext getLoggerContext() { return sormContext.getLoggerContext(); } - private PreparedStatementSupplier getPreparedStatementSupplier() { return sormContext.getPreparedStatementSupplier(); } @@ -354,7 +366,6 @@ private SqlParametersSetter getSqlParametersSetter() { return sormContext.getSqlParametersSetter(); } - /** * Gets {@link SqlParametersToTableMapping}. This method is for internal use. * @@ -386,21 +397,16 @@ public JdbcTableMetaData getJdbcTableMetaData(String tableName) { return sormContext.getJdbcTableMetaData(connection, tableName); } - - @Override public String getTableName(Class objectClass) { return sormContext.getTableName(connection, objectClass); } - - @Override public int[] insert(List objects) { return applytoArray(objects, array -> insert(array)); } - @Override public int insert(T object) { SqlParametersToTableMapping mapping = getCastedTableMapping(object.getClass()); @@ -409,8 +415,8 @@ public int insert(T object) { @Override public int[] insert(@SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(objects, - mapping -> mapping.insert(getJdbcConnection(), objects), EMPTY_INT_SUPPLIER); + return execSqlIfParameterExists( + objects, mapping -> mapping.insert(getJdbcConnection(), objects), EMPTY_INT_SUPPLIER); } @Override @@ -418,7 +424,6 @@ public InsertResult insertAndGet(List objects) { return applytoArray(objects, array -> insertAndGet(array)); } - @Override public InsertResult insertAndGet(T object) { SqlParametersToTableMapping mapping = getCastedTableMapping(object.getClass()); @@ -427,12 +432,12 @@ public InsertResult insertAndGet(T object) { @Override public InsertResult insertAndGet(@SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(objects, + return execSqlIfParameterExists( + objects, mapping -> mapping.insertAndGet(getJdbcConnection(), objects), () -> InsertResultImpl.EMPTY_INSERT_RESULT); } - @Override public InsertResult insertAndGetIn(String tableName, List objects) { return applytoArray(objects, array -> insertAndGetIn(tableName, array)); @@ -445,31 +450,33 @@ public InsertResult insertAndGetIn(String tableName, T object) { } @Override - public InsertResult insertAndGetIn(String tableName, - @SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(tableName, objects, + public InsertResult insertAndGetIn( + String tableName, @SuppressWarnings("unchecked") T... objects) { + return execSqlIfParameterExists( + tableName, + objects, mapping -> mapping.insertAndGet(getJdbcConnection(), objects), () -> InsertResultImpl.EMPTY_INSERT_RESULT); } - @Override public int[] insertIn(String tableName, List objects) { return applytoArray(objects, array -> insertIn(tableName, array)); } - @Override public int insertIn(String tableName, T object) { SqlParametersToTableMapping mapping = getCastedTableMapping(tableName, object.getClass()); return executeUpdate(mapping.getSql().getInsertSql(), mapping.getInsertParameters(object)); } - @Override public int[] insertIn(String tableName, @SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(tableName, objects, - mapping -> mapping.insert(getJdbcConnection(), objects), EMPTY_INT_SUPPLIER); + return execSqlIfParameterExists( + tableName, + objects, + mapping -> mapping.insert(getJdbcConnection(), objects), + EMPTY_INT_SUPPLIER); } @Override @@ -487,7 +494,6 @@ public int[] insertMapIn(String tableName, List objects) { } } - @Override public int insertMapIn(String tableName, RowMap object) { String sql = getTableSql(tableName).getInsertSql(); @@ -505,14 +511,14 @@ public int[] insertMapIn(String tableName, RowMap... objects) { } @Override - public List> join(Class t1, Class t2, String sql, - Object... parameters) { + public List> join( + Class t1, Class t2, String sql, Object... parameters) { return readTupleList(t1, t2, sql, parameters); } @Override - public List> join(Class t1, Class t2, Class t3, - String sql, Object... parameters) { + public List> join( + Class t1, Class t2, Class t3, String sql, Object... parameters) { return readTupleList(t1, t2, t3, sql, parameters); } @@ -522,46 +528,70 @@ public List> joinOn(Class t1, Class t2, String o } @Override - public List> joinOn(Class t1, Class t2, Class t3, - String t1T2OnCondition, String t2T3OnCondition) { + public List> joinOn( + Class t1, Class t2, Class t3, String t1T2OnCondition, String t2T3OnCondition) { return join(t1, t2, t3, joinSql(JOIN, t1, t2, t1T2OnCondition, t3, t2T3OnCondition)); } - @Override public List> joinUsing(Class t1, Class t2, String... columns) { - return join(t1, t2, - joinSql(JOIN, t1, t2, " using (" + SelectSql.joinCommaAndSpace(columns) + ")")); + return join( + t1, t2, joinSql(JOIN, t1, t2, " using (" + SelectSql.joinCommaAndSpace(columns) + ")")); } - - private String joinSql(String joinType, Class t1, Class t2, - String joinCondition) { + private String joinSql( + String joinType, Class t1, Class t2, String joinCondition) { TableMetaData t1m = getTableMapping(t1).getTableMetaData(); TableMetaData t2m = getTableMapping(t2).getTableMetaData(); - String sql = SELECT + String.join(",", t1m.getColumnAliases()) + ", " - + String.join(",", t2m.getColumnAliases()) + FROM + t1m.getTableName() + joinType - + t2m.getTableName() + joinCondition; + String sql = + SELECT + + String.join(",", t1m.getColumnAliases()) + + ", " + + String.join(",", t2m.getColumnAliases()) + + FROM + + t1m.getTableName() + + joinType + + t2m.getTableName() + + joinCondition; return sql; } - private String joinSql(String joinType, Class t1, Class t2, - String t1T2OnCondition, Class t3, String t2T3OnCondition) { + private String joinSql( + String joinType, + Class t1, + Class t2, + String t1T2OnCondition, + Class t3, + String t2T3OnCondition) { TableMetaData t2m = getTableMapping(t2).getTableMetaData(); TableMetaData t3m = getTableMapping(t3).getTableMetaData(); - String joinCondition = joinType + t2m.getTableName() + ON + t1T2OnCondition + joinType - + t3m.getTableName() + ON + t2T3OnCondition; + String joinCondition = + joinType + + t2m.getTableName() + + ON + + t1T2OnCondition + + joinType + + t3m.getTableName() + + ON + + t2T3OnCondition; return joinSql(joinType, t1, t2, t3, joinCondition); } - private String joinSql(String joinType, Class t1, Class t2, Class t3, - String joinCondition) { + private String joinSql( + String joinType, Class t1, Class t2, Class t3, String joinCondition) { TableMetaData t1m = getTableMapping(t1).getTableMetaData(); TableMetaData t2m = getTableMapping(t2).getTableMetaData(); TableMetaData t3m = getTableMapping(t3).getTableMetaData(); - String sql = SELECT + String.join(",", t1m.getColumnAliases()) + ", " - + String.join(",", t2m.getColumnAliases()) + ", " + String.join(",", t3m.getColumnAliases()) - + FROM + t1m.getTableName() + joinCondition; + String sql = + SELECT + + String.join(",", t1m.getColumnAliases()) + + ", " + + String.join(",", t2m.getColumnAliases()) + + ", " + + String.join(",", t3m.getColumnAliases()) + + FROM + + t1m.getTableName() + + joinCondition; return sql; } @@ -571,8 +601,8 @@ public List> leftJoinOn(Class t1, Class t2, Stri } @Override - public List> leftJoinOn(Class t1, Class t2, Class t3, - String t1T2OnCondition, String t2T3OnCondition) { + public List> leftJoinOn( + Class t1, Class t2, Class t3, String t1T2OnCondition, String t2T3OnCondition) { return join(t1, t2, t3, joinSql(LEFT + JOIN, t1, t2, t1T2OnCondition, t3, t2T3OnCondition)); } @@ -580,17 +610,16 @@ public T loadFirst(Class objectClass, ResultSet resultSet) throws SQLExce return resultSet.next() ? mapRowToObject(objectClass, resultSet) : null; } - private final T loadResultContainerObject(final Class objectClass, - final ResultSet resultSet) throws SQLException { + private final T loadResultContainerObject( + final Class objectClass, final ResultSet resultSet) throws SQLException { return getColumnsMapping(objectClass).loadResultContainerObject(resultSet); } - public final List loadResultContainerObjectList(final Class objectClass, - final ResultSet resultSet) throws SQLException { + public final List loadResultContainerObjectList( + final Class objectClass, final ResultSet resultSet) throws SQLException { return getColumnsMapping(objectClass).traverseAndMap(resultSet); } - private final List loadSupportedReturnedTypeList(Class objectClass, ResultSet resultSet) throws SQLException { final List ret = new ArrayList<>(); @@ -599,7 +628,6 @@ private final List loadSupportedReturnedTypeList(Class objectClass, Re ret.add(toSupportedReturnedTypeObject(resultSet, sqlType, objectClass)); } return ret; - } private RowMap mapRowToMap(ResultSet resultSet) throws SQLException { @@ -612,8 +640,8 @@ public T mapRowToObject(Class objectClass, ResultSet resultSet) throws SQ if (objectClass.equals(RowMap.class)) { return (T) mapRowToMap(resultSet); } else if (getColumnValueToJavaObjectConverter().isSupportedReturnedType(objectClass)) { - return toSupportedReturnedTypeObject(resultSet, getOneSqlType(objectClass, resultSet), - objectClass); + return toSupportedReturnedTypeObject( + resultSet, getOneSqlType(objectClass, resultSet), objectClass); } else { return loadResultContainerObject(objectClass, resultSet); } @@ -630,11 +658,10 @@ public int merge(T object) { return executeUpdate(mapping.getSql().getMergeSql(), mapping.getMergeParameters(object)); } - @Override public int[] merge(@SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(objects, mapping -> mapping.merge(getJdbcConnection(), objects), - EMPTY_INT_SUPPLIER); + return execSqlIfParameterExists( + objects, mapping -> mapping.merge(getJdbcConnection(), objects), EMPTY_INT_SUPPLIER); } @Override @@ -650,8 +677,11 @@ public int mergeIn(String tableName, T object) { @Override public int[] mergeIn(String tableName, @SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(tableName, objects, - mapping -> mapping.merge(getJdbcConnection(), objects), EMPTY_INT_SUPPLIER); + return execSqlIfParameterExists( + tableName, + objects, + mapping -> mapping.merge(getJdbcConnection(), objects), + EMPTY_INT_SUPPLIER); } @Override @@ -676,8 +706,13 @@ public T readFirst(Class objectClass, ParameterizedSql sql) { @Override public T readFirst(Class objectClass, String sql, Object... parameters) { - return executeQueryAndClose(getLoggerContext(), getJdbcConnection(), - getPreparedStatementSupplier(), getSqlParametersSetter(), sql, parameters, + return executeQueryAndClose( + getLoggerContext(), + getJdbcConnection(), + getPreparedStatementSupplier(), + getSqlParametersSetter(), + sql, + parameters, resultSet -> loadFirst(objectClass, resultSet)); } @@ -688,8 +723,13 @@ public List readList(Class objectClass, ParameterizedSql sql) { @Override public List readList(Class objectClass, String sql, Object... parameters) { - return executeQueryAndClose(getLoggerContext(), getJdbcConnection(), - getPreparedStatementSupplier(), getSqlParametersSetter(), sql, parameters, + return executeQueryAndClose( + getLoggerContext(), + getJdbcConnection(), + getPreparedStatementSupplier(), + getSqlParametersSetter(), + sql, + parameters, resultSet -> traverseAndMapToList(objectClass, resultSet)); } @@ -700,65 +740,95 @@ public T readOne(Class objectClass, ParameterizedSql sql) { @Override public T readOne(Class objectClass, String sql, Object... parameters) { - return executeQueryAndClose(getLoggerContext(), getJdbcConnection(), - getPreparedStatementSupplier(), getSqlParametersSetter(), sql, parameters, resultSet -> { + return executeQueryAndClose( + getLoggerContext(), + getJdbcConnection(), + getPreparedStatementSupplier(), + getSqlParametersSetter(), + sql, + parameters, + resultSet -> { T ret = null; if (resultSet.next()) { ret = mapRowToObject(objectClass, resultSet); } else { - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format( - "Try to read an unique [{}] object but no result returned. sql=[{}],params=[{}]", - objectClass.getName(), sql, parameters)); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Try to read an unique [{}] object but no result returned. sql=[{}],params=[{}]", + objectClass.getName(), + sql, + parameters)); } if (resultSet.next()) { - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format( - "Try to read an unique [{}] object but non-unique result returned. sql=[{}],params=[{}]", - objectClass.getName(), sql, parameters)); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Try to read an unique [{}] object but non-unique result returned. sql=[{}],params=[{}]", + objectClass.getName(), + sql, + parameters)); } return ret; }); } @Override - public List> readTupleList(Class t1, Class t2, - Class t3, ParameterizedSql sql) { + public List> readTupleList( + Class t1, Class t2, Class t3, ParameterizedSql sql) { return readTupleList(t1, t2, t3, sql.getSql(), sql.getParameters()); } @Override - public List> readTupleList(Class t1, Class t2, - Class t3, String sql, Object... parameters) { - List> ret = executeQueryAndClose(getLoggerContext(), getJdbcConnection(), - getPreparedStatementSupplier(), getSqlParametersSetter(), sql, parameters, resultSet -> { - final List> ret1 = new ArrayList<>(); - while (resultSet.next()) { - ret1.add(Tuple.of(loadResultContainerObject(t1, resultSet), - loadResultContainerObject(t2, resultSet), - loadResultContainerObject(t3, resultSet))); - } - return ret1; - }); + public List> readTupleList( + Class t1, Class t2, Class t3, String sql, Object... parameters) { + List> ret = + executeQueryAndClose( + getLoggerContext(), + getJdbcConnection(), + getPreparedStatementSupplier(), + getSqlParametersSetter(), + sql, + parameters, + resultSet -> { + final List> ret1 = new ArrayList<>(); + while (resultSet.next()) { + ret1.add( + Tuple.of( + loadResultContainerObject(t1, resultSet), + loadResultContainerObject(t2, resultSet), + loadResultContainerObject(t3, resultSet))); + } + return ret1; + }); return ret; } @Override - public List> readTupleList(Class t1, Class t2, - ParameterizedSql sql) { + public List> readTupleList( + Class t1, Class t2, ParameterizedSql sql) { return readTupleList(t1, t2, sql.getSql(), sql.getParameters()); } @Override - public List> readTupleList(Class t1, Class t2, String sql, - Object... parameters) { - List> ret = executeQueryAndClose(getLoggerContext(), getJdbcConnection(), - getPreparedStatementSupplier(), getSqlParametersSetter(), sql, parameters, resultSet -> { - final List> ret1 = new ArrayList<>(); - while (resultSet.next()) { - ret1.add(Tuple.of(loadResultContainerObject(t1, resultSet), - loadResultContainerObject(t2, resultSet))); - } - return ret1; - }); + public List> readTupleList( + Class t1, Class t2, String sql, Object... parameters) { + List> ret = + executeQueryAndClose( + getLoggerContext(), + getJdbcConnection(), + getPreparedStatementSupplier(), + getSqlParametersSetter(), + sql, + parameters, + resultSet -> { + final List> ret1 = new ArrayList<>(); + while (resultSet.next()) { + ret1.add( + Tuple.of( + loadResultContainerObject(t1, resultSet), + loadResultContainerObject(t2, resultSet))); + } + return ret1; + }); return ret; } @@ -769,7 +839,6 @@ public void rollback() { } catch (SQLException e) { throw Try.rethrow(e); } - } @Override @@ -780,11 +849,18 @@ public final List selectAll(Class objectClass) { @Override public T selectByPrimaryKey(Class objectClass, Object... primaryKeyValues) { final String sql = getTableMapping(objectClass).getSql().getSelectByPrimaryKeySql(); - return executeQueryAndClose(getLoggerContext(), getJdbcConnection(), - getPreparedStatementSupplier(), getSqlParametersSetter(), sql, primaryKeyValues, + return executeQueryAndClose( + getLoggerContext(), + getJdbcConnection(), + getPreparedStatementSupplier(), + getSqlParametersSetter(), + sql, + primaryKeyValues, resultSet -> { - return resultSet.next() ? getColumnsMapping(objectClass) - .loadResultContainerObjectByPrimaryKey(objectClass, resultSet) : null; + return resultSet.next() + ? getColumnsMapping(objectClass) + .loadResultContainerObjectByPrimaryKey(objectClass, resultSet) + : null; }); } @@ -795,30 +871,28 @@ public void setAutoCommit(boolean autoCommit) { } catch (SQLException e) { throw Try.rethrow(e); } - } /** * Converts the result from database to a {@link RowMap} objects. The data of the column is * extracted by corresponding column types. * - *

- * Keys in the results is depending on {@link ColumnValueToMapKeyConverter#convertToKey(String)}. + *

Keys in the results is depending on {@link + * ColumnValueToMapKeyConverter#convertToKey(String)}. * * @param resultSet * @param columns * @param columnTypes SQL types from {@link java.sql.Types} - * * @return * @throws SQLException */ - private RowMap toSingleRowMap(ResultSet resultSet, String[] columns, int[] columnTypes) throws SQLException { final int colsNum = columns.length; final RowMap ret = new BasicRowMap(colsNum + 1, 1.0f); for (int i = 1; i <= colsNum; i++) { - ret.put(columns[i - 1], + ret.put( + columns[i - 1], getColumnValueToMapValueConverter().convertToValue(resultSet, i, columnTypes[i - 1])); } return ret; @@ -830,28 +904,25 @@ private RowMap toSingleRowMap(ResultSet resultSet, String[] columns, int[] colum * @param resultSet * @param columnType * @param objectClass - * * @param * @return * @throws SQLException */ - - private T toSupportedReturnedTypeObject(ResultSet resultSet, int sqlType, - Class objectClass) throws SQLException { + private T toSupportedReturnedTypeObject( + ResultSet resultSet, int sqlType, Class objectClass) throws SQLException { return getColumnValueToJavaObjectConverter().convertTo(resultSet, 1, sqlType, objectClass); } - @SuppressWarnings("unchecked") private List traverseAndMapToList(Class objectClass, ResultSet resultSet) throws SQLException { - return objectClass.equals(RowMap.class) ? (List) traverseAndMapToRowMapList(resultSet) + return objectClass.equals(RowMap.class) + ? (List) traverseAndMapToRowMapList(resultSet) : (getColumnValueToJavaObjectConverter().isSupportedReturnedType(objectClass) ? loadSupportedReturnedTypeList(objectClass, resultSet) : loadResultContainerObjectList(objectClass, resultSet)); } - private List traverseAndMapToRowMapList(ResultSet resultSet) throws SQLException { final List ret = new ArrayList<>(); final ColumnsAndTypes ct = ColumnsAndTypes.createColumnsAndTypes(resultSet); @@ -866,7 +937,6 @@ public int[] update(List objects) { return applytoArray(objects, array -> update(array)); } - /** * Updates an object in the database. The object will be identified using its mapped table's * primary key. If no primary keys are defined in the mapped table, a {@link RuntimeException} @@ -894,21 +964,24 @@ public int updateByPrimaryKeyIn(String tableName, RowMap object, Object... prima return executeUpdate(sql, params.toArray()); } - @Override public int[] update(@SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(objects, mapping -> mapping.batch(connection, - mapping.getSql().getUpdateSql(), obj -> mapping.getUpdateParameters(obj), objects), + return execSqlIfParameterExists( + objects, + mapping -> + mapping.batch( + connection, + mapping.getSql().getUpdateSql(), + obj -> mapping.getUpdateParameters(obj), + objects), EMPTY_INT_SUPPLIER); } - @Override public int[] updateIn(String tableName, List objects) { return applytoArray(objects, array -> updateIn(tableName, array)); } - @Override public int updateIn(String tableName, T object) { SqlParametersToTableMapping mapping = getCastedTableMapping(tableName, object.getClass()); @@ -917,8 +990,15 @@ public int updateIn(String tableName, T object) { @Override public int[] updateIn(String tableName, @SuppressWarnings("unchecked") T... objects) { - return execSqlIfParameterExists(tableName, objects, mapping -> mapping.batch(connection, - mapping.getSql().getUpdateSql(), obj -> mapping.getUpdateParameters(obj), objects), + return execSqlIfParameterExists( + tableName, + objects, + mapping -> + mapping.batch( + connection, + mapping.getSql().getUpdateSql(), + obj -> mapping.getUpdateParameters(obj), + objects), EMPTY_INT_SUPPLIER); } @@ -927,15 +1007,20 @@ private static R applytoArray(List objects, Function sqlFunc) return sqlFunc.apply((T[]) objects.toArray(Object[]::new)); } - private static Optional createLogPointAndLogBeforeSql(LoggerContext loggerContext, - LoggerContext.Category category, Class clazz, Connection connection, String sql, + private static Optional createLogPointAndLogBeforeSql( + LoggerContext loggerContext, + LoggerContext.Category category, + Class clazz, + Connection connection, + String sql, Object... parameters) { Optional lp = loggerContext.createLogPoint(category, clazz); lp.ifPresent(_lp -> _lp.logBeforeSql(connection, sql, parameters)); return lp; } - private static R executeQueryAndClose(Connection connection, + private static R executeQueryAndClose( + Connection connection, ResultSetTraverser resultSetTraverser, FunctionHandler statementSupplier) { try (PreparedStatement stmt = statementSupplier.apply(connection); @@ -946,9 +1031,13 @@ private static R executeQueryAndClose(Connection connection, } } - private static boolean executeAndClose(LoggerContext loggerContext, Connection connection, - PreparedStatementSupplier statementSupplier, SqlParametersSetter sqlParametersSetter, - String sql, Object[] parameters) { + private static boolean executeAndClose( + LoggerContext loggerContext, + Connection connection, + PreparedStatementSupplier statementSupplier, + SqlParametersSetter sqlParametersSetter, + String sql, + Object[] parameters) { try (PreparedStatement stmt = statementSupplier.prepareStatement(connection, sql)) { sqlParametersSetter.setParameters(stmt, parameters); boolean ret = stmt.execute(); @@ -958,11 +1047,22 @@ private static boolean executeAndClose(LoggerContext loggerContext, Connecti } } - private static R executeQueryAndClose(LoggerContext loggerContext, Connection connection, - PreparedStatementSupplier statementSupplier, SqlParametersSetter sqlParametersSetter, - String sql, Object[] parameters, ResultSetTraverser resultSetTraverser) { - Optional lp = createLogPointAndLogBeforeSql(loggerContext, Category.EXECUTE_QUERY, - OrmConnectionImpl.class, connection, sql, parameters); + private static R executeQueryAndClose( + LoggerContext loggerContext, + Connection connection, + PreparedStatementSupplier statementSupplier, + SqlParametersSetter sqlParametersSetter, + String sql, + Object[] parameters, + ResultSetTraverser resultSetTraverser) { + Optional lp = + createLogPointAndLogBeforeSql( + loggerContext, + Category.EXECUTE_QUERY, + OrmConnectionImpl.class, + connection, + sql, + parameters); try (PreparedStatement stmt = statementSupplier.prepareStatement(connection, sql)) { sqlParametersSetter.setParameters(stmt, parameters); ResultSet resultSet = stmt.executeQuery(); @@ -974,11 +1074,21 @@ private static R executeQueryAndClose(LoggerContext loggerContext, Connectio } } - private static int executeUpdateAndClose(LoggerContext loggerContext, Connection connection, - SqlParametersSetter sqlParametersSetter, PreparedStatementSupplier statementSupplier, - String sql, Object[] parameters) { - Optional lp = createLogPointAndLogBeforeSql(loggerContext, Category.EXECUTE_QUERY, - OrmConnectionImpl.class, connection, sql, parameters); + private static int executeUpdateAndClose( + LoggerContext loggerContext, + Connection connection, + SqlParametersSetter sqlParametersSetter, + PreparedStatementSupplier statementSupplier, + String sql, + Object[] parameters) { + Optional lp = + createLogPointAndLogBeforeSql( + loggerContext, + Category.EXECUTE_QUERY, + OrmConnectionImpl.class, + connection, + sql, + parameters); try (PreparedStatement stmt = statementSupplier.prepareStatement(connection, sql)) { sqlParametersSetter.setParameters(stmt, parameters); int ret = stmt.executeUpdate(); @@ -992,9 +1102,12 @@ private static int executeUpdateAndClose(LoggerContext loggerContext, Connection private static int getOneSqlType(Class objectClass, ResultSet resultSet) throws SQLException { ResultSetMetaData metaData = resultSet.getMetaData(); if (metaData.getColumnCount() != 1) { - throw new SormException("ResultSet returned [" + metaData.getColumnCount() - + "] columns but 1 column was expected to load data into an instance of [" - + objectClass.getName() + "]"); + throw new SormException( + "ResultSet returned [" + + metaData.getColumnCount() + + "] columns but 1 column was expected to load data into an instance of [" + + objectClass.getName() + + "]"); } return metaData.getColumnType(1); } @@ -1057,8 +1170,6 @@ public String[] getColumns() { public int[] getColumnTypes() { return columnTypes; } - - } @Override @@ -1070,5 +1181,4 @@ public TableMappedOrmConnection mapToTable(Class type) { public TableMappedOrmConnection mapToTable(Class type, String tableName) { return new TableMappedOrmConnectionImpl<>(this, type, tableName); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmTransactionImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmTransactionImpl.java index 62737e45..a6195dbd 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmTransactionImpl.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmTransactionImpl.java @@ -9,7 +9,6 @@ * An transaction with object relation mapping. * * @author nkjm - * */ public final class OrmTransactionImpl extends OrmConnectionImpl implements OrmTransaction { @@ -18,9 +17,8 @@ public final class OrmTransactionImpl extends OrmConnectionImpl implements OrmTr * * @param connection * @param context - * @param isolationLevel {@link Connection#TRANSACTION_READ_COMMITTED}, - * {@link Connection#TRANSACTION_READ_UNCOMMITTED} and so on. - * + * @param isolationLevel {@link Connection#TRANSACTION_READ_COMMITTED}, {@link + * Connection#TRANSACTION_READ_UNCOMMITTED} and so on. */ public OrmTransactionImpl(Connection connection, SormContextImpl context, int isolationLevel) { super(connection, context); @@ -43,7 +41,4 @@ public void close() { super.close(); } } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormConfig.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormConfig.java index 4f5ba088..ac370412 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormConfig.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormConfig.java @@ -25,12 +25,16 @@ final class SormConfig { private final TableSqlFactory tableSqlFactory; private final TableMetaDataParser tableMetaDataReader = new DefaultTableMetaDataParser(); - SormConfig(LoggerContext loggerContext, ColumnToFieldAccessorMapper columnFieldMapper, + SormConfig( + LoggerContext loggerContext, + ColumnToFieldAccessorMapper columnFieldMapper, TableNameMapper tableNameMapper, ColumnValueToJavaObjectConverters columnValueToJavaObjectConverter, ColumnValueToMapValueConverters columnValueToMapValueConverter, - SqlParametersSetter sqlParametersSetter, PreparedStatementSupplier preparedStatementSupplier, - TableSqlFactory tableSqlFactory, MultiRowProcessorFactory multiRowProcessorFactory) { + SqlParametersSetter sqlParametersSetter, + PreparedStatementSupplier preparedStatementSupplier, + TableSqlFactory tableSqlFactory, + MultiRowProcessorFactory multiRowProcessorFactory) { this.loggerContext = loggerContext; this.tableNameMapper = tableNameMapper; this.columnFieldMapper = columnFieldMapper; @@ -42,7 +46,6 @@ final class SormConfig { this.tableSqlFactory = tableSqlFactory; } - TableMetaDataParser getTableMetaDataReader() { return this.tableMetaDataReader; } @@ -55,7 +58,6 @@ ColumnValueToMapValueConverters getColumnValueToMapValueConverter() { return columnValueToMapValueConverter; } - SqlParametersSetter getSqlParametersSetter() { return sqlParametersSetter; } @@ -72,7 +74,6 @@ ColumnToFieldAccessorMapper getColumnToFieldAccessorMapper() { return columnFieldMapper; } - TableNameMapper getTableNameMapper() { return tableNameMapper; } @@ -81,22 +82,28 @@ TableSqlFactory getTableSqlFactory() { return tableSqlFactory; } - MultiRowProcessorFactory getMultiRowProcessorFactory() { return multiRowProcessorFactory; } - @Override public String toString() { - return "SormConfig [tableNameMapper=" + tableNameMapper + ", columnFieldMapper=" - + columnFieldMapper + ", multiRowProcessorFactory=" + multiRowProcessorFactory - + ", columnValueToJavaObjectConverter=" + columnValueToJavaObjectConverter - + ", columnValueToMapValueConverter=" + columnValueToMapValueConverter - + ", sqlParametersSetter=" + sqlParametersSetter + ", loggerContext=" + loggerContext - + ", tableSqlFactory=" + tableSqlFactory + "]"; + return "SormConfig [tableNameMapper=" + + tableNameMapper + + ", columnFieldMapper=" + + columnFieldMapper + + ", multiRowProcessorFactory=" + + multiRowProcessorFactory + + ", columnValueToJavaObjectConverter=" + + columnValueToJavaObjectConverter + + ", columnValueToMapValueConverter=" + + columnValueToMapValueConverter + + ", sqlParametersSetter=" + + sqlParametersSetter + + ", loggerContext=" + + loggerContext + + ", tableSqlFactory=" + + tableSqlFactory + + "]"; } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormContextImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormContextImpl.java index 0e6b546d..6060dedf 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormContextImpl.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormContextImpl.java @@ -50,46 +50,64 @@ private SormContextImpl(SormConfig sormConfig) { this.sqlResultToColumnsMappings = new ConcurrentHashMap<>(); } - public SormContextImpl(LoggerContext loggerContext, ColumnToFieldAccessorMapper columnFieldMapper, + public SormContextImpl( + LoggerContext loggerContext, + ColumnToFieldAccessorMapper columnFieldMapper, TableNameMapper tableNameMapper, ColumnValueToJavaObjectConverters columnValueToJavaObjectConverter, ColumnValueToMapValueConverters columnValueToMapValueConverter, - SqlParametersSetter sqlParametersSetter, PreparedStatementSupplier statementSupplier, - TableSqlFactory tableSqlFactory, MultiRowProcessorFactory multiRowProcessorFactory) { - this(new SormConfig(loggerContext, columnFieldMapper, tableNameMapper, - columnValueToJavaObjectConverter, columnValueToMapValueConverter, sqlParametersSetter, - statementSupplier, tableSqlFactory, multiRowProcessorFactory)); + SqlParametersSetter sqlParametersSetter, + PreparedStatementSupplier statementSupplier, + TableSqlFactory tableSqlFactory, + MultiRowProcessorFactory multiRowProcessorFactory) { + this( + new SormConfig( + loggerContext, + columnFieldMapper, + tableNameMapper, + columnValueToJavaObjectConverter, + columnValueToMapValueConverter, + sqlParametersSetter, + statementSupplier, + tableSqlFactory, + multiRowProcessorFactory)); } JdbcTableMetaData getJdbcTableMetaData(Connection connection, String tableName) { return getTableMetaData(connection, tableName, NoValueType.class); } - TableMetaDataImpl getTableMetaData(Connection connection, String tableName, - Class objectClass) { + TableMetaDataImpl getTableMetaData( + Connection connection, String tableName, Class objectClass) { TableName _tableName = toTableName(connection, tableName); - TableMetaDataImpl ret = tableMetaDataMap.computeIfAbsent(_tableName.getName(), _key -> { - try { - return createTableMetaData(objectClass, _tableName.getName(), connection.getMetaData()); - } catch (SQLException e) { - throw Try.rethrow(e); - } - }); + TableMetaDataImpl ret = + tableMetaDataMap.computeIfAbsent( + _tableName.getName(), + _key -> { + try { + return createTableMetaData( + objectClass, _tableName.getName(), connection.getMetaData()); + } catch (SQLException e) { + throw Try.rethrow(e); + } + }); return ret; } public TableSql getTableSql(Connection connection, JdbcTableMetaData tableMetaData) { - return tableSqlMap.computeIfAbsent(tableMetaData.getTableName(), _key -> { - try { - return config.getTableSqlFactory().create(tableMetaData, - JdbcDatabaseMetaData.of(connection.getMetaData())); - } catch (SQLException e) { - throw Try.rethrow(e); - } - }); + return tableSqlMap.computeIfAbsent( + tableMetaData.getTableName(), + _key -> { + try { + return config + .getTableSqlFactory() + .create(tableMetaData, JdbcDatabaseMetaData.of(connection.getMetaData())); + } catch (SQLException e) { + throw Try.rethrow(e); + } + }); } - SqlParametersToTableMapping getTableMapping(Connection connection, Class objectClass) { return getTableMapping(connection, toTableName(connection, objectClass), objectClass); } @@ -97,54 +115,60 @@ SqlParametersToTableMapping getTableMapping(Connection connection, Class< /** * Get table mapping by the table name and the object class. When there is no mapping, the method * create a mapping and register it. - * */ - SqlParametersToTableMapping getTableMapping(Connection connection, String tableName, - Class objectClass) { + SqlParametersToTableMapping getTableMapping( + Connection connection, String tableName, Class objectClass) { return getTableMapping(connection, toTableName(connection, tableName), objectClass); } - SqlParametersToTableMapping getTableMapping(Connection connection, TableName tableName, - Class objectClass) { + SqlParametersToTableMapping getTableMapping( + Connection connection, TableName tableName, Class objectClass) { String key = toKey(objectClass, tableName); @SuppressWarnings("unchecked") SqlParametersToTableMapping ret = - (SqlParametersToTableMapping) sqlParametersToTableMappings.computeIfAbsent(key, _k -> { - try { - SqlParametersToTableMapping m = - createTableMapping(objectClass, tableName.getName(), connection); - config.getLoggerContext() - .createLogPoint(LoggerContext.Category.MAPPING, SormContext.class) - .ifPresent(lp -> lp.logMapping(m.toString())); - return m; - } catch (SQLException e) { - throw Try.rethrow(e); - } - }); + (SqlParametersToTableMapping) + sqlParametersToTableMappings.computeIfAbsent( + key, + _k -> { + try { + SqlParametersToTableMapping m = + createTableMapping(objectClass, tableName.getName(), connection); + config + .getLoggerContext() + .createLogPoint(LoggerContext.Category.MAPPING, SormContext.class) + .ifPresent(lp -> lp.logMapping(m.toString())); + return m; + } catch (SQLException e) { + throw Try.rethrow(e); + } + }); return ret; } - private static String toKey(Class objectClass, TableName tableName) { return objectClass.getName() + "-" + tableName.getName(); } SqlResultToColumnsMapping createColumnsMapping(Class objectClass) { - ColumnToAccessorMapping columnToAccessorMap = new ColumnToAccessorMapping(objectClass, - config.getColumnToFieldAccessorMapper().createMapping(objectClass), - config.getColumnToFieldAccessorMapper().getColumnAliasPrefix(objectClass)); + ColumnToAccessorMapping columnToAccessorMap = + new ColumnToAccessorMapping( + objectClass, + config.getColumnToFieldAccessorMapper().createMapping(objectClass), + config.getColumnToFieldAccessorMapper().getColumnAliasPrefix(objectClass)); - return new SqlResultToColumnsMapping<>(config.getColumnValueToJavaObjectConverter(), - objectClass, columnToAccessorMap); + return new SqlResultToColumnsMapping<>( + config.getColumnValueToJavaObjectConverter(), objectClass, columnToAccessorMap); } - SqlParametersToTableMapping createTableMapping(Class objectClass, String tableName, - Connection connection) throws SQLException { + SqlParametersToTableMapping createTableMapping( + Class objectClass, String tableName, Connection connection) throws SQLException { - ColumnToAccessorMapping columnToAccessorMap = new ColumnToAccessorMapping(objectClass, - config.getColumnToFieldAccessorMapper().createMapping(objectClass), - config.getColumnToFieldAccessorMapper().getColumnAliasPrefix(objectClass)); + ColumnToAccessorMapping columnToAccessorMap = + new ColumnToAccessorMapping( + objectClass, + config.getColumnToFieldAccessorMapper().createMapping(objectClass), + config.getColumnToFieldAccessorMapper().getColumnAliasPrefix(objectClass)); TableMetaDataImpl tableMetaData = getTableMetaData(connection, tableName, objectClass); @@ -152,14 +176,18 @@ SqlParametersToTableMapping createTableMapping(Class objectClass, Stri // validate(objectClass, tableMetaData, columnToAccessorMap.keySet()); - return new SqlParametersToTableMapping<>(config.getLoggerContext(), - config.getColumnValueToJavaObjectConverter(), config.getSqlParametersSetter(), - config.getPreparedStatementSupplier(), config.getMultiRowProcessorFactory(), objectClass, - columnToAccessorMap, tableMetaData, sql); + return new SqlParametersToTableMapping<>( + config.getLoggerContext(), + config.getColumnValueToJavaObjectConverter(), + config.getSqlParametersSetter(), + config.getPreparedStatementSupplier(), + config.getMultiRowProcessorFactory(), + objectClass, + columnToAccessorMap, + tableMetaData, + sql); } - - // private void validate(Class objectClass, TableMetaData tableMetaData, // Set keySetWithoutAlias) { // List notMatchColumns = tableMetaData.getColumns().stream() @@ -177,9 +205,8 @@ SqlParametersToTableMapping createTableMapping(Class objectClass, Stri // } // } - - private TableMetaDataImpl createTableMetaData(Class objectClass, String tableName, - DatabaseMetaData metaData) throws SQLException { + private TableMetaDataImpl createTableMetaData( + Class objectClass, String tableName, DatabaseMetaData metaData) throws SQLException { List columns = config.getTableMetaDataReader().getColumnsMetaData(metaData, tableName); @@ -194,40 +221,45 @@ private TableMetaDataImpl createTableMetaData(Class objectClass, String t } @SuppressWarnings("unchecked") - SqlParametersToTableMapping getCastedTableMapping(Connection connection, - Class objectClass) { + SqlParametersToTableMapping getCastedTableMapping( + Connection connection, Class objectClass) { return (SqlParametersToTableMapping) getTableMapping(connection, objectClass); } - @SuppressWarnings("unchecked") - SqlParametersToTableMapping getCastedTableMapping(Connection connection, String tableName, - Class objectClass) { + SqlParametersToTableMapping getCastedTableMapping( + Connection connection, String tableName, Class objectClass) { return (SqlParametersToTableMapping) getTableMapping(connection, tableName, objectClass); } SqlResultToColumnsMapping getColumnsMapping(Class objectClass) { @SuppressWarnings("unchecked") - SqlResultToColumnsMapping ret = (SqlResultToColumnsMapping) sqlResultToColumnsMappings - .computeIfAbsent(objectClass, _k -> { - SqlResultToColumnsMapping m = createColumnsMapping(objectClass); - config.getLoggerContext() - .createLogPoint(LoggerContext.Category.MAPPING, SormContext.class) - .ifPresent(lp -> lp.logMapping(m.toString())); - return m; - }); + SqlResultToColumnsMapping ret = + (SqlResultToColumnsMapping) + sqlResultToColumnsMappings.computeIfAbsent( + objectClass, + _k -> { + SqlResultToColumnsMapping m = createColumnsMapping(objectClass); + config + .getLoggerContext() + .createLogPoint(LoggerContext.Category.MAPPING, SormContext.class) + .ifPresent(lp -> lp.logMapping(m.toString())); + return m; + }); return ret; } private TableName toTableName(Connection connection, Class objectClass) { - return classNameToValidTableNameMap.computeIfAbsent(objectClass, k -> { - try { - return new TableName( - config.getTableNameMapper().getTableName(objectClass, connection.getMetaData())); - } catch (SQLException e) { - throw Try.rethrow(e); - } - }); + return classNameToValidTableNameMap.computeIfAbsent( + objectClass, + k -> { + try { + return new TableName( + config.getTableNameMapper().getTableName(objectClass, connection.getMetaData())); + } catch (SQLException e) { + throw Try.rethrow(e); + } + }); } String getTableName(Connection connection, Class objectClass) { @@ -235,23 +267,23 @@ String getTableName(Connection connection, Class objectClass) { } private TableName toTableName(Connection connection, String tableName) { - return tableNameToValidTableNameMap.computeIfAbsent(tableName, k -> { - try { - return new TableName( - config.getTableNameMapper().getTableName(tableName, connection.getMetaData())); - } catch (SQLException e) { - throw Try.rethrow(e); - } - }); + return tableNameToValidTableNameMap.computeIfAbsent( + tableName, + k -> { + try { + return new TableName( + config.getTableNameMapper().getTableName(tableName, connection.getMetaData())); + } catch (SQLException e) { + throw Try.rethrow(e); + } + }); } - @Override public LoggerContext getLoggerContext() { return config.getLoggerContext(); } - @Override public ColumnValueToJavaObjectConverters getColumnValueToJavaObjectConverter() { return config.getColumnValueToJavaObjectConverter(); @@ -272,32 +304,48 @@ public PreparedStatementSupplier getPreparedStatementSupplier() { return config.getPreparedStatementSupplier(); } - - /** - * Returns string of this context. This is for debugging. - */ + /** Returns string of this context. This is for debugging. */ @Override public String toString() { - return "SormContext {" + lineSeparator() + "[Table metadata]" + lineSeparator() - + convertMapToString(tableMetaDataMap) + lineSeparator() + "[SqlParameterToTableMappings]" - + lineSeparator() + convertMapToString(sqlParametersToTableMappings) + lineSeparator() - + "[SqlResultToColumnsMapping]" + lineSeparator() - + convertClassMapToString(sqlResultToColumnsMappings) + lineSeparator() - + "[classNameToValidTableNameMap]" + lineSeparator() - + convertClassMapToString(classNameToValidTableNameMap) + lineSeparator() - + "[tableNameToValidTableNameMap]" + lineSeparator() - + convertMapToString(tableNameToValidTableNameMap) + lineSeparator() + "[SormConfig]" - + lineSeparator() + config + lineSeparator() + "}"; + return "SormContext {" + + lineSeparator() + + "[Table metadata]" + + lineSeparator() + + convertMapToString(tableMetaDataMap) + + lineSeparator() + + "[SqlParameterToTableMappings]" + + lineSeparator() + + convertMapToString(sqlParametersToTableMappings) + + lineSeparator() + + "[SqlResultToColumnsMapping]" + + lineSeparator() + + convertClassMapToString(sqlResultToColumnsMappings) + + lineSeparator() + + "[classNameToValidTableNameMap]" + + lineSeparator() + + convertClassMapToString(classNameToValidTableNameMap) + + lineSeparator() + + "[tableNameToValidTableNameMap]" + + lineSeparator() + + convertMapToString(tableNameToValidTableNameMap) + + lineSeparator() + + "[SormConfig]" + + lineSeparator() + + config + + lineSeparator() + + "}"; } private String convertClassMapToString(Map, ? extends Object> map) { - return convertMapToString(map.entrySet().stream() - .collect(Collectors.toMap(e -> e.getKey().getName(), e -> e.getValue()))); + return convertMapToString( + map.entrySet().stream() + .collect(Collectors.toMap(e -> e.getKey().getName(), e -> e.getValue()))); } private String convertMapToString(Map map) { List keySet = map.keySet().stream().sorted().collect(Collectors.toList()); - return String.join(lineSeparator(), + return String.join( + lineSeparator(), keySet.stream().map(e -> e + " => " + map.get(e).toString()).collect(Collectors.toList())); } @@ -314,8 +362,5 @@ public SormContext.Builder builder() { .setTableSqlFactory(config.getTableSqlFactory()); } - - private static class NoValueType { - - } + private static class NoValueType {} } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormImpl.java index 0970b557..5fbef20b 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormImpl.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormImpl.java @@ -34,7 +34,6 @@ * An entry point of object-relation mapping. * * @author nkjm - * */ public final class SormImpl implements Sorm { @@ -45,7 +44,6 @@ public final class SormImpl implements Sorm { private final SormContextImpl sormContext; private final ConcurrentMap> tables; - public static Sorm create(DataSource dataSource, SormContext context) { return new SormImpl(dataSource, (SormContextImpl) context); } @@ -71,8 +69,8 @@ public R applyHandler(FunctionHandler connectionHandler) { } @Override - public R applyHandler(int isolationLevel, - FunctionHandler transactionHandler) { + public R applyHandler( + int isolationLevel, FunctionHandler transactionHandler) { try (OrmTransaction transaction = open(isolationLevel)) { R ret = transactionHandler.apply(transaction); transaction.rollback(); @@ -82,10 +80,9 @@ public R applyHandler(int isolationLevel, } } - @Override - public void acceptHandler(int isolationLevel, - ConsumerHandler transactionHandler) { + public void acceptHandler( + int isolationLevel, ConsumerHandler transactionHandler) { try (OrmTransaction transaction = open(isolationLevel)) { transactionHandler.accept(transaction); } catch (Exception e) { @@ -117,8 +114,6 @@ public Connection getJdbcConnection() { } } - - @Override public void acceptHandler(ConsumerHandler handler) { try (OrmConnection conn = open()) { @@ -128,14 +123,11 @@ public void acceptHandler(ConsumerHandler handler) { } } - - @Override public String toString() { return "Sorm [dataSource=" + dataSource + ", sormContext=" + sormContext + "]"; } - private R applyAndClose(FunctionHandler handler) { try (OrmConnection conn = open()) { return handler.apply(conn); @@ -149,7 +141,6 @@ public List selectAll(Class objectClass) { return applyAndClose(conn -> conn.selectAll(objectClass)); } - @Override public T selectByPrimaryKey(Class objectClass, Object... primaryKeyValues) { return applyAndClose(conn -> conn.selectByPrimaryKey(objectClass, primaryKeyValues)); @@ -165,7 +156,6 @@ public T readFirst(Class objectClass, String sql, Object... parameters) { return applyAndClose(conn -> conn.readFirst(objectClass, sql, parameters)); } - @Override public List readList(Class objectClass, ParameterizedSql sql) { return applyAndClose(conn -> conn.readList(objectClass, sql)); @@ -187,38 +177,38 @@ public T readOne(Class objectClass, String sql, Object... parameters) { } @Override - public List> readTupleList(Class t1, Class t2, - Class t3, ParameterizedSql sql) { + public List> readTupleList( + Class t1, Class t2, Class t3, ParameterizedSql sql) { return readTupleList(t1, t2, t3, sql.getSql(), sql.getParameters()); } @Override - public List> readTupleList(Class t1, Class t2, - Class t3, String sql, Object... parameters) { + public List> readTupleList( + Class t1, Class t2, Class t3, String sql, Object... parameters) { return applyAndClose(conn -> conn.readTupleList(t1, t2, t3, sql, parameters)); } @Override - public List> readTupleList(Class t1, Class t2, - ParameterizedSql sql) { + public List> readTupleList( + Class t1, Class t2, ParameterizedSql sql) { return readTupleList(t1, t2, sql.getSql(), sql.getParameters()); } @Override - public List> readTupleList(Class t1, Class t2, String sql, - Object... parameters) { + public List> readTupleList( + Class t1, Class t2, String sql, Object... parameters) { return applyAndClose(conn -> conn.readTupleList(t1, t2, sql, parameters)); } @Override - public List> join(Class t1, Class t2, String sql, - Object... parameters) { + public List> join( + Class t1, Class t2, String sql, Object... parameters) { return applyAndClose(conn -> conn.join(t1, t2, sql, parameters)); } @Override - public List> join(Class t1, Class t2, Class t3, - String sql, Object... parameters) { + public List> join( + Class t1, Class t2, Class t3, String sql, Object... parameters) { return applyAndClose(conn -> conn.join(t1, t2, t3, sql, parameters)); } @@ -233,8 +223,8 @@ public List> joinUsing(Class t1, Class t2, Strin } @Override - public List> joinOn(Class t1, Class t2, Class t3, - String t1t2OnCondition, String t2t3OnCondition) { + public List> joinOn( + Class t1, Class t2, Class t3, String t1t2OnCondition, String t2t3OnCondition) { return applyAndClose(conn -> conn.joinOn(t1, t2, t3, t1t2OnCondition, t2t3OnCondition)); } @@ -244,12 +234,11 @@ public List> leftJoinOn(Class t1, Class t2, Stri } @Override - public List> leftJoinOn(Class t1, Class t2, Class t3, - String t1t2OnCondition, String t2t3OnCondition) { + public List> leftJoinOn( + Class t1, Class t2, Class t3, String t1t2OnCondition, String t2t3OnCondition) { return applyAndClose(conn -> conn.leftJoinOn(t1, t2, t3, t1t2OnCondition, t2t3OnCondition)); } - @Override public RowMapper getRowMapper(Class objectClass) { return applyAndClose(conn -> conn.getRowMapper(objectClass)); @@ -295,7 +284,6 @@ public int[] delete(@SuppressWarnings("unchecked") T... objects) { return applyAndClose(conn -> conn.delete(objects)); } - @Override public int[] deleteIn(String tableName, List objects) { return applyAndClose(conn -> conn.deleteIn(tableName, objects)); @@ -356,14 +344,11 @@ public int[] insertMapIn(String tableName, List objects) { return applyAndClose(conn -> conn.insertMapIn(tableName, objects)); } - - @Override public int[] insert(@SuppressWarnings("unchecked") T... objects) { return applyAndClose(conn -> conn.insert(objects)); } - @Override public InsertResult insertAndGet(List objects) { return applyAndClose(conn -> conn.insertAndGet(objects)); @@ -379,8 +364,6 @@ public InsertResult insertAndGet(@SuppressWarnings("unchecked") T... objects return applyAndClose(conn -> conn.insertAndGet(objects)); } - - @Override public InsertResult insertAndGetIn(String tableName, List objects) { return applyAndClose(conn -> conn.insertAndGetIn(tableName, objects)); @@ -392,8 +375,8 @@ public InsertResult insertAndGetIn(String tableName, T object) { } @Override - public InsertResult insertAndGetIn(String tableName, - @SuppressWarnings("unchecked") T... objects) { + public InsertResult insertAndGetIn( + String tableName, @SuppressWarnings("unchecked") T... objects) { return applyAndClose(conn -> conn.insertAndGetIn(tableName, objects)); } @@ -427,7 +410,6 @@ public int[] merge(@SuppressWarnings("unchecked") T... objects) { return applyAndClose(conn -> conn.merge(objects)); } - @Override public int[] mergeIn(String tableName, List objects) { return applyAndClose(conn -> conn.mergeIn(tableName, objects)); @@ -483,7 +465,6 @@ public int[] updateIn(String tableName, @SuppressWarnings("unchecked") T... return applyAndClose(conn -> conn.updateIn(tableName, objects)); } - @Override public String getTableName(Class objectClass) { return applyAndClose(conn -> conn.getTableName(objectClass)); @@ -494,7 +475,6 @@ public TableMetaData getTableMetaData(Class objectClass) { return applyAndClose(conn -> conn.getTableMetaData(objectClass)); } - @Override public JdbcTableMetaData getJdbcTableMetaData(String tableName) { return applyAndClose(conn -> conn.getJdbcTableMetaData(tableName)); @@ -521,14 +501,15 @@ public boolean execute(String sql, Object... parameters) { } @Override - public T executeQuery(FunctionHandler statementSupplier, + public T executeQuery( + FunctionHandler statementSupplier, ResultSetTraverser traverser) { return applyAndClose(conn -> conn.executeQuery(statementSupplier, traverser)); } @Override - public List executeQuery(FunctionHandler statementSupplier, - RowMapper rowMapper) { + public List executeQuery( + FunctionHandler statementSupplier, RowMapper rowMapper) { return applyAndClose(conn -> conn.executeQuery(statementSupplier, rowMapper)); } @@ -552,7 +533,6 @@ public int executeUpdate(ParameterizedSql sql) { return applyAndClose(conn -> conn.executeUpdate(sql)); } - @Override public JdbcDatabaseMetaData getJdbcDatabaseMetaData() { return applyAndClose(conn -> conn.getJdbcDatabaseMetaData()); @@ -567,8 +547,9 @@ public Table getTable(Class type) { @Override @SuppressWarnings("unchecked") public Table getTable(Class type, String tableName) { - return (Table) tables.computeIfAbsent(type.getName() + "-" + tableName, - key -> new BasicTable<>(this, type, tableName)); + return (Table) + tables.computeIfAbsent( + type.getName() + "-" + tableName, key -> new BasicTable<>(this, type, tableName)); } @Override @@ -585,5 +566,4 @@ public ResultSetStream stream(Class type, ParameterizedSql sql) { public ResultSetStream stream(Class type, String sql, Object... parameters) { return new ResultSetStreamSorm(this, type, sql, parameters); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/common/TableMetaDataImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/common/TableMetaDataImpl.java index b6e95fd8..1fdfe155 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/common/TableMetaDataImpl.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/common/TableMetaDataImpl.java @@ -24,36 +24,46 @@ public final class TableMetaDataImpl implements TableMetaData { private final List columnsWithAliases; private final List columnsWithMetaData; - - public TableMetaDataImpl(String tableName, String columnAliasPrefix, - List columnsWithMetaData, List primaryKeys, + public TableMetaDataImpl( + String tableName, + String columnAliasPrefix, + List columnsWithMetaData, + List primaryKeys, List autoGeneratedColumns) { this.tableName = tableName; this.columnsWithMetaData = List.copyOf(columnsWithMetaData); - this.columns = Collections.unmodifiableList( - columnsWithMetaData.stream().map(c -> c.getName()).collect(Collectors.toList())); + this.columns = + Collections.unmodifiableList( + columnsWithMetaData.stream().map(c -> c.getName()).collect(Collectors.toList())); this.primaryKeys = Collections.unmodifiableList(primaryKeys); this.autoGeneratedColumns = Collections.unmodifiableList(autoGeneratedColumns); - this.notAutoGeneratedColumns = Collections.unmodifiableList(columns.stream() - .filter(col -> !autoGeneratedColumns.contains(col)).collect(Collectors.toList())); + this.notAutoGeneratedColumns = + Collections.unmodifiableList( + columns.stream() + .filter(col -> !autoGeneratedColumns.contains(col)) + .collect(Collectors.toList())); this.hasPrimaryKey = !primaryKeys.isEmpty(); this.hasAutoGeneratedColumns = !autoGeneratedColumns.isEmpty(); this.autoGeneratedColumnsArray = autoGeneratedColumns.toArray(String[]::new); - this.notPrimaryKeys = Collections.unmodifiableList( - columns.stream().filter(col -> !primaryKeys.contains(col)).collect(Collectors.toList())); + this.notPrimaryKeys = + Collections.unmodifiableList( + columns.stream() + .filter(col -> !primaryKeys.contains(col)) + .collect(Collectors.toList())); - this.columnsForUpdate = Collections.unmodifiableList( - Stream.concat(notPrimaryKeys.stream(), primaryKeys.stream()).collect(Collectors.toList())); + this.columnsForUpdate = + Collections.unmodifiableList( + Stream.concat(notPrimaryKeys.stream(), primaryKeys.stream()) + .collect(Collectors.toList())); this.columnsWithAliases = - columns.stream().map(col -> tableName + "." + col + " as " + columnAliasPrefix + col) + columns.stream() + .map(col -> tableName + "." + col + " as " + columnAliasPrefix + col) .collect(Collectors.toList()); - - } @Override @@ -117,14 +127,30 @@ public boolean hasPrimaryKey() { @Override public String toString() { - return "TableMetaDataImpl [tableName=" + tableName + ", columns=" + columns + ", primaryKeys=" - + primaryKeys + ", autoGeneratedColumns=" + autoGeneratedColumns + ", hasPrimaryKey=" - + hasPrimaryKey + ", hasAutoGeneratedColumns=" + hasAutoGeneratedColumns - + ", notAutoGeneratedColumns=" + notAutoGeneratedColumns + ", columnsForUpdate=" - + columnsForUpdate + ", autoGeneratedColumnsArray=" - + Arrays.toString(autoGeneratedColumnsArray) + ", notPrimaryKeys=" + notPrimaryKeys - + ", columnsWithAliases=" + columnsWithAliases + ", columnsWithMetaData=" - + columnsWithMetaData + "]"; + return "TableMetaDataImpl [tableName=" + + tableName + + ", columns=" + + columns + + ", primaryKeys=" + + primaryKeys + + ", autoGeneratedColumns=" + + autoGeneratedColumns + + ", hasPrimaryKey=" + + hasPrimaryKey + + ", hasAutoGeneratedColumns=" + + hasAutoGeneratedColumns + + ", notAutoGeneratedColumns=" + + notAutoGeneratedColumns + + ", columnsForUpdate=" + + columnsForUpdate + + ", autoGeneratedColumnsArray=" + + Arrays.toString(autoGeneratedColumnsArray) + + ", notPrimaryKeys=" + + notPrimaryKeys + + ", columnsWithAliases=" + + columnsWithAliases + + ", columnsWithMetaData=" + + columnsWithMetaData + + "]"; } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/ColumnToAccessorMapping.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/ColumnToAccessorMapping.java index ed515718..27b9be84 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/ColumnToAccessorMapping.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/ColumnToAccessorMapping.java @@ -23,20 +23,22 @@ public final class ColumnToAccessorMapping { * * @param columnToAccessorMap */ - public ColumnToAccessorMapping(Class objectClass, - Map columnToAccessorMap, String columnAliasPrefix) { - this.columnToAccessorMap = columnToAccessorMap.entrySet().stream() - .collect(Collectors.toMap(e -> toCanonicalCase(e.getKey()), e -> e.getValue())); + public ColumnToAccessorMapping( + Class objectClass, + Map columnToAccessorMap, + String columnAliasPrefix) { + this.columnToAccessorMap = + columnToAccessorMap.entrySet().stream() + .collect(Collectors.toMap(e -> toCanonicalCase(e.getKey()), e -> e.getValue())); this.columnAliasPrefix = columnAliasPrefix; this.aliasColumnToAccessorMap = - columnAliasPrefix == null || columnAliasPrefix.length() == 0 ? Collections.emptyMap() + columnAliasPrefix == null || columnAliasPrefix.length() == 0 + ? Collections.emptyMap() : createAliasAccessors(columnAliasPrefix, columnToAccessorMap).entrySet().stream() .collect(Collectors.toMap(e -> toCanonicalCase(e.getKey()), e -> e.getValue())); } - - /** * Gets the accessor of the given columnName. ColumnName name is regarded as canonical name. * @@ -49,23 +51,39 @@ public FieldAccessor get(String columnName) { return ret != null ? ret : aliasColumnToAccessorMap.get(cn); } - - @Override public String toString() { List keySet = columnToAccessorMap.keySet().stream().sorted().collect(Collectors.toList()); List aliasKeySet = aliasColumnToAccessorMap.keySet().stream().sorted().collect(Collectors.toList()); - return "columns " + keySet + System.lineSeparator() + String.join(System.lineSeparator(), - keySet.stream() - .map(e -> " CsvColumn " + e + " <=> " + columnToAccessorMap.get(e).getFormattedString()) - .collect(Collectors.toList())) - + System.lineSeparator() + "column aliases " + aliasKeySet + System.lineSeparator() - + String.join(System.lineSeparator(), aliasKeySet.stream().map( - e -> " CsvColumn " + e + " <=> " + aliasColumnToAccessorMap.get(e).getFormattedString()) - .collect(Collectors.toList())); - + return "columns " + + keySet + + System.lineSeparator() + + String.join( + System.lineSeparator(), + keySet.stream() + .map( + e -> + " CsvColumn " + + e + + " <=> " + + columnToAccessorMap.get(e).getFormattedString()) + .collect(Collectors.toList())) + + System.lineSeparator() + + "column aliases " + + aliasKeySet + + System.lineSeparator() + + String.join( + System.lineSeparator(), + aliasKeySet.stream() + .map( + e -> + " CsvColumn " + + e + + " <=> " + + aliasColumnToAccessorMap.get(e).getFormattedString()) + .collect(Collectors.toList())); } public String getColumnAliasPrefix() { @@ -75,17 +93,34 @@ public String getColumnAliasPrefix() { public final void setValue(Object object, String columnName, Object value) { final FieldAccessor acc = get(columnName); if (acc == null) { - Object[] params = {value, value.getClass().getSimpleName(), object.getClass().getName(), columnName, columnToAccessorMap.toString()}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("Error: setting value [{}]" - + " of type [{}] in [{}]" - + " because column [{}] does not have a corresponding setter method or field access =>[{}]", params)); + Object[] params = { + value, + value.getClass().getSimpleName(), + object.getClass().getName(), + columnName, + columnToAccessorMap.toString() + }; + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Error: setting value [{}]" + + " of type [{}] in [{}]" + + " because column [{}] does not have a corresponding setter method or field access =>[{}]", + params)); } try { acc.set(object, value); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Object[] params = {columnName, object == null ? "null" : object.getClass().getSimpleName(), acc.getFormattedString(), value}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("Could not set a value for column [{}] to instance of [{}] with [{}]. The value is=[{}]", params), e); - + Object[] params = { + columnName, + object == null ? "null" : object.getClass().getSimpleName(), + acc.getFormattedString(), + value + }; + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Could not set a value for column [{}] to instance of [{}] with [{}]. The value is=[{}]", + params), + e); } } @@ -93,7 +128,10 @@ private final FieldAccessor getAccessor(Object object, String columnName) { final FieldAccessor acc = get(columnName); if (acc == null) { Object[] params = {object.getClass(), columnName, this}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("Error: getting value from [{}] because column [{}] does not have a corresponding getter method or field access. {}", params)); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Error: getting value from [{}] because column [{}] does not have a corresponding getter method or field access. {}", + params)); } return acc; } @@ -103,19 +141,26 @@ public final Object getValue(Object object, String columnName) { try { return acc.get(object); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Object[] params = {(object == null ? "null" : object.getClass().getName()), acc.getFormattedString(), acc.getFormattedString(), object}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("Could not get a value from instance of [{}] for column [{}] with [{}] The instance is =[{}]", params), e); + Object[] params = { + (object == null ? "null" : object.getClass().getName()), + acc.getFormattedString(), + acc.getFormattedString(), + object + }; + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Could not get a value from instance of [{}] for column [{}] with [{}] The instance is =[{}]", + params), + e); } } - public Set keySet() { return columnToAccessorMap.keySet(); } - - private Map createAliasAccessors(String prefix, - Map accessors) { + private Map createAliasAccessors( + String prefix, Map accessors) { if (prefix.length() == 0) { return Collections.emptyMap(); } @@ -126,13 +171,13 @@ private Map createAliasAccessors(String prefix, String aKey = toCanonicalCase(prefix + key); if (accessors.containsKey(aKey)) { Object[] params = {prefix, key}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("Modify table alias because table alias [{}] and column [{}] is concatenated and it becomes duplicated column", params)); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Modify table alias because table alias [{}] and column [{}] is concatenated and it becomes duplicated column", + params)); } ret.put(aKey, accessors.get(key)); } return ret; } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlParametersToTableMapping.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlParametersToTableMapping.java index c65ec21c..c7bb3017 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlParametersToTableMapping.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlParametersToTableMapping.java @@ -29,9 +29,7 @@ import org.nkjmlab.sorm4j.util.logger.LogPoint; import org.nkjmlab.sorm4j.util.logger.LoggerContext; -/** - * Holds mapping data from a given class and a table - */ +/** Holds mapping data from a given class and a table */ public final class SqlParametersToTableMapping { private final Class objectClass; @@ -45,11 +43,16 @@ public final class SqlParametersToTableMapping { private final TableSql sql; private final LoggerContext loggerContext; - public SqlParametersToTableMapping(LoggerContext loggerContext, + public SqlParametersToTableMapping( + LoggerContext loggerContext, ColumnValueToJavaObjectConverters columnValueConverter, - SqlParametersSetter sqlParametersSetter, PreparedStatementSupplier statementSupplier, - MultiRowProcessorFactory multiRowProcessorFactory, Class objectClass, - ColumnToAccessorMapping columnToAccessorMap, TableMetaDataImpl tableMetaData, TableSql sql) { + SqlParametersSetter sqlParametersSetter, + PreparedStatementSupplier statementSupplier, + MultiRowProcessorFactory multiRowProcessorFactory, + Class objectClass, + ColumnToAccessorMapping columnToAccessorMap, + TableMetaDataImpl tableMetaData, + TableSql sql) { this.columnValueConverter = columnValueConverter; this.objectClass = objectClass; this.columnToAccessorMap = columnToAccessorMap; @@ -58,12 +61,13 @@ public SqlParametersToTableMapping(LoggerContext loggerContext, this.sql = sql; this.sqlParametersSetter = sqlParametersSetter; this.statementSupplier = statementSupplier; - this.multiRowProcessor = multiRowProcessorFactory.getMultiRowProcessor(loggerContext, - sqlParametersSetter, statementSupplier, objectClass, this); + this.multiRowProcessor = + multiRowProcessorFactory.getMultiRowProcessor( + loggerContext, sqlParametersSetter, statementSupplier, objectClass, this); } - public int[] batch(Connection con, String sql, Function parameterCreator, - T[] objects) { + public int[] batch( + Connection con, String sql, Function parameterCreator, T[] objects) { return this.multiRowProcessor.batch(con, sql, parameterCreator, objects); } @@ -91,8 +95,9 @@ public Object[] getMergeParameters(T object) { public Object[] getParameters(Object object, List columns) { if (object == null) { Object[] params = {objectClass}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256 - .format("Fail to get value from a instance of [{}] but it is null.", params)); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Fail to get value from a instance of [{}] but it is null.", params)); } final Object[] ret = new Object[columns.size()]; @@ -130,16 +135,18 @@ public final int[] insert(Connection con, T[] objects) { public InsertResult insertAndGet(Connection connection, T object) { String insertSql = sql.getInsertSql(); - try (PreparedStatement stmt = !tableMetaData.hasAutoGeneratedColumns() - ? statementSupplier.prepareStatement(connection, insertSql) - : statementSupplier.prepareStatement(connection, insertSql, - tableMetaData.getAutoGeneratedColumnsArray())) { + try (PreparedStatement stmt = + !tableMetaData.hasAutoGeneratedColumns() + ? statementSupplier.prepareStatement(connection, insertSql) + : statementSupplier.prepareStatement( + connection, insertSql, tableMetaData.getAutoGeneratedColumnsArray())) { Object[] parameters = getInsertParameters(object); sqlParametersSetter.setParameters(stmt, parameters); - Optional lp = loggerContext.createLogPoint(LoggerContext.Category.EXECUTE_UPDATE, - SqlParametersToTableMapping.class); + Optional lp = + loggerContext.createLogPoint( + LoggerContext.Category.EXECUTE_UPDATE, SqlParametersToTableMapping.class); lp.ifPresent(_lp -> _lp.logBeforeSql(connection, insertSql, parameters)); int rowsModified = stmt.executeUpdate(); @@ -155,7 +162,6 @@ public InsertResult insertAndGet(Connection connection, T object) { } /** - * * @param con * @param objects not allow {@code null} or {@code 0} length * @return @@ -188,30 +194,34 @@ private RowMap getGeneratedKeys(PreparedStatement stmt, T object) throws SQLExce } } - - public int[] merge(Connection con, T[] objects) { int[] result = multiRowProcessor.multiRowMerge(con, objects); return result; } - - private void throwExeptionIfPrimaryKeyIsNotExist() { if (!tableMetaData.hasPrimaryKey()) { - throw new SormException("This opperation requiers primary keys but Table [" - + tableMetaData.getTableName() + "] doesn't have them."); + throw new SormException( + "This opperation requiers primary keys but Table [" + + tableMetaData.getTableName() + + "] doesn't have them."); } } @Override public String toString() { - return "[" + objectClass.getName() + "] class is mapped to [" + tableMetaData.getTableName() - + "] Table. [" + objectClass.getName() + "] could set/get values for following columns." - + lineSeparator() + columnToAccessorMap.toString() + lineSeparator() + " with [" - + multiRowProcessor.getClass().getSimpleName() + "]"; + return "[" + + objectClass.getName() + + "] class is mapped to [" + + tableMetaData.getTableName() + + "] Table. [" + + objectClass.getName() + + "] could set/get values for following columns." + + lineSeparator() + + columnToAccessorMap.toString() + + lineSeparator() + + " with [" + + multiRowProcessor.getClass().getSimpleName() + + "]"; } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToColumnsMapping.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToColumnsMapping.java index 06f59b4f..1a9a3b70 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToColumnsMapping.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToColumnsMapping.java @@ -19,11 +19,10 @@ import org.nkjmlab.sorm4j.internal.util.Try; /** - * Holds mapping data from a given class and a table. The object reads a query result in - * {@link ResultSet} via {@link DefaultColumnValueToJavaObjectConverters}. + * Holds mapping data from a given class and a table. The object reads a query result in {@link + * ResultSet} via {@link DefaultColumnValueToJavaObjectConverters}. * * @author nkjm - * * @param */ public final class SqlResultToColumnsMapping { @@ -35,28 +34,31 @@ public final class SqlResultToColumnsMapping { private final ColumnToAccessorMapping columnToAccessorMap; private final SqlResultToContainerMapping containerObjectCreator; - public SqlResultToColumnsMapping(ColumnValueToJavaObjectConverters converter, - Class objectClass, ColumnToAccessorMapping columnToAccessorMap) { + public SqlResultToColumnsMapping( + ColumnValueToJavaObjectConverters converter, + Class objectClass, + ColumnToAccessorMapping columnToAccessorMap) { this.columnValueConverter = converter; this.objectClass = objectClass; this.columnToAccessorMap = columnToAccessorMap; Constructor ormConstructor = getOrmConstructor(objectClass); Constructor ormRecordConstructor = getOrmRecordConstructor(objectClass); - this.containerObjectCreator = ormRecordConstructor != null - ? createContainerRecordCreator(objectClass, ormRecordConstructor) - : (ormConstructor != null ? createOrmConstructorPojoCreator(objectClass, ormConstructor) - : new SqlResultToContainerMappingWithSetter<>(columnToAccessorMap, - getDefaultConstructor(objectClass))); - + this.containerObjectCreator = + ormRecordConstructor != null + ? createContainerRecordCreator(objectClass, ormRecordConstructor) + : (ormConstructor != null + ? createOrmConstructorPojoCreator(objectClass, ormConstructor) + : new SqlResultToContainerMappingWithSetter<>( + columnToAccessorMap, getDefaultConstructor(objectClass))); } - private SqlResultToContainerMapping createContainerRecordCreator(Class objectClass, - Constructor constructor) { + private SqlResultToContainerMapping createContainerRecordCreator( + Class objectClass, Constructor constructor) { String[] parameterNames = Arrays.stream(objectClass.getDeclaredFields()).map(f -> f.getName()).toArray(String[]::new); - return new SqlResultToContainerMappingWithConstructor<>(getColumnToAccessorMap(), constructor, - parameterNames); + return new SqlResultToContainerMappingWithConstructor<>( + getColumnToAccessorMap(), constructor, parameterNames); } private Constructor getOrmRecordConstructor(Class objectClass) { @@ -66,20 +68,33 @@ private Constructor getOrmRecordConstructor(Class objectClass) { } Object[] params = {objectClass, OrmRecord.class.getSimpleName()}; return Try.getOrElseThrow( - () -> objectClass.getConstructor(Arrays.stream(objectClass.getDeclaredFields()) - .filter(f -> !java.lang.reflect.Modifier.isStatic(f.getModifiers())) - .map(f -> f.getType()).toArray(Class[]::new)), - e -> new SormException(ParameterizedStringFormatter.LENGTH_256.format("The given container class [{}] annotated by @{} should have the canonical constructor.", params), e)); + () -> + objectClass.getConstructor( + Arrays.stream(objectClass.getDeclaredFields()) + .filter(f -> !java.lang.reflect.Modifier.isStatic(f.getModifiers())) + .map(f -> f.getType()) + .toArray(Class[]::new)), + e -> + new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "The given container class [{}] annotated by @{} should have the canonical constructor.", + params), + e)); } private Constructor getOrmConstructor(Class objectClass) { - List> ormConstructors = Arrays.stream(objectClass.getConstructors()) - .filter(c -> c.getAnnotation(OrmConstructor.class) != null).collect(Collectors.toList()); + List> ormConstructors = + Arrays.stream(objectClass.getConstructors()) + .filter(c -> c.getAnnotation(OrmConstructor.class) != null) + .collect(Collectors.toList()); if (ormConstructors.isEmpty()) { return null; } else if (ormConstructors.size() > 1) { Object[] params = {objectClass, OrmConstructor.class.getSimpleName()}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("The given container class [{}] should have one or less constructor annotated by @{}.", params)); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "The given container class [{}] should have one or less constructor annotated by @{}.", + params)); } else { @SuppressWarnings("unchecked") Constructor constructor = (Constructor) ormConstructors.get(0); @@ -87,28 +102,38 @@ private Constructor getOrmConstructor(Class objectClass) { } } - private SqlResultToContainerMapping createOrmConstructorPojoCreator(Class objectClass, - Constructor constructor) { + private SqlResultToContainerMapping createOrmConstructorPojoCreator( + Class objectClass, Constructor constructor) { String[] _parameters = constructor.getAnnotation(OrmConstructor.class).value(); - return new SqlResultToContainerMappingWithConstructor<>(getColumnToAccessorMap(), constructor, - _parameters); + return new SqlResultToContainerMappingWithConstructor<>( + getColumnToAccessorMap(), constructor, _parameters); } - private Constructor getDefaultConstructor(Class objectClass) { - Object[] params = {objectClass, OrmConstructor.class.getSimpleName(), OrmRecord.class.getSimpleName()}; - return Try.getOrElseThrow(() -> objectClass.getConstructor(), e -> new SormException(ParameterizedStringFormatter.LENGTH_256.format("The given container class [{}] should have the public default constructor or the constructor annotated by @{}. Or the container class should be annotated by @{}.", params), e)); + Object[] params = { + objectClass, OrmConstructor.class.getSimpleName(), OrmRecord.class.getSimpleName() + }; + return Try.getOrElseThrow( + () -> objectClass.getConstructor(), + e -> + new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "The given container class [{}] should have the public default constructor or the constructor annotated by @{}. Or the container class should be annotated by @{}.", + params), + e)); } - - public List traverseAndMap(ResultSet resultSet) throws SQLException { ColumnsAndTypes columnsAndTypes = OrmConnectionImpl.ColumnsAndTypes.createColumnsAndTypes(resultSet); String columnsString = getObjectColumnsString(columnsAndTypes.getColumns()); - return containerObjectCreator.loadContainerObjectList(columnValueConverter, resultSet, - columnsAndTypes.getColumns(), columnsAndTypes.getColumnTypes(), columnsString); + return containerObjectCreator.loadContainerObjectList( + columnValueConverter, + resultSet, + columnsAndTypes.getColumns(), + columnsAndTypes.getColumnTypes(), + columnsString); } public T loadResultContainerObject(ResultSet resultSet) throws SQLException { @@ -117,17 +142,24 @@ public T loadResultContainerObject(ResultSet resultSet) throws SQLException { OrmConnectionImpl.ColumnsAndTypes.createColumnsAndTypes(resultSet); String columnsString = getObjectColumnsString(columnsAndTypes.getColumns()); - return containerObjectCreator.loadContainerObject(columnValueConverter, resultSet, - columnsAndTypes.getColumns(), columnsAndTypes.getColumnTypes(), columnsString); + return containerObjectCreator.loadContainerObject( + columnValueConverter, + resultSet, + columnsAndTypes.getColumns(), + columnsAndTypes.getColumnTypes(), + columnsString); } public T loadResultContainerObjectByPrimaryKey(Class objectClass, ResultSet resultSet) throws SQLException { - ColumnsAndTypesAndString columnsAndTypesAndString = metaDataForSelectByPrimaryKey - .computeIfAbsent(objectClass, key -> ColumnsAndTypesAndString.create(resultSet)); + ColumnsAndTypesAndString columnsAndTypesAndString = + metaDataForSelectByPrimaryKey.computeIfAbsent( + objectClass, key -> ColumnsAndTypesAndString.create(resultSet)); - return containerObjectCreator.loadContainerObject(columnValueConverter, resultSet, + return containerObjectCreator.loadContainerObject( + columnValueConverter, + resultSet, columnsAndTypesAndString.columnsAndTypes.getColumns(), columnsAndTypesAndString.columnsAndTypes.getColumnTypes(), columnsAndTypesAndString.columnsString); @@ -153,26 +185,27 @@ static ColumnsAndTypesAndString create(ResultSet resultSet) { throw Try.rethrow(e); } } - } private static String getObjectColumnsString(String[] columns) { return String.join("-", columns); } - - ColumnToAccessorMapping getColumnToAccessorMap() { return columnToAccessorMap; } - @Override public String toString() { - Object[] params = {objectClass.getName(), containerObjectCreator.getClass().getSimpleName(), containerObjectCreator.toString()}; - return ParameterizedStringFormatter.LENGTH_256.format("[{}] instance used as SQL result container will be created by [{}]" - + System.lineSeparator() + "{}", params); + Object[] params = { + objectClass.getName(), + containerObjectCreator.getClass().getSimpleName(), + containerObjectCreator.toString() + }; + return ParameterizedStringFormatter.LENGTH_256.format( + "[{}] instance used as SQL result container will be created by [{}]" + + System.lineSeparator() + + "{}", + params); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMapping.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMapping.java index b2c9bc8e..46900936 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMapping.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMapping.java @@ -6,29 +6,39 @@ import java.util.List; import org.nkjmlab.sorm4j.context.ColumnValueToJavaObjectConverters; - abstract class SqlResultToContainerMapping { protected final Constructor constructor; protected final ColumnToAccessorMapping columnToAccessorMap; - public SqlResultToContainerMapping(ColumnToAccessorMapping columnToAccessorMap, - Constructor constructor) { + public SqlResultToContainerMapping( + ColumnToAccessorMapping columnToAccessorMap, Constructor constructor) { this.columnToAccessorMap = columnToAccessorMap; this.constructor = constructor; } - abstract List loadContainerObjectList(ColumnValueToJavaObjectConverters columnValueConverter, - ResultSet resultSet, String[] columns, int[] columnTypes, String columnsString) + abstract List loadContainerObjectList( + ColumnValueToJavaObjectConverters columnValueConverter, + ResultSet resultSet, + String[] columns, + int[] columnTypes, + String columnsString) throws SQLException; - abstract T loadContainerObject(ColumnValueToJavaObjectConverters columnValueConverter, - ResultSet resultSet, String[] columns, int[] columnTypes, String columnsString) + abstract T loadContainerObject( + ColumnValueToJavaObjectConverters columnValueConverter, + ResultSet resultSet, + String[] columns, + int[] columnTypes, + String columnsString) throws SQLException; @Override public String toString() { - return getClass().getSimpleName() + " [constructor=" + constructor + ", columnToAccessorMap=" - + columnToAccessorMap + "]"; + return getClass().getSimpleName() + + " [constructor=" + + constructor + + ", columnToAccessorMap=" + + columnToAccessorMap + + "]"; } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMappingWithConstructor.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMappingWithConstructor.java index 9f4ade53..9cfdf81c 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMappingWithConstructor.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMappingWithConstructor.java @@ -26,8 +26,10 @@ final class SqlResultToContainerMappingWithConstructor extends SqlResultToCon private final Map columnAndConstructorParameterMapping = new ConcurrentHashMap<>(); - public SqlResultToContainerMappingWithConstructor(ColumnToAccessorMapping columnToAccessorMap, - Constructor constructor, String[] parameterNames) { + public SqlResultToContainerMappingWithConstructor( + ColumnToAccessorMapping columnToAccessorMap, + Constructor constructor, + String[] parameterNames) { super(columnToAccessorMap, constructor); String columnAliasPrefix = columnToAccessorMap.getColumnAliasPrefix(); Parameter[] parameters = constructor.getParameters(); @@ -44,8 +46,9 @@ public SqlResultToContainerMappingWithConstructor(ColumnToAccessorMapping column } } - /** + * + * *

    * 
    * Pojo(int a, String b, int c);
@@ -63,11 +66,14 @@ public SqlResultToContainerMappingWithConstructor(ColumnToAccessorMapping column
    * @param resultSet
    * @param sqlTypes
    * @param constructorParameters ordered by column. if the column is not mapped to constructor
-   *        parameter, the value is null.
+   *     parameter, the value is null.
    * @return
    */
-  private S createContainerObject(ColumnValueToJavaObjectConverters columnValueConverter,
-      ResultSet resultSet, int[] sqlTypes, ConstructorParameter[] constructorParameters) {
+  private S createContainerObject(
+      ColumnValueToJavaObjectConverters columnValueConverter,
+      ResultSet resultSet,
+      int[] sqlTypes,
+      ConstructorParameter[] constructorParameters) {
     try {
       final Object[] params = new Object[constructorParametersLength];
 
@@ -76,68 +82,90 @@ private S createContainerObject(ColumnValueToJavaObjectConverters columnValueCon
         if (cp == null) {
           continue;
         }
-        params[cp.getOrder()] = columnValueConverter.convertTo(resultSet, i + 1, sqlTypes[i],
-            constructorParameters[i].getType());
+        params[cp.getOrder()] =
+            columnValueConverter.convertTo(
+                resultSet, i + 1, sqlTypes[i], constructorParameters[i].getType());
       }
       return constructor.newInstance(params);
-    } catch (IllegalArgumentException | SecurityException | InstantiationException
-        | IllegalAccessException | InvocationTargetException e) {
+    } catch (IllegalArgumentException
+        | SecurityException
+        | InstantiationException
+        | IllegalAccessException
+        | InvocationTargetException e) {
       Object[] params = {JdbcTypeUtils.convert(sqlTypes), constructorParameters};
-      throw new SormException(ParameterizedStringFormatter.LENGTH_256.format("Constructor with parameters of container class for object-relation mapping is not match with columns. param={}, sqltypes={}", params), e);
+      throw new SormException(
+          ParameterizedStringFormatter.LENGTH_256.format(
+              "Constructor with parameters of container class for object-relation mapping is not match with columns. param={}, sqltypes={}",
+              params),
+          e);
     }
   }
 
-
-  private ConstructorParameter[] getCorrespondingParameter(String[] columns,
-      String objectColumnsStr) {
-    return columnAndConstructorParameterMapping.computeIfAbsent(objectColumnsStr,
-        key -> Arrays.stream(columns).map(col -> constructorParametersMap.get(toCanonicalCase(col)))
-            .toArray(ConstructorParameter[]::new));
+  private ConstructorParameter[] getCorrespondingParameter(
+      String[] columns, String objectColumnsStr) {
+    return columnAndConstructorParameterMapping.computeIfAbsent(
+        objectColumnsStr,
+        key ->
+            Arrays.stream(columns)
+                .map(col -> constructorParametersMap.get(toCanonicalCase(col)))
+                .toArray(ConstructorParameter[]::new));
   }
 
   @Override
-  List loadContainerObjectList(ColumnValueToJavaObjectConverters columnValueConverter,
-      ResultSet resultSet, String[] columns, int[] columnTypes, String columnsString)
+  List loadContainerObjectList(
+      ColumnValueToJavaObjectConverters columnValueConverter,
+      ResultSet resultSet,
+      String[] columns,
+      int[] columnTypes,
+      String columnsString)
       throws SQLException {
     final ConstructorParameter[] constructorParameters =
         getCorrespondingParameter(columns, columnsString);
     final List ret = new ArrayList<>();
     while (resultSet.next()) {
-      ret.add(createContainerObject(columnValueConverter, resultSet, columnTypes,
-          constructorParameters));
+      ret.add(
+          createContainerObject(
+              columnValueConverter, resultSet, columnTypes, constructorParameters));
     }
     return ret;
   }
 
-
   @Override
-  S loadContainerObject(ColumnValueToJavaObjectConverters columnValueConverter, ResultSet resultSet,
-      String[] columns, int[] columnTypes, String columnsString) throws SQLException {
+  S loadContainerObject(
+      ColumnValueToJavaObjectConverters columnValueConverter,
+      ResultSet resultSet,
+      String[] columns,
+      int[] columnTypes,
+      String columnsString)
+      throws SQLException {
     final ConstructorParameter[] constructorParameters =
         getCorrespondingParameter(columns, columnsString);
-    return createContainerObject(columnValueConverter, resultSet, columnTypes,
-        constructorParameters);
+    return createContainerObject(
+        columnValueConverter, resultSet, columnTypes, constructorParameters);
   }
 
-
   @Override
   public String toString() {
     List keySet =
         constructorParametersMap.keySet().stream().sorted().collect(Collectors.toList());
-    Object[] params = {constructor, keySet, String.join(System.lineSeparator(),
-        keySet.stream().map(key -> "  " + key + "=>" + constructorParametersMap.get(key))
-            .collect(Collectors.toList()))};
-    return ParameterizedStringFormatter.LENGTH_256.format("constructor=[{}], arguments={}" + System.lineSeparator() + "{}", params);
-
+    Object[] params = {
+      constructor,
+      keySet,
+      String.join(
+          System.lineSeparator(),
+          keySet.stream()
+              .map(key -> "  " + key + "=>" + constructorParametersMap.get(key))
+              .collect(Collectors.toList()))
+    };
+    return ParameterizedStringFormatter.LENGTH_256.format(
+        "constructor=[{}], arguments={}" + System.lineSeparator() + "{}", params);
   }
 
-
-  final static class ConstructorParameter {
+  static final class ConstructorParameter {
     private final String name;
-    /**
-     * Order in the constructor parameter
-     */
+    /** Order in the constructor parameter */
     private final int order;
+
     private final Class type;
 
     public ConstructorParameter(String name, int order, Class type) {
@@ -158,7 +186,5 @@ public Class getType() {
     public String toString() {
       return "[name=" + name + ", order=" + order + ", type=" + type + "]";
     }
-
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMappingWithSetter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMappingWithSetter.java
index 28df6013..f95b7381 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMappingWithSetter.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/SqlResultToContainerMappingWithSetter.java
@@ -18,45 +18,61 @@ final class SqlResultToContainerMappingWithSetter extends SqlResultToContaine
   // https://github.com/yuu-nkjm/sorm4j/issues/26
   private final Map[]> setterTypesMap = new ConcurrentHashMap<>();
 
-  public SqlResultToContainerMappingWithSetter(ColumnToAccessorMapping columnToAccessorMap,
-      Constructor constructor) {
+  public SqlResultToContainerMappingWithSetter(
+      ColumnToAccessorMapping columnToAccessorMap, Constructor constructor) {
     super(columnToAccessorMap, constructor);
   }
 
   private Class[] getSetterTypes(String[] columns, String objectColumnsStr) {
-    return setterTypesMap.computeIfAbsent(objectColumnsStr,
-        k -> Arrays.stream(columns).map(columnName -> {
-          FieldAccessor acc = columnToAccessorMap.get(columnName);
-          return acc != null ? acc.getSetterParameterType() : null;
-        }).toArray(Class[]::new));
+    return setterTypesMap.computeIfAbsent(
+        objectColumnsStr,
+        k ->
+            Arrays.stream(columns)
+                .map(
+                    columnName -> {
+                      FieldAccessor acc = columnToAccessorMap.get(columnName);
+                      return acc != null ? acc.getSetterParameterType() : null;
+                    })
+                .toArray(Class[]::new));
   }
 
-
   @Override
-  T loadContainerObject(ColumnValueToJavaObjectConverters columnValueConverter, ResultSet resultSet,
-      String[] columns, int[] columnTypes, String columnsString) throws SQLException {
+  T loadContainerObject(
+      ColumnValueToJavaObjectConverters columnValueConverter,
+      ResultSet resultSet,
+      String[] columns,
+      int[] columnTypes,
+      String columnsString)
+      throws SQLException {
     final Class[] setterTypes = getSetterTypes(columns, columnsString);
-    return createContainerObject(columnValueConverter, resultSet, columns, columnTypes,
-        setterTypes);
+    return createContainerObject(
+        columnValueConverter, resultSet, columns, columnTypes, setterTypes);
   }
 
-
-
   @Override
-  public List loadContainerObjectList(ColumnValueToJavaObjectConverters columnValueConverter,
-      ResultSet resultSet, String[] columns, int[] columnTypes, String columnsString)
+  public List loadContainerObjectList(
+      ColumnValueToJavaObjectConverters columnValueConverter,
+      ResultSet resultSet,
+      String[] columns,
+      int[] columnTypes,
+      String columnsString)
       throws SQLException {
     final Class[] setterTypes = getSetterTypes(columns, columnsString);
     final List ret = new ArrayList<>();
     while (resultSet.next()) {
-      ret.add(createContainerObject(columnValueConverter, resultSet, columns, columnTypes,
-          setterTypes));
+      ret.add(
+          createContainerObject(
+              columnValueConverter, resultSet, columns, columnTypes, setterTypes));
     }
     return ret;
   }
 
-  private T createContainerObject(ColumnValueToJavaObjectConverters columnValueConverter,
-      ResultSet resultSet, String[] columns, int[] sqlTypes, Class[] setterTypes) {
+  private T createContainerObject(
+      ColumnValueToJavaObjectConverters columnValueConverter,
+      ResultSet resultSet,
+      String[] columns,
+      int[] sqlTypes,
+      Class[] setterTypes) {
     try {
       final T ret = constructor.newInstance();
       for (int i = 1; i <= columns.length; i++) {
@@ -73,14 +89,14 @@ private T createContainerObject(ColumnValueToJavaObjectConverters columnValueCon
         columnToAccessorMap.setValue(ret, columnName, value);
       }
       return ret;
-    } catch (IllegalArgumentException | SecurityException | InstantiationException
-        | IllegalAccessException | InvocationTargetException e) {
+    } catch (IllegalArgumentException
+        | SecurityException
+        | InstantiationException
+        | IllegalAccessException
+        | InvocationTargetException e) {
       throw new SormException(
           "Container class for object relation mapping must have the public default constructor.",
           e);
     }
   }
-
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/TableName.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/TableName.java
index 516d5202..fe346851 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/TableName.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/TableName.java
@@ -6,7 +6,6 @@
  * Value object of table name.
  *
  * @author nkjm
- *
  */
 public final class TableName {
 
@@ -18,10 +17,8 @@ public TableName(String name) {
 
   @Override
   public boolean equals(Object obj) {
-    if (this == obj)
-      return true;
-    if (!(obj instanceof TableName))
-      return false;
+    if (this == obj) return true;
+    if (!(obj instanceof TableName)) return false;
     TableName other = (TableName) obj;
     return Objects.equals(name, other.name);
   }
@@ -31,7 +28,6 @@ public boolean equals(Object obj) {
    *
    * @return
    */
-
   public String getName() {
     return name;
   }
@@ -41,12 +37,9 @@ public int hashCode() {
     return Objects.hash(name);
   }
 
-  /**
-   * Uses {@link #getName()} when you want to get name.
-   */
+  /** Uses {@link #getName()} when you want to get name. */
   @Override
   public String toString() {
     return name;
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/BatchOfMultiRowInOneStatementProcessor.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/BatchOfMultiRowInOneStatementProcessor.java
index 0e8a5b82..6d24a7d4 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/BatchOfMultiRowInOneStatementProcessor.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/BatchOfMultiRowInOneStatementProcessor.java
@@ -19,7 +19,6 @@
  * {@link SormContext}
  *
  * @author nkjm
- *
  * @param 
  */
 public final class BatchOfMultiRowInOneStatementProcessor extends MultiRowProcessor {
@@ -27,9 +26,13 @@ public final class BatchOfMultiRowInOneStatementProcessor extends MultiRowPro
   private final int multiRowSize;
   private final int batchSizeWithMultiRow;
 
-  public BatchOfMultiRowInOneStatementProcessor(LoggerContext loggerContext,
-      SqlParametersSetter sqlParametersSetter, PreparedStatementSupplier statementSupplier,
-      SqlParametersToTableMapping tableMapping, int batchSize, int multiRowSize,
+  public BatchOfMultiRowInOneStatementProcessor(
+      LoggerContext loggerContext,
+      SqlParametersSetter sqlParametersSetter,
+      PreparedStatementSupplier statementSupplier,
+      SqlParametersToTableMapping tableMapping,
+      int batchSize,
+      int multiRowSize,
       int batchSizeWithMultiRow) {
     super(loggerContext, sqlParametersSetter, statementSupplier, tableMapping, batchSize);
     this.multiRowSize = multiRowSize;
@@ -38,18 +41,28 @@ public BatchOfMultiRowInOneStatementProcessor(LoggerContext loggerContext,
 
   @Override
   public final int[] multiRowInsert(Connection con, T[] objects) {
-    return execMultiRowProcIfValidObjects(con, objects,
-        nonNullObjects -> procMultiRowOneStatementAndBatch(con,
-            num -> prepareStatement(con, getSql().getMultirowInsertSql(num)),
-            (stmt, objs) -> setPrametersOfMultiRow(stmt, objs), nonNullObjects));
+    return execMultiRowProcIfValidObjects(
+        con,
+        objects,
+        nonNullObjects ->
+            procMultiRowOneStatementAndBatch(
+                con,
+                num -> prepareStatement(con, getSql().getMultirowInsertSql(num)),
+                (stmt, objs) -> setPrametersOfMultiRow(stmt, objs),
+                nonNullObjects));
   }
 
   @Override
   public final int[] multiRowMerge(Connection con, T[] objects) {
-    return execMultiRowProcIfValidObjects(con, objects,
-        nonNullObjects -> procMultiRowOneStatementAndBatch(con,
-            num -> prepareStatement(con, getSql().getMultirowMergeSql(num)),
-            (stmt, objs) -> setPrametersOfMultiRow(stmt, objs), nonNullObjects));
+    return execMultiRowProcIfValidObjects(
+        con,
+        objects,
+        nonNullObjects ->
+            procMultiRowOneStatementAndBatch(
+                con,
+                num -> prepareStatement(con, getSql().getMultirowMergeSql(num)),
+                (stmt, objs) -> setPrametersOfMultiRow(stmt, objs),
+                nonNullObjects));
   }
 
   /**
@@ -60,9 +73,11 @@ public final int[] multiRowMerge(Connection con, T[] objects) {
    * @param objects
    * @return
    */
-  private final int[] procMultiRowOneStatementAndBatch(Connection con,
+  private final int[] procMultiRowOneStatementAndBatch(
+      Connection con,
       ThrowableFunction multiRowStatementCreator,
-      ThrowableBiConsumer parametersSetter, T[] objects) {
+      ThrowableBiConsumer parametersSetter,
+      T[] objects) {
 
     final List objsPartitions = ArrayUtils.split(multiRowSize, objects);
     final int[] result = new int[objsPartitions.size()];
@@ -95,9 +110,5 @@ private final int[] procMultiRowOneStatementAndBatch(Connection con,
       OrmConnectionImpl.commitOrRollback(con, origAutoCommit);
       OrmConnectionImpl.setAutoCommit(con, origAutoCommit);
     }
-
   }
-
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowInOneStatementProcessor.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowInOneStatementProcessor.java
index 7bfa7d31..114075ad 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowInOneStatementProcessor.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowInOneStatementProcessor.java
@@ -17,34 +17,48 @@ public final class MultiRowInOneStatementProcessor extends MultiRowProcessor<
 
   private final int multiRowSize;
 
-  public MultiRowInOneStatementProcessor(LoggerContext loggerContext,
-      SqlParametersSetter sqlParametersSetter, PreparedStatementSupplier statementSupplier,
-      SqlParametersToTableMapping tableMapping, int batchSize, int multiRowSize) {
+  public MultiRowInOneStatementProcessor(
+      LoggerContext loggerContext,
+      SqlParametersSetter sqlParametersSetter,
+      PreparedStatementSupplier statementSupplier,
+      SqlParametersToTableMapping tableMapping,
+      int batchSize,
+      int multiRowSize) {
     super(loggerContext, sqlParametersSetter, statementSupplier, tableMapping, batchSize);
     this.multiRowSize = multiRowSize;
-
   }
 
   @Override
   public final int[] multiRowInsert(Connection con, T[] objects) {
-    return execMultiRowProcIfValidObjects(con, objects,
-        nonNullObjects -> procMultiRowOneStatement(con,
-            num -> prepareStatement(con, getSql().getMultirowInsertSql(num)),
-            (stmt, objs) -> setPrametersOfMultiRow(stmt, objs), nonNullObjects));
+    return execMultiRowProcIfValidObjects(
+        con,
+        objects,
+        nonNullObjects ->
+            procMultiRowOneStatement(
+                con,
+                num -> prepareStatement(con, getSql().getMultirowInsertSql(num)),
+                (stmt, objs) -> setPrametersOfMultiRow(stmt, objs),
+                nonNullObjects));
   }
 
   @Override
   public final int[] multiRowMerge(Connection con, T[] objects) {
-    return execMultiRowProcIfValidObjects(con, objects,
-        nonNullObjects -> procMultiRowOneStatement(con,
-            num -> prepareStatement(con, getSql().getMultirowMergeSql(num)),
-            (stmt, objs) -> setPrametersOfMultiRow(stmt, objs), nonNullObjects));
+    return execMultiRowProcIfValidObjects(
+        con,
+        objects,
+        nonNullObjects ->
+            procMultiRowOneStatement(
+                con,
+                num -> prepareStatement(con, getSql().getMultirowMergeSql(num)),
+                (stmt, objs) -> setPrametersOfMultiRow(stmt, objs),
+                nonNullObjects));
   }
 
-
-  private final int[] procMultiRowOneStatement(Connection con,
+  private final int[] procMultiRowOneStatement(
+      Connection con,
       ThrowableFunction multiRowStatementCreator,
-      ThrowableBiConsumer parametersSetter, T[] objects) {
+      ThrowableBiConsumer parametersSetter,
+      T[] objects) {
     final List objsPartitions = ArrayUtils.split(multiRowSize, objects);
     final int[] result = new int[objsPartitions.size()];
     final boolean origAutoCommit = OrmConnectionImpl.getAutoCommit(con);
@@ -73,7 +87,4 @@ private final int[] procMultiRowOneStatement(Connection con,
       OrmConnectionImpl.setAutoCommit(con, origAutoCommit);
     }
   }
-
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowProcessor.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowProcessor.java
index ba1f2504..6bcf7c0f 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowProcessor.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowProcessor.java
@@ -23,8 +23,11 @@ public abstract class MultiRowProcessor {
   private final SqlParametersToTableMapping tableMapping;
   private final LoggerContext loggerContext;
 
-  MultiRowProcessor(LoggerContext loggerContext, SqlParametersSetter sqlParametersSetter,
-      PreparedStatementSupplier statementSupplier, SqlParametersToTableMapping tableMapping,
+  MultiRowProcessor(
+      LoggerContext loggerContext,
+      SqlParametersSetter sqlParametersSetter,
+      PreparedStatementSupplier statementSupplier,
+      SqlParametersToTableMapping tableMapping,
       int batchSize) {
     this.loggerContext = loggerContext;
     this.statementSupplier = statementSupplier;
@@ -49,56 +52,62 @@ protected Object[] getMergeParameters(T obj) {
     return tableMapping.getMergeParameters(obj);
   }
 
-
   public final void setPrametersOfMultiRow(PreparedStatement stmt, T[] objects)
       throws SQLException {
-    Object[] parameters = Arrays.stream(objects)
-        .flatMap(obj -> Arrays.stream(tableMapping.getParametersWithoutAutoGeneratedColumns(obj)))
-        .toArray(Object[]::new);
+    Object[] parameters =
+        Arrays.stream(objects)
+            .flatMap(
+                obj -> Arrays.stream(tableMapping.getParametersWithoutAutoGeneratedColumns(obj)))
+            .toArray(Object[]::new);
     sqlParametersSetter.setParameters(stmt, parameters);
   }
 
-  public final int[] batch(Connection con, String sql, Function parameterCreator,
-      T[] objects) {
-    return execMultiRowProcIfValidObjects(con, objects, nonNullObjects -> {
-      int[] result = new int[0];
-      boolean origAutoCommit = OrmConnectionImpl.getAutoCommit(con);
-
-      try (PreparedStatement stmt = statementSupplier.prepareStatement(con, sql)) {
-        OrmConnectionImpl.setAutoCommit(con, false);
-        final BatchHelper batchHelper = new BatchHelper(batchSize, stmt);
-        for (int i = 0; i < objects.length; i++) {
-          T obj = objects[i];
-          this.sqlParametersSetter.setParameters(stmt, parameterCreator.apply(obj));
-          batchHelper.addBatchAndExecuteIfReachedThreshold();
-        }
-        result = batchHelper.finish();
-        return result;
-      } catch (SQLException e) {
-        throw Try.rethrow(e);
-      } finally {
-        OrmConnectionImpl.commitOrRollback(con, origAutoCommit);
-        OrmConnectionImpl.setAutoCommit(con, origAutoCommit);
-      }
-    });
+  public final int[] batch(
+      Connection con, String sql, Function parameterCreator, T[] objects) {
+    return execMultiRowProcIfValidObjects(
+        con,
+        objects,
+        nonNullObjects -> {
+          int[] result = new int[0];
+          boolean origAutoCommit = OrmConnectionImpl.getAutoCommit(con);
+
+          try (PreparedStatement stmt = statementSupplier.prepareStatement(con, sql)) {
+            OrmConnectionImpl.setAutoCommit(con, false);
+            final BatchHelper batchHelper = new BatchHelper(batchSize, stmt);
+            for (int i = 0; i < objects.length; i++) {
+              T obj = objects[i];
+              this.sqlParametersSetter.setParameters(stmt, parameterCreator.apply(obj));
+              batchHelper.addBatchAndExecuteIfReachedThreshold();
+            }
+            result = batchHelper.finish();
+            return result;
+          } catch (SQLException e) {
+            throw Try.rethrow(e);
+          } finally {
+            OrmConnectionImpl.commitOrRollback(con, origAutoCommit);
+            OrmConnectionImpl.setAutoCommit(con, origAutoCommit);
+          }
+        });
   }
 
-
-
   /**
    * Execute multirow sql function. objects when objects[0] is null, {@code NullPointerException}
    * are throw.
    */
-  final int[] execMultiRowProcIfValidObjects(Connection con, T[] objects,
-      Function exec) {
+  final int[] execMultiRowProcIfValidObjects(
+      Connection con, T[] objects, Function exec) {
     if (objects == null || objects.length == 0) {
       return new int[0];
     }
     Optional lp =
         loggerContext.createLogPoint(LoggerContext.Category.MULTI_ROW, MultiRowProcessor.class);
-    lp.ifPresent(_lp -> _lp.logBeforeMultiRow(con, objects[0].getClass(), objects.length,
-        tableMapping.getTableMetaData().getTableName()));
-
+    lp.ifPresent(
+        _lp ->
+            _lp.logBeforeMultiRow(
+                con,
+                objects[0].getClass(),
+                objects.length,
+                tableMapping.getTableMetaData().getTableName()));
 
     final int[] result = exec.apply(objects);
 
@@ -109,6 +118,4 @@ final int[] execMultiRowProcIfValidObjects(Connection con, T[] objects,
   protected PreparedStatement prepareStatement(Connection con, String sql) throws SQLException {
     return statementSupplier.prepareStatement(con, sql);
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowProcessorFactoryImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowProcessorFactoryImpl.java
index b4f9ff1a..7251c83d 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowProcessorFactoryImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowProcessorFactoryImpl.java
@@ -12,8 +12,11 @@ public class MultiRowProcessorFactoryImpl implements MultiRowProcessorFactory {
   private final int batchSizeWithMultiRow;
   private final int multiRowSize;
 
-  public MultiRowProcessorFactoryImpl(MultiRowProcessorType multiRowProcessorType, int batchSize,
-      int multiRowSize, int batchSizeWithMultiRow) {
+  public MultiRowProcessorFactoryImpl(
+      MultiRowProcessorType multiRowProcessorType,
+      int batchSize,
+      int multiRowSize,
+      int batchSizeWithMultiRow) {
     this.multiRowProcessorType = multiRowProcessorType;
     this.batchSize = batchSize;
     this.multiRowSize = multiRowSize;
@@ -21,19 +24,33 @@ public MultiRowProcessorFactoryImpl(MultiRowProcessorType multiRowProcessorType,
   }
 
   @Override
-  public  MultiRowProcessor getMultiRowProcessor(LoggerContext loggerContext,
-      SqlParametersSetter sqlParametersSetter, PreparedStatementSupplier statementSupplier,
-      Class objectClass, SqlParametersToTableMapping tableMapping) {
+  public  MultiRowProcessor getMultiRowProcessor(
+      LoggerContext loggerContext,
+      SqlParametersSetter sqlParametersSetter,
+      PreparedStatementSupplier statementSupplier,
+      Class objectClass,
+      SqlParametersToTableMapping tableMapping) {
     switch (multiRowProcessorType) {
       case SIMPLE_BATCH:
-        return new SimpleBatchProcessor<>(loggerContext, sqlParametersSetter, statementSupplier,
-            tableMapping, batchSize);
+        return new SimpleBatchProcessor<>(
+            loggerContext, sqlParametersSetter, statementSupplier, tableMapping, batchSize);
       case MULTI_ROW:
-        return new MultiRowInOneStatementProcessor<>(loggerContext, sqlParametersSetter,
-            statementSupplier, tableMapping, batchSize, multiRowSize);
+        return new MultiRowInOneStatementProcessor<>(
+            loggerContext,
+            sqlParametersSetter,
+            statementSupplier,
+            tableMapping,
+            batchSize,
+            multiRowSize);
       case MULTI_ROW_AND_BATCH:
-        return new BatchOfMultiRowInOneStatementProcessor<>(loggerContext, sqlParametersSetter,
-            statementSupplier, tableMapping, batchSize, multiRowSize, batchSizeWithMultiRow);
+        return new BatchOfMultiRowInOneStatementProcessor<>(
+            loggerContext,
+            sqlParametersSetter,
+            statementSupplier,
+            tableMapping,
+            batchSize,
+            multiRowSize,
+            batchSizeWithMultiRow);
       default:
         throw new IllegalStateException(multiRowProcessorType + " is invalid");
     }
@@ -41,9 +58,14 @@ public  MultiRowProcessor getMultiRowProcessor(LoggerContext loggerContext
 
   @Override
   public String toString() {
-    return "MultiRowProcessorFactory [multiRowProcessorType=" + multiRowProcessorType
-        + ", batchSize=" + batchSize + ", batchSizeWithMultiRow=" + batchSizeWithMultiRow
-        + ", multiRowSize=" + multiRowSize + "]";
+    return "MultiRowProcessorFactory [multiRowProcessorType="
+        + multiRowProcessorType
+        + ", batchSize="
+        + batchSize
+        + ", batchSizeWithMultiRow="
+        + batchSizeWithMultiRow
+        + ", multiRowSize="
+        + multiRowSize
+        + "]";
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/SimpleBatchProcessor.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/SimpleBatchProcessor.java
index 7b9a4ae1..c3a7047c 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/SimpleBatchProcessor.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/mapping/multirow/SimpleBatchProcessor.java
@@ -7,8 +7,11 @@
 import org.nkjmlab.sorm4j.util.logger.LoggerContext;
 
 final class SimpleBatchProcessor extends MultiRowProcessor {
-  public SimpleBatchProcessor(LoggerContext loggerContext, SqlParametersSetter sqlParametersSetter,
-      PreparedStatementSupplier statementSupplier, SqlParametersToTableMapping tableMapping,
+  public SimpleBatchProcessor(
+      LoggerContext loggerContext,
+      SqlParametersSetter sqlParametersSetter,
+      PreparedStatementSupplier statementSupplier,
+      SqlParametersToTableMapping tableMapping,
       int batchSize) {
     super(loggerContext, sqlParametersSetter, statementSupplier, tableMapping, batchSize);
   }
@@ -22,5 +25,4 @@ public final int[] multiRowInsert(Connection con, T[] objects) {
   public final int[] multiRowMerge(Connection con, T[] objects) {
     return batch(con, getSql().getMergeSql(), obj -> getMergeParameters(obj), objects);
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/AbstractResultSetStream.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/AbstractResultSetStream.java
index 0d98791f..1a357c71 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/AbstractResultSetStream.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/AbstractResultSetStream.java
@@ -32,10 +32,11 @@ public AbstractResultSetStream(Class objectClass, String sql, Object[] parame
 
   @Override
   public void accept(ConsumerHandler> handler) {
-    apply(stream -> {
-      handler.accept(stream);
-      return null;
-    });
+    apply(
+        stream -> {
+          handler.accept(stream);
+          return null;
+        });
   }
 
   public  R apply(OrmConnectionImpl ormConn, FunctionHandler, R> handler) {
@@ -53,10 +54,11 @@ public  R apply(OrmConnectionImpl ormConn, FunctionHandler, R> hand
       lp.ifPresent(_lp -> _lp.logBeforeSql(ormConn.getJdbcConnection(), sql, parameters));
 
       try (ResultSet resultSet = stmt.executeQuery()) {
-        Stream stream = StreamSupport.stream(
-            Spliterators.spliteratorUnknownSize(
-                new ResultSetIterator(ormConn, objectClass, resultSet), Spliterator.ORDERED),
-            false);
+        Stream stream =
+            StreamSupport.stream(
+                Spliterators.spliteratorUnknownSize(
+                    new ResultSetIterator(ormConn, objectClass, resultSet), Spliterator.ORDERED),
+                false);
         R ret = handler.apply(stream);
         lp.ifPresent(_lp -> _lp.logAfterQuery(ret));
         return ret;
@@ -65,6 +67,4 @@ public  R apply(OrmConnectionImpl ormConn, FunctionHandler, R> hand
       throw Try.rethrow(e);
     }
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/InsertResultImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/InsertResultImpl.java
index d1f9bed8..723872a8 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/InsertResultImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/InsertResultImpl.java
@@ -5,9 +5,7 @@
 import org.nkjmlab.sorm4j.result.InsertResult;
 import org.nkjmlab.sorm4j.result.RowMap;
 
-/**
- * Represents a result from an insert operation with auto-generated keys.
- */
+/** Represents a result from an insert operation with auto-generated keys. */
 public final class InsertResultImpl implements InsertResult {
 
   public static final InsertResult EMPTY_INSERT_RESULT =
@@ -17,7 +15,6 @@ public final class InsertResultImpl implements InsertResult {
   private final int countRowsModified;
 
   /**
-   *
    * @param rowsModified Returns the row count by executing a insert statement
    * @param generatedKeys auto-generated keys by executing a insert statement
    */
@@ -28,8 +25,8 @@ public InsertResultImpl(int[] rowsModified, RowMap generatedKeys) {
   }
 
   /**
-   * Returns the row count by executing a insert statement
-   * {@link java.sql.PreparedStatement#executeUpdate()}.
+   * Returns the row count by executing a insert statement {@link
+   * java.sql.PreparedStatement#executeUpdate()}.
    */
   @Override
   public int[] getRowsModified() {
@@ -48,13 +45,15 @@ public RowMap getGeneratedKeys() {
 
   @Override
   public String toString() {
-    return "InsertResultImpl [rowsModified=" + Arrays.toString(rowsModified) + ", generatedKeys="
-        + generatedKeys + "]";
+    return "InsertResultImpl [rowsModified="
+        + Arrays.toString(rowsModified)
+        + ", generatedKeys="
+        + generatedKeys
+        + "]";
   }
 
   @Override
   public int countRowsModified() {
     return countRowsModified;
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetIterator.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetIterator.java
index a85520d0..637965c0 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetIterator.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetIterator.java
@@ -12,12 +12,11 @@ class ResultSetIterator implements Iterator {
   private final Class objectClass;
   private final ResultSet resultSet;
 
-  public ResultSetIterator(OrmConnectionImpl connection, Class objectClass,
-      ResultSet resultSet) {
+  public ResultSetIterator(
+      OrmConnectionImpl connection, Class objectClass, ResultSet resultSet) {
     this.ormConnection = connection;
     this.objectClass = objectClass;
     this.resultSet = resultSet;
-
   }
 
   @Override
@@ -29,9 +28,7 @@ public boolean hasNext() {
     }
   }
 
-  /**
-   * This iterator is closed if hasNext is false.
-   */
+  /** This iterator is closed if hasNext is false. */
   @Override
   public T next() {
     try {
@@ -45,5 +42,4 @@ public T next() {
   public void remove() {
     throw new UnsupportedOperationException();
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetStreamOrmConnection.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetStreamOrmConnection.java
index 1dc561cd..7f15997a 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetStreamOrmConnection.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetStreamOrmConnection.java
@@ -1,4 +1,3 @@
-
 package org.nkjmlab.sorm4j.internal.result;
 
 import java.util.stream.Stream;
@@ -14,16 +13,14 @@ public final class ResultSetStreamOrmConnection extends AbstractResultSetStre
 
   private final OrmConnectionImpl ormConn;
 
-  public ResultSetStreamOrmConnection(OrmConnectionImpl ormConn, Class objectClass, String sql,
-      Object... parameters) {
+  public ResultSetStreamOrmConnection(
+      OrmConnectionImpl ormConn, Class objectClass, String sql, Object... parameters) {
     super(objectClass, sql, parameters);
     this.ormConn = ormConn;
   }
 
-
   @Override
   public  R apply(FunctionHandler, R> handler) {
     return apply(ormConn, handler);
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetStreamSorm.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetStreamSorm.java
index 801f0bfb..0a59daad 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetStreamSorm.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/result/ResultSetStreamSorm.java
@@ -1,4 +1,3 @@
-
 package org.nkjmlab.sorm4j.internal.result;
 
 import java.util.stream.Stream;
@@ -16,8 +15,8 @@ public final class ResultSetStreamSorm extends AbstractResultSetStream {
 
   private final SormImpl sorm;
 
-  public ResultSetStreamSorm(SormImpl sorm, Class objectClass, String sql,
-      Object... parameters) {
+  public ResultSetStreamSorm(
+      SormImpl sorm, Class objectClass, String sql, Object... parameters) {
     super(objectClass, sql, parameters);
     this.sorm = sorm;
   }
@@ -30,5 +29,4 @@ public  R apply(FunctionHandler, R> handler) {
       throw Try.rethrow(e);
     }
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/NamedParameterSqlParserImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/NamedParameterSqlParserImpl.java
index e1216584..941195f5 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/NamedParameterSqlParserImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/NamedParameterSqlParserImpl.java
@@ -19,7 +19,6 @@
  * class could treat {@link List} parameter.
  *
  * @author nkjm
- *
  */
 public final class NamedParameterSqlParserImpl implements NamedParameterSqlParser {
 
@@ -39,8 +38,8 @@ public final class NamedParameterSqlParserImpl implements NamedParameterSqlParse
   private final Map parameters;
   private Object bean;
 
-  public NamedParameterSqlParserImpl(String sql, char prefix, char suffix,
-      NameToFieldAccessorMapper nameToFieldMapper) {
+  public NamedParameterSqlParserImpl(
+      String sql, char prefix, char suffix, NameToFieldAccessorMapper nameToFieldMapper) {
     this.sql = sql;
     this.prefix = prefix;
     this.suffix = suffix;
@@ -48,7 +47,6 @@ public NamedParameterSqlParserImpl(String sql, char prefix, char suffix,
     this.parameters = new HashMap<>();
   }
 
-
   public NamedParameterSqlParserImpl(String sql) {
     this(sql, DEFAULT_PREFIX, DEFAULT_SUFFIX, DEFAULT_COLUMN_FIELD_MAPPER);
   }
@@ -71,7 +69,6 @@ public NamedParameterSqlParser bindBean(Object bean) {
     return this;
   }
 
-
   @Override
   public ParameterizedSql parse() {
     // Ordered by position in the sentence
@@ -141,5 +138,4 @@ private FieldAccessor getAccessor(String parameterName) {
         .computeIfAbsent(objectClass, k -> nameToFieldMapper.createMapping(objectClass))
         .get(toCanonicalCase(parameterName));
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/OrderedParameterSqlParserImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/OrderedParameterSqlParserImpl.java
index b86c7c46..b3922cc5 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/OrderedParameterSqlParserImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/OrderedParameterSqlParserImpl.java
@@ -10,7 +10,6 @@
  * An implementation of {@link OrderedParameterSqlParser}
  *
  * @author nkjm
- *
  */
 public final class OrderedParameterSqlParserImpl implements OrderedParameterSqlParser {
 
@@ -37,6 +36,4 @@ public OrderedParameterSqlParser addParameter(Object parameter) {
   public ParameterizedSql parse() {
     return ParameterizedSqlImpl.parse(sql, parameters.toArray());
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/ParameterizedSqlImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/ParameterizedSqlImpl.java
index c00c454a..9d27ffd2 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/ParameterizedSqlImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/sql/ParameterizedSqlImpl.java
@@ -14,7 +14,6 @@
  * This class represents a sql statement with ordered parameters.
  *
  * @author nkjm
- *
  */
 public final class ParameterizedSqlImpl implements ParameterizedSql {
 
@@ -28,11 +27,14 @@ private ParameterizedSqlImpl(String sql, Object... parameters) {
     this.parameters = parameters;
   }
 
-
   @Override
   public String toString() {
-    return "sql=[" + sql + "]" + ((parameters == null || parameters.length == 0) ? ""
-        : ", parameters=" + Arrays.toString(parameters) + "");
+    return "sql=["
+        + sql
+        + "]"
+        + ((parameters == null || parameters.length == 0)
+            ? ""
+            : ", parameters=" + Arrays.toString(parameters) + "");
   }
 
   @Override
@@ -58,7 +60,8 @@ public static ParameterizedSql parse(String sql, Object... parameters) {
     }
 
     ParameterizedSql embeddedSql =
-        sql.contains(EMBEDDED_PLACEHOLDER) ? parseEmbeddedPlaceholder(sql, parameters)
+        sql.contains(EMBEDDED_PLACEHOLDER)
+            ? parseEmbeddedPlaceholder(sql, parameters)
             : new ParameterizedSqlImpl(sql, parameters);
 
     return sql.contains(LIST_PLACEHOLDER)
@@ -66,7 +69,6 @@ public static ParameterizedSql parse(String sql, Object... parameters) {
         : embeddedSql;
   }
 
-
   private static ParameterizedSql parseListPlaceholder(String sql, Object[] parameters) {
     final List specialParameterIndexes = createSpecialParameterIndexes(sql, '<', '?', '>');
 
@@ -89,16 +91,18 @@ private static ParameterizedSql parseListPlaceholder(String sql, Object[] parame
         flattenListParams.add(parameters[i]);
       }
     }
-    String _sql = ParameterizedStringFormatter.newString(sql, LIST_PLACEHOLDER,
-        specialParameterIndexes.size(), index -> {
-          int parameterLength = getSize(parameters[specialParameterIndexes.get(index)]);
-          return "?,".repeat(parameterLength).substring(0, 2 * parameterLength - 1);
-        });
+    String _sql =
+        ParameterizedStringFormatter.newString(
+            sql,
+            LIST_PLACEHOLDER,
+            specialParameterIndexes.size(),
+            index -> {
+              int parameterLength = getSize(parameters[specialParameterIndexes.get(index)]);
+              return "?,".repeat(parameterLength).substring(0, 2 * parameterLength - 1);
+            });
     return new ParameterizedSqlImpl(_sql, flattenListParams.toArray());
-
   }
 
-
   private static int getSize(Object object) {
     if (object instanceof Collection) {
       return ((Collection) object).size();
@@ -109,7 +113,6 @@ private static int getSize(Object object) {
     }
   }
 
-
   public static ParameterizedSql parseEmbeddedPlaceholder(String sql, Object... parameters) {
 
     final List specialParameterIndexes = createSpecialParameterIndexes(sql, '{', '?', '}');
@@ -120,17 +123,21 @@ public static ParameterizedSql parseEmbeddedPlaceholder(String sql, Object... pa
         removedEmbeddedParams.add(parameters[i]);
       }
     }
-    String _sql = ParameterizedStringFormatter.newString(sql, EMBEDDED_PLACEHOLDER,
-        specialParameterIndexes.size(),
-        index -> parameters[specialParameterIndexes.get(index)] == null ? "null"
-            : parameters[specialParameterIndexes.get(index)].toString());
+    String _sql =
+        ParameterizedStringFormatter.newString(
+            sql,
+            EMBEDDED_PLACEHOLDER,
+            specialParameterIndexes.size(),
+            index ->
+                parameters[specialParameterIndexes.get(index)] == null
+                    ? "null"
+                    : parameters[specialParameterIndexes.get(index)].toString());
 
     return new ParameterizedSqlImpl(_sql, removedEmbeddedParams.toArray());
   }
 
-
-  private static List createSpecialParameterIndexes(String str, char prefix,
-      char normalPlaceholder, char suffix) {
+  private static List createSpecialParameterIndexes(
+      String str, char prefix, char normalPlaceholder, char suffix) {
     final char[] arry = str.toCharArray();
 
     final List ret = new ArrayList<>();
@@ -138,7 +145,10 @@ private static List createSpecialParameterIndexes(String str, char pref
 
     for (int i = 0; i < arry.length; i++) {
       char c = arry[i];
-      if (c == normalPlaceholder && i - 1 >= 0 && arry[i - 1] == prefix && i + 1 < arry.length
+      if (c == normalPlaceholder
+          && i - 1 >= 0
+          && arry[i - 1] == prefix
+          && i + 1 < arry.length
           && arry[i + 1] == suffix) {
         ret.add(parameterIndex);
         parameterIndex++;
@@ -149,7 +159,6 @@ private static List createSpecialParameterIndexes(String str, char pref
     return ret;
   }
 
-
   @Override
   public String getBindedSql() {
     String sql = this.sql;
@@ -158,5 +167,4 @@ public String getBindedSql() {
     }
     return sql;
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ArrayUtils.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ArrayUtils.java
index 535f95fc..6d2c4445 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ArrayUtils.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ArrayUtils.java
@@ -144,9 +144,7 @@ public static Short[] toObjectArray(short[] array) {
     return result;
   }
 
-
   /**
-   *
    * @param 
    * @param toComponentType
    * @param srcArray
@@ -184,9 +182,12 @@ public static Object convertSqlArrayToArray(Class toComponentType, Object src
 
   public static  T[] convertToObjectArray(Class componentType, Object srcArray) {
     final int length = Array.getLength(srcArray);
-    Object destArray = Array.newInstance(
-        componentType.isPrimitive() ? ClassUtils.primitiveToWrapper(componentType) : componentType,
-        length);
+    Object destArray =
+        Array.newInstance(
+            componentType.isPrimitive()
+                ? ClassUtils.primitiveToWrapper(componentType)
+                : componentType,
+            length);
     for (int i = 0; i < length; i++) {
       Object v = Array.get(srcArray, i);
       Array.set(destArray, i, v);
@@ -222,9 +223,10 @@ public static Object[] convertToObjectArray(Object srcArray) {
     }
     Object o = Array.get(srcArray, 0);
     final int length = Array.getLength(srcArray);
-    Object destArray = Array.newInstance(
-        Array.newInstance(convertToObjectArray(o).getClass().getComponentType(), 0).getClass(),
-        length);
+    Object destArray =
+        Array.newInstance(
+            Array.newInstance(convertToObjectArray(o).getClass().getComponentType(), 0).getClass(),
+            length);
     for (int i = 0; i < length; i++) {
       Object v = Array.get(srcArray, i);
       Array.set(destArray, i, convertToObjectArray(v));
@@ -239,6 +241,4 @@ public static Class getInternalComponentType(Class compType) {
     }
     return ret;
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ClassUtils.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ClassUtils.java
index 3b58a8f2..1db45679 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ClassUtils.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ClassUtils.java
@@ -8,13 +8,19 @@ public final class ClassUtils {
   private ClassUtils() {}
 
   private static final Map, Class> primitiveToWrapperMap =
-      Map.ofEntries(entry(Boolean.TYPE, Boolean.class), entry(Byte.TYPE, Byte.class),
-          entry(Character.TYPE, Character.class), entry(Short.TYPE, Short.class),
-          entry(Integer.TYPE, Integer.class), entry(Long.TYPE, Long.class),
-          entry(Double.TYPE, Double.class), entry(Float.TYPE, Float.class));
+      Map.ofEntries(
+          entry(Boolean.TYPE, Boolean.class),
+          entry(Byte.TYPE, Byte.class),
+          entry(Character.TYPE, Character.class),
+          entry(Short.TYPE, Short.class),
+          entry(Integer.TYPE, Integer.class),
+          entry(Long.TYPE, Long.class),
+          entry(Double.TYPE, Double.class),
+          entry(Float.TYPE, Float.class));
 
-  private static final Map, Class> wrapperToPrimitiveMap = primitiveToWrapperMap
-      .entrySet().stream().collect(Collectors.toMap(en -> en.getValue(), en -> en.getKey()));
+  private static final Map, Class> wrapperToPrimitiveMap =
+      primitiveToWrapperMap.entrySet().stream()
+          .collect(Collectors.toMap(en -> en.getValue(), en -> en.getKey()));
 
   public static Class primitiveToWrapper(Class clazz) {
     return primitiveToWrapperMap.get(clazz);
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ConcurrentCache.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ConcurrentCache.java
index 053da737..74ce505c 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ConcurrentCache.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ConcurrentCache.java
@@ -4,12 +4,10 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
-
 /**
  * Concurrent cache. This class simply focus to limit number of entries.
  *
  * @author yuu_nkjm
- *
  * @param 
  * @param 
  */
@@ -22,7 +20,6 @@ public ConcurrentCache(int maxSize) {
     this.maxSize = maxSize;
   }
 
-
   @Override
   public V put(K key, V value) {
     if (size() >= maxSize) {
@@ -31,15 +28,14 @@ public V put(K key, V value) {
     return super.put(key, value);
   }
 
-
   @Override
   public void putAll(Map m) {
     if (size() >= maxSize || m.size() + size() > maxSize) {
       clear();
     }
-    super.putAll(m.entrySet().stream().limit(maxSize - size())
-        .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())));
-
+    super.putAll(
+        m.entrySet().stream()
+            .limit(maxSize - size())
+            .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())));
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/JdbcTypeUtils.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/JdbcTypeUtils.java
index 1ca9db77..56b69240 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/JdbcTypeUtils.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/JdbcTypeUtils.java
@@ -15,5 +15,4 @@ public static List convert(int... sqlTypes) {
   public static JDBCType convert(int sqlTypes) {
     return JDBCType.valueOf(sqlTypes);
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/MethodInvokerInfoUtils.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/MethodInvokerInfoUtils.java
index c983ff7c..93c64f26 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/MethodInvokerInfoUtils.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/MethodInvokerInfoUtils.java
@@ -6,16 +6,18 @@
 
 public final class MethodInvokerInfoUtils {
 
-
   public static String getInvokerInfo(int depth, StackTraceElement[] stackTraceElements) {
     StackTraceElement e = getStackTraceElement(depth, stackTraceElements);
-    return e.getClassName() + " ("
-        + (e.getFileName() != null ? new File(e.getFileName()).getName() : "") + ":"
-        + e.getLineNumber() + ") ";
+    return e.getClassName()
+        + " ("
+        + (e.getFileName() != null ? new File(e.getFileName()).getName() : "")
+        + ":"
+        + e.getLineNumber()
+        + ") ";
   }
 
-  private static StackTraceElement getStackTraceElement(int index,
-      StackTraceElement[] stackTraceElements) {
+  private static StackTraceElement getStackTraceElement(
+      int index, StackTraceElement[] stackTraceElements) {
     if (index < 0) {
       return stackTraceElements[0];
     } else if (index >= stackTraceElements.length) {
@@ -29,10 +31,14 @@ public static String getOutsideInvoker(String libPrefix) {
     StackTraceElement[] stackTrace = new Throwable().getStackTrace();
 
     {
-      Optional c = Arrays.stream(stackTrace)
-          .filter(s -> !s.getClassName().startsWith(libPrefix)
-              && !s.getClassName().startsWith("java.") && !s.getClassName().startsWith("jdk."))
-          .findFirst();
+      Optional c =
+          Arrays.stream(stackTrace)
+              .filter(
+                  s ->
+                      !s.getClassName().startsWith(libPrefix)
+                          && !s.getClassName().startsWith("java.")
+                          && !s.getClassName().startsWith("jdk."))
+              .findFirst();
 
       if (c.isPresent()) {
         return c.map(se -> getInvoker(se)).get();
@@ -40,8 +46,10 @@ public static String getOutsideInvoker(String libPrefix) {
     }
 
     {
-      Optional c = Arrays.stream(stackTrace)
-          .filter(s -> !s.getClassName().startsWith(libPrefix)).findFirst();
+      Optional c =
+          Arrays.stream(stackTrace)
+              .filter(s -> !s.getClassName().startsWith(libPrefix))
+              .findFirst();
 
       if (c.isPresent()) {
         return c.map(se -> getInvoker(se)).get();
@@ -51,7 +59,13 @@ public static String getOutsideInvoker(String libPrefix) {
   }
 
   public static String getInvoker(StackTraceElement se) {
-    return se.getClassName() + "." + se.getMethodName() + "(" + se.getFileName() + ":"
-        + se.getLineNumber() + ")";
+    return se.getClassName()
+        + "."
+        + se.getMethodName()
+        + "("
+        + se.getFileName()
+        + ":"
+        + se.getLineNumber()
+        + ")";
   }
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ParameterizedStringFormatter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ParameterizedStringFormatter.java
index 368410db..22a555fc 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ParameterizedStringFormatter.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/ParameterizedStringFormatter.java
@@ -29,7 +29,6 @@ public final class ParameterizedStringFormatter {
   private final String placeholder;
   private final int maxLength;
 
-
   private ParameterizedStringFormatter(int maxLength) {
     this(DEFAULT_PLACEHOLDER, maxLength);
   }
@@ -69,16 +68,14 @@ public String format(String msg, Object... params) {
     return newStringWithPlaceHolder(msg, placeholder, maxLength, params);
   }
 
-  private static String newStringWithPlaceHolder(String msg, String placeholder, int maxLength,
-      Object... params) {
+  private static String newStringWithPlaceHolder(
+      String msg, String placeholder, int maxLength, Object... params) {
     if (params == null || params.length == 0) {
       return msg;
     }
     return newString(msg, placeholder, params.length, index -> toString(maxLength, params[index]));
   }
 
-
-
   private static String trim(String string, int maxLength) {
     if (string.length() <= maxLength) {
       return string;
@@ -86,7 +83,10 @@ private static String trim(String string, int maxLength) {
     return string.substring(0, maxLength) + "...";
   }
 
-  public static String newString(String msg, String placeholder, int numOfParameter,
+  public static String newString(
+      String msg,
+      String placeholder,
+      int numOfParameter,
       Function parameterReplacer) {
     final StringBuilder sbuf = new StringBuilder(msg.length() + 50);
     int i = 0;
@@ -115,6 +115,4 @@ private static String toString(int maxLength, Object param) {
       return trim(param.toString(), maxLength);
     }
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/StringCache.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/StringCache.java
index d75e94d7..09b8f2a5 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/StringCache.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/StringCache.java
@@ -29,11 +29,10 @@ public static String toUpperSnakeCase(final String compoundName) {
     return StringCache.toUpperCase(camelCase.replaceAll("([A-Z])", "_$1").replace("__", "_"));
   }
 
-
   /**
    * Converts the given string to string in canonical case.
    *
-   * Example
+   * 

Example * *

    * STUDENT_ID = > STUDENTID
@@ -44,8 +43,8 @@ public static String toUpperSnakeCase(final String compoundName) {
    * @return
    */
   public static String toCanonicalCase(String str) {
-    return canonicalCaseCaches.computeIfAbsent(str,
-        key -> str.replaceAll("[_/\\s]", "").toUpperCase(Locale.ENGLISH));
+    return canonicalCaseCaches.computeIfAbsent(
+        str, key -> str.replaceAll("[_/\\s]", "").toUpperCase(Locale.ENGLISH));
   }
 
   /**
@@ -69,5 +68,4 @@ public static boolean containsAsCanonical(Collection collection, String
   }
 
   private StringCache() {}
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/SystemPropertyUtils.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/SystemPropertyUtils.java
index 100377f1..339979c5 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/SystemPropertyUtils.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/SystemPropertyUtils.java
@@ -8,7 +8,8 @@
 import java.util.stream.Stream;
 
 public class SystemPropertyUtils {
-  private SystemPropertyUtils() {};
+  private SystemPropertyUtils() {}
+  ;
 
   public static String[] getClassPathElements() {
     return System.getProperty("java.class.path").split(File.pathSeparator);
@@ -20,15 +21,18 @@ public static String findClassPathElement(String regex) {
       return elements.get(0);
     } else {
       Object[] params = {regex, elements, getClassPathElements()};
-      throw new IllegalArgumentException(ParameterizedStringFormatter.LENGTH_256
-          .format("{} should be one in classpath. found {}, in {}", params));
+      throw new IllegalArgumentException(
+          ParameterizedStringFormatter.LENGTH_256.format(
+              "{} should be one in classpath. found {}, in {}", params));
     }
   }
 
   public static List findClassPathElements(String regex) {
     String[] classPathElements = getClassPathElements();
-    List elements = Arrays.stream(classPathElements)
-        .filter(elem -> new File(elem).getName().matches(regex)).collect(Collectors.toList());
+    List elements =
+        Arrays.stream(classPathElements)
+            .filter(elem -> new File(elem).getName().matches(regex))
+            .collect(Collectors.toList());
     return elements;
   }
 
@@ -38,31 +42,42 @@ public static String findJavaCommand() {
   }
 
   public static Map getJavaProperties() {
-    return Stream
-        .of("os.name", "os.version", "java.class.version", "java.specification.version",
-            "java.vm.name", "java.vm.version", "java.vm.vendor", "java.home", "java.class.path",
-            "user.name", "user.home", "user.dir")
-        .collect(Collectors.toMap(p -> p,
-            p -> ParameterizedStringFormatter.LENGTH_256.format("{}={}", p, System.getProperty(p))));
+    return Stream.of(
+            "os.name",
+            "os.version",
+            "java.class.version",
+            "java.specification.version",
+            "java.vm.name",
+            "java.vm.version",
+            "java.vm.vendor",
+            "java.home",
+            "java.class.path",
+            "user.name",
+            "user.home",
+            "user.dir")
+        .collect(
+            Collectors.toMap(
+                p -> p,
+                p ->
+                    ParameterizedStringFormatter.LENGTH_256.format(
+                        "{}={}", p, System.getProperty(p))));
   }
 
   /**
-   * Getting the user's home directory which is referenced by
-   * {@code System.getProperty("user.home")}.
+   * Getting the user's home directory which is referenced by {@code
+   * System.getProperty("user.home")}.
    *
    * @return
    */
   public static File getUserHomeDirectory() {
     return new File(System.getProperty("user.home"));
-
   }
 
   public static String getTildeExpandAbsolutePath(File path) {
-    return (path.getName().equals("~") || path.getPath().startsWith("~/")
-        || path.getPath().startsWith("~\\"))
-            ? path.getPath().replace("~", getUserHomeDirectory().getAbsolutePath())
-            : path.getAbsolutePath();
+    return (path.getName().equals("~")
+            || path.getPath().startsWith("~/")
+            || path.getPath().startsWith("~\\"))
+        ? path.getPath().replace("~", getUserHomeDirectory().getAbsolutePath())
+        : path.getAbsolutePath();
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/Try.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/Try.java
index 9512afb5..379ca8d8 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/Try.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/Try.java
@@ -32,17 +32,15 @@ public static interface ThrowableSupplier {
     T get() throws Exception;
   }
 
-
   /**
-   *
    * @param 
    * @param 
    * @param onTry
    * @param exceptionConsumer
    * @return
    */
-  public static  BiConsumer createBiConsumer(ThrowableBiConsumer onTry,
-      Consumer exceptionConsumer) {
+  public static  BiConsumer createBiConsumer(
+      ThrowableBiConsumer onTry, Consumer exceptionConsumer) {
     return (t, s) -> {
       try {
         onTry.accept(t, s);
@@ -53,7 +51,6 @@ public static  BiConsumer createBiConsumer(ThrowableBiConsumer
   }
 
   /**
-   *
    * @param 
    * @param 
    * @param 
@@ -64,22 +61,22 @@ public static  BiConsumer createBiConsumer(ThrowableBiConsumer
    */
   public static  BiConsumer createBiConsumerWithThrow(
       ThrowableBiConsumer onTry, Function exeptionThrower) throws X {
-    return createBiConsumer(onTry, e -> {
-      throw exeptionThrower.apply(e);
-    });
+    return createBiConsumer(
+        onTry,
+        e -> {
+          throw exeptionThrower.apply(e);
+        });
   }
 
-
   /**
-   *
    * @param 
    * @param 
    * @param onTry
    * @param exceptionConsumer
    * @return
    */
-  public static  Consumer createConsumer(ThrowableConsumer onTry,
-      Consumer exceptionConsumer) {
+  public static  Consumer createConsumer(
+      ThrowableConsumer onTry, Consumer exceptionConsumer) {
     return x -> {
       try {
         onTry.accept(x);
@@ -89,9 +86,7 @@ public static  Consumer createConsumer(ThrowableConsumer onTry,
     };
   }
 
-
   /**
-   *
    * @param 
    * @param 
    * @param onTry
@@ -101,21 +96,22 @@ public static  Consumer createConsumer(ThrowableConsumer onTry,
    */
   public static  Consumer createConsumerWithThrow(
       ThrowableConsumer onTry, Function exeptionThrower) throws X {
-    return createConsumer(onTry, e -> {
-      throw exeptionThrower.apply(e);
-    });
+    return createConsumer(
+        onTry,
+        e -> {
+          throw exeptionThrower.apply(e);
+        });
   }
 
   /**
-   *
    * @param 
    * @param 
    * @param onTry
    * @param exceptionHandler
    * @return
    */
-  public static  Function createFunction(ThrowableFunction onTry,
-      Function exceptionHandler) {
+  public static  Function createFunction(
+      ThrowableFunction onTry, Function exceptionHandler) {
     return x -> {
       try {
         return onTry.apply(x);
@@ -125,10 +121,7 @@ public static  Function createFunction(ThrowableFunction onTry
     };
   }
 
-
-
   /**
-   *
    * @param 
    * @param 
    * @param 
@@ -139,20 +132,20 @@ public static  Function createFunction(ThrowableFunction onTry
    */
   public static  Function createFunctionWithThrow(
       ThrowableFunction onTry, Function exceptionThrower) throws X {
-    return createFunction(onTry, e -> {
-      throw exceptionThrower.apply(e);
-    });
+    return createFunction(
+        onTry,
+        e -> {
+          throw exceptionThrower.apply(e);
+        });
   }
 
-
   /**
-   *
    * @param onTry
    * @param exceptionConsumer
    * @return
    */
-  public static Runnable createRunnable(ThrowableRunnable onTry,
-      Consumer exceptionConsumer) {
+  public static Runnable createRunnable(
+      ThrowableRunnable onTry, Consumer exceptionConsumer) {
     return () -> {
       try {
         onTry.run();
@@ -163,7 +156,6 @@ public static Runnable createRunnable(ThrowableRunnable onTry,
   }
 
   /**
-   *
    * @param 
    * @param onTry
    * @param exceptionThrower
@@ -172,20 +164,21 @@ public static Runnable createRunnable(ThrowableRunnable onTry,
    */
   public static  Runnable createRunnableWithThrow(
       ThrowableRunnable onTry, Function exceptionThrower) throws X {
-    return createRunnable(onTry, e -> {
-      throw exceptionThrower.apply(e);
-    });
+    return createRunnable(
+        onTry,
+        e -> {
+          throw exceptionThrower.apply(e);
+        });
   }
 
   /**
-   *
    * @param 
    * @param onTry
    * @param exceptionHandler
    * @return
    */
-  public static  Supplier createSupplier(ThrowableSupplier onTry,
-      Function exceptionHandler) {
+  public static  Supplier createSupplier(
+      ThrowableSupplier onTry, Function exceptionHandler) {
     return () -> {
       try {
         return onTry.get();
@@ -196,7 +189,6 @@ public static  Supplier createSupplier(ThrowableSupplier onTry,
   }
 
   /**
-   *
    * @param 
    * @param 
    * @param onTry
@@ -206,9 +198,11 @@ public static  Supplier createSupplier(ThrowableSupplier onTry,
    */
   public static  Supplier createSupplierWithThrow(
       ThrowableSupplier onTry, Function exceptionThrower) throws X {
-    return createSupplier(onTry, e -> {
-      throw exceptionThrower.apply(e);
-    });
+    return createSupplier(
+        onTry,
+        e -> {
+          throw exceptionThrower.apply(e);
+        });
   }
 
   /**
@@ -220,9 +214,12 @@ public static  Supplier createSupplierWithThro
    * @return
    */
   public static  T getOrElse(ThrowableSupplier onTry, T other) {
-    return createSupplier(onTry, e -> {
-      return other;
-    }).get();
+    return createSupplier(
+            onTry,
+            e -> {
+              return other;
+            })
+        .get();
   }
 
   /**
@@ -234,12 +231,11 @@ public static  T getOrElse(ThrowableSupplier onTry, T other) {
    * @param ohterSupplier
    * @return
    */
-  public static  T getOrElseGet(ThrowableSupplier onTry,
-      Function ohterSupplier) {
+  public static  T getOrElseGet(
+      ThrowableSupplier onTry, Function ohterSupplier) {
     return createSupplier(onTry, e -> ohterSupplier.apply(e)).get();
   }
 
-
   /**
    * Tries to get a value or throws an exception if an exception occurs.
    *
@@ -250,11 +246,14 @@ public static  T getOrElseGet(ThrowableSupplier T getOrElseThrow(ThrowableSupplier onTry,
-      Function exceptionSupplier) throws X {
-    return createSupplier(onTry, e -> {
-      throw exceptionSupplier.apply(e);
-    }).get();
+  public static  T getOrElseThrow(
+      ThrowableSupplier onTry, Function exceptionSupplier) throws X {
+    return createSupplier(
+            onTry,
+            e -> {
+              throw exceptionSupplier.apply(e);
+            })
+        .get();
   }
 
   /**
@@ -265,9 +264,12 @@ public static  T getOrElseThrow(ThrowableSupplier
    * @return
    */
   public static  T getOrElseNull(ThrowableSupplier onTry) {
-    return createSupplier(onTry, e -> {
-      return null;
-    }).get();
+    return createSupplier(
+            onTry,
+            e -> {
+              return null;
+            })
+        .get();
   }
 
   /**
@@ -302,20 +304,20 @@ public static void runOrElseDo(ThrowableRunnable onTry, Consumer exce
    * @param exceptionThrower
    * @throws X
    */
-  public static  void runOrElseThrow(ThrowableRunnable onTry,
-      Function exceptionThrower) throws X {
-    createRunnable(onTry, e -> {
-      throw exceptionThrower.apply(e);
-    }).run();
+  public static  void runOrElseThrow(
+      ThrowableRunnable onTry, Function exceptionThrower) throws X {
+    createRunnable(
+            onTry,
+            e -> {
+              throw exceptionThrower.apply(e);
+            })
+        .run();
   }
 
-
   public static  void runOrElseRethrow(ThrowableRunnable onTry)
       throws X {
     runOrElseThrow(onTry, e -> Try.rethrow(e));
   }
 
   private Try() {}
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/AbstractCommand.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/AbstractCommand.java
index 15d36e18..c2c5786d 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/AbstractCommand.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/AbstractCommand.java
@@ -55,9 +55,8 @@ public  List> readTupleList(Class t1, Class t2) {
   }
 
   @Override
-  public  List> readTupleList(Class t1, Class t2,
-      Class t3) {
+  public  List> readTupleList(
+      Class t1, Class t2, Class t3) {
     return conn.readTupleList(t1, t2, t3, parse());
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/BasicCommandImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/BasicCommandImpl.java
index 08e2b285..0d5f9dd6 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/BasicCommandImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/BasicCommandImpl.java
@@ -45,6 +45,4 @@ public NamedParameterCommand bindBean(Object bean) {
   protected ParameterizedSql parse() {
     return ParameterizedSql.of(sql);
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/NamedParameterCommandImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/NamedParameterCommandImpl.java
index f07d6bbf..e5b66bbd 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/NamedParameterCommandImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/NamedParameterCommandImpl.java
@@ -6,7 +6,8 @@
 import org.nkjmlab.sorm4j.sql.ParameterizedSql;
 import org.nkjmlab.sorm4j.util.command.NamedParameterCommand;
 
-public final class NamedParameterCommandImpl extends AbstractCommand implements NamedParameterCommand {
+public final class NamedParameterCommandImpl extends AbstractCommand
+    implements NamedParameterCommand {
 
   private final NamedParameterSqlParser sql;
 
@@ -37,5 +38,4 @@ public NamedParameterCommand bindBean(Object bean) {
     sql.bindBean(bean);
     return this;
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/OrderedParameterCommandImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/OrderedParameterCommandImpl.java
index 87db4e32..b9e5910b 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/OrderedParameterCommandImpl.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/command/OrderedParameterCommandImpl.java
@@ -31,5 +31,4 @@ public OrderedParameterCommand addParameter(Object... parameters) {
     sql.addParameter(parameters);
     return this;
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/AbstractSormLogger.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/AbstractSormLogger.java
index 24588ae2..b87f2f01 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/AbstractSormLogger.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/AbstractSormLogger.java
@@ -19,22 +19,32 @@ public void logBeforeSql(String tag, Connection connection, String sql, Object..
 
   @Override
   public void logBeforeSql(String tag, Connection connection, ParameterizedSql psql) {
-    Object[] params = {tag, getOutsideInvokerOfLibrary(), psql.getBindedSql(), getDbUrl(connection)};
-    debug(ParameterizedStringFormatter.LENGTH_256.format("[{}] At {}, Execute SQL [{}] to [{}]", params));
+    Object[] params = {
+      tag, getOutsideInvokerOfLibrary(), psql.getBindedSql(), getDbUrl(connection)
+    };
+    debug(
+        ParameterizedStringFormatter.LENGTH_256.format(
+            "[{}] At {}, Execute SQL [{}] to [{}]", params));
   }
 
-
   @Override
-  public void logBeforeMultiRow(String tag, Connection connection, Class clazz, int length,
-      String tableName) {
-    Object[] params = {tag, getOutsideInvokerOfLibrary(), length, clazz, tableName, getDbUrl(connection)};
-    debug(ParameterizedStringFormatter.LENGTH_256.format("[{}] At {}, Execute multirow insert with [{}] objects of [{}] into [{}] on [{}]", params));
+  public void logBeforeMultiRow(
+      String tag, Connection connection, Class clazz, int length, String tableName) {
+    Object[] params = {
+      tag, getOutsideInvokerOfLibrary(), length, clazz, tableName, getDbUrl(connection)
+    };
+    debug(
+        ParameterizedStringFormatter.LENGTH_256.format(
+            "[{}] At {}, Execute multirow insert with [{}] objects of [{}] into [{}] on [{}]",
+            params));
   }
 
-
   @Override
   public void logAfterQuery(String tag, long elapsedTime, Object ret) {
-    Object[] params = {getTagAndElapsedTime(tag, elapsedTime), ret instanceof Collection ? ((Collection) ret).size() : 1};
+    Object[] params = {
+      getTagAndElapsedTime(tag, elapsedTime),
+      ret instanceof Collection ? ((Collection) ret).size() : 1
+    };
     debug(ParameterizedStringFormatter.LENGTH_256.format("{} Read [{}] objects", params));
   }
 
@@ -44,7 +54,6 @@ public void logAfterUpdate(String tag, long elapsedTime, int ret) {
     debug(ParameterizedStringFormatter.LENGTH_256.format("{} Affect [{}] rows", params));
   }
 
-
   @Override
   public void logAfterMultiRow(String tag, long elapsedTime, int[] result) {
     Object[] params = {getTagAndElapsedTime(tag, elapsedTime), IntStream.of(result).sum()};
@@ -57,7 +66,11 @@ public void logMapping(String tag, String mappingInfo) {
   }
 
   private String getTagAndElapsedTime(String tag, long elapsedTime) {
-    return "[" + tag + "]" + " [" + String.format("%.3f", (double) elapsedTime / 1000 / 1000)
+    return "["
+        + tag
+        + "]"
+        + " ["
+        + String.format("%.3f", (double) elapsedTime / 1000 / 1000)
         + " msec] :";
   }
 
@@ -65,10 +78,7 @@ private String getDbUrl(Connection connection) {
     return Try.getOrElse(() -> connection.getMetaData().getURL(), "");
   }
 
-
   private static String getOutsideInvokerOfLibrary() {
     return MethodInvokerInfoUtils.getOutsideInvoker("org.nkjmlab.sorm4j");
-
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/JulSormLogger.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/JulSormLogger.java
index 16b71189..48a6b3e1 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/JulSormLogger.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/JulSormLogger.java
@@ -33,7 +33,6 @@ public void trace(String format, Object... params) {
     this.logger.finer(ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
-
   @Override
   public void debug(String format, Object... params) {
     this.logger.fine(ParameterizedStringFormatter.LENGTH_256.format(format, params));
@@ -78,6 +77,4 @@ public void warn(int depth, String format, Object... params) {
   public void error(int depth, String format, Object... params) {
     error(format, params);
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/Log4jSormLogger.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/Log4jSormLogger.java
index 5fbe47fd..2d0853e2 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/Log4jSormLogger.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/Log4jSormLogger.java
@@ -11,18 +11,21 @@ public final class Log4jSormLogger extends AbstractSormLogger implements SormLog
   public static final boolean enableLogger = isEnable();
 
   private static boolean isEnable() {
-    return Try.getOrElse(() -> {
-      Class.forName("org.apache.logging.log4j.Logger");
-      return true;
-    }, false);
+    return Try.getOrElse(
+        () -> {
+          Class.forName("org.apache.logging.log4j.Logger");
+          return true;
+        },
+        false);
   }
 
   private final org.apache.logging.log4j.Logger logger;
 
   public static SormLogger getLogger() {
     if (!enableLogger) {
-      System.err.println("sorm4j: [org.apache.logging.log4j.Logger] is not found at the classpath."
-          + "If you want to use Log4j2, you should add Log4j2 logger at the classpath.");
+      System.err.println(
+          "sorm4j: [org.apache.logging.log4j.Logger] is not found at the classpath."
+              + "If you want to use Log4j2, you should add Log4j2 logger at the classpath.");
     }
     return new Log4jSormLogger(org.apache.logging.log4j.LogManager.getLogger());
   }
@@ -31,21 +34,21 @@ public static SormLogger getLogger() {
     this.logger = logger;
   }
 
-
   @Override
   public void trace(String format, Object... params) {
     printf(2, Level.TRACE, format, params);
   }
 
-
   @Override
   public void debug(String format, Object... params) {
     printf(2, Level.DEBUG, format, params);
   }
 
   private void printf(int depth, Level level, String format, Object... params) {
-    this.logger.printf(level,
-        "%n  " + MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
+    this.logger.printf(
+        level,
+        "%n  "
+            + MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
             + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
@@ -88,7 +91,4 @@ public void warn(int depth, String format, Object... params) {
   public void error(int depth, String format, Object... params) {
     printf(depth, Level.ERROR, format, params);
   }
-
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/Slf4jSormLogger.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/Slf4jSormLogger.java
index aa7b0ed3..88cb2935 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/Slf4jSormLogger.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/util/logger/Slf4jSormLogger.java
@@ -10,10 +10,12 @@ public final class Slf4jSormLogger extends AbstractSormLogger implements SormLog
   public static final boolean enableLogger = isEnable();
 
   private static boolean isEnable() {
-    return Try.getOrElse(() -> {
-      Class.forName("org.slf4j.Logger");
-      return true;
-    }, false);
+    return Try.getOrElse(
+        () -> {
+          Class.forName("org.slf4j.Logger");
+          return true;
+        },
+        false);
   }
 
   private final org.slf4j.Logger logger;
@@ -24,72 +26,80 @@ private static boolean isEnable() {
 
   public static SormLogger getLogger() {
     if (!enableLogger) {
-      System.err.println("sorm4j: [org.slf4j.Logger] is not found at the classpath. "
-          + "If you want to use SLF4J, you should add SLF4J logger at the classpath.");
+      System.err.println(
+          "sorm4j: [org.slf4j.Logger] is not found at the classpath. "
+              + "If you want to use SLF4J, you should add SLF4J logger at the classpath.");
     }
     return new Slf4jSormLogger(org.slf4j.LoggerFactory.getLogger(Slf4jSormLogger.class));
   }
 
   @Override
   public void trace(String format, Object... params) {
-    logger.trace(MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.trace(
+        MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
-
   @Override
   public void debug(String format, Object... params) {
-    logger.debug(MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.debug(
+        MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
   @Override
   public void info(String format, Object... params) {
-    logger.info(MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.info(
+        MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
   @Override
   public void warn(String format, Object... params) {
-    logger.warn(MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.warn(
+        MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
   @Override
   public void error(String format, Object... params) {
-    logger.error(MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.error(
+        MethodInvokerInfoUtils.getInvokerInfo(1, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
   @Override
   public void trace(int depth, String format, Object... params) {
-    logger.trace(MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.trace(
+        MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
-
   @Override
   public void debug(int depth, String format, Object... params) {
-    logger.debug(MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.debug(
+        MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
   @Override
   public void info(int depth, String format, Object... params) {
-    logger.info(MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.info(
+        MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
   @Override
   public void warn(int depth, String format, Object... params) {
-    logger.warn(MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.warn(
+        MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
 
   @Override
   public void error(int depth, String format, Object... params) {
-    logger.error(MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
-        + ParameterizedStringFormatter.LENGTH_256.format(format, params));
+    logger.error(
+        MethodInvokerInfoUtils.getInvokerInfo(depth, new Throwable().getStackTrace())
+            + ParameterizedStringFormatter.LENGTH_256.format(format, params));
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/mapping/ResultSetTraverser.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/mapping/ResultSetTraverser.java
index 7ec99f7f..ba2e3bad 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/mapping/ResultSetTraverser.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/mapping/ResultSetTraverser.java
@@ -9,7 +9,6 @@
  * Traverses {@link ResultSet} and maps to T.
  *
  * @author nkjm
- *
  * @param 
  */
 @FunctionalInterface
@@ -42,5 +41,4 @@ static  ResultSetTraverser> of(RowMapper rowMapper) {
       return ret;
     };
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/mapping/RowMapper.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/mapping/RowMapper.java
index 962cafb7..9e7a8798 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/mapping/RowMapper.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/mapping/RowMapper.java
@@ -4,11 +4,9 @@
 import java.sql.SQLException;
 
 /**
- *
  * Maps a row in a {@link ResultSet} to a object.
  *
  * @author nkjm
- *
  * @param 
  * @see {@link ResultSetTraverser}
  */
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/BasicRowMap.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/BasicRowMap.java
index 93a59a63..60b8ae20 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/BasicRowMap.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/BasicRowMap.java
@@ -27,8 +27,12 @@ public BasicRowMap(int initialCapacity, float loadFactor) {
   }
 
   public BasicRowMap(Map map) {
-    this.map = List.copyOf(map.entrySet()).stream().collect(LinkedHashMap::new,
-        (m, v) -> m.put(toKey(v.getKey()), v.getValue()), LinkedHashMap::putAll);
+    this.map =
+        List.copyOf(map.entrySet()).stream()
+            .collect(
+                LinkedHashMap::new,
+                (m, v) -> m.put(toKey(v.getKey()), v.getValue()),
+                LinkedHashMap::putAll);
   }
 
   private static String toKey(String key) {
@@ -102,10 +106,8 @@ public int hashCode() {
 
   @Override
   public boolean equals(Object obj) {
-    if (this == obj)
-      return true;
-    if (!(obj instanceof Map))
-      return false;
+    if (this == obj) return true;
+    if (!(obj instanceof Map)) return false;
     Map other = (Map) obj;
     return Objects.equals(map, other);
   }
@@ -115,7 +117,6 @@ public String toString() {
     return map.toString();
   }
 
-
   @Override
   public String getString(String key) {
     Object val = get(key);
@@ -130,34 +131,50 @@ public String getString(String key) {
 
   @Override
   public Integer getInteger(String key) {
-    return getNumberHelper(key, Integer.class,
-        (clazz, val) -> Number.class.isAssignableFrom(clazz) ? ((Number) val).intValue()
-            : Integer.valueOf(val.toString()));
+    return getNumberHelper(
+        key,
+        Integer.class,
+        (clazz, val) ->
+            Number.class.isAssignableFrom(clazz)
+                ? ((Number) val).intValue()
+                : Integer.valueOf(val.toString()));
   }
 
   @Override
   public Long getLong(String key) {
-    return getNumberHelper(key, Long.class,
-        (clazz, val) -> Number.class.isAssignableFrom(clazz) ? ((Number) val).longValue()
-            : Long.valueOf(val.toString()));
+    return getNumberHelper(
+        key,
+        Long.class,
+        (clazz, val) ->
+            Number.class.isAssignableFrom(clazz)
+                ? ((Number) val).longValue()
+                : Long.valueOf(val.toString()));
   }
 
   @Override
   public Float getFloat(String key) {
-    return getNumberHelper(key, Float.class,
-        (clazz, val) -> Number.class.isAssignableFrom(clazz) ? ((Number) val).floatValue()
-            : Float.valueOf(val.toString()));
+    return getNumberHelper(
+        key,
+        Float.class,
+        (clazz, val) ->
+            Number.class.isAssignableFrom(clazz)
+                ? ((Number) val).floatValue()
+                : Float.valueOf(val.toString()));
   }
 
   @Override
   public Double getDouble(String key) {
-    return getNumberHelper(key, Double.class,
-        (clazz, val) -> Number.class.isAssignableFrom(clazz) ? ((Number) val).doubleValue()
-            : Double.valueOf(val.toString()));
+    return getNumberHelper(
+        key,
+        Double.class,
+        (clazz, val) ->
+            Number.class.isAssignableFrom(clazz)
+                ? ((Number) val).doubleValue()
+                : Double.valueOf(val.toString()));
   }
 
-  private  T getNumberHelper(String key, Class toType,
-      BiFunction, Object, T> function) {
+  private  T getNumberHelper(
+      String key, Class toType, BiFunction, Object, T> function) {
     Object val = get(key);
     if (val == null) {
       return null;
@@ -178,7 +195,6 @@ public LocalDate getLocalDate(String key) {
     return LocalDate.parse(val.toString());
   }
 
-
   @Override
   public LocalTime getLocalTime(String key) {
     Object val = get(key);
@@ -191,7 +207,6 @@ public LocalTime getLocalTime(String key) {
     return LocalTime.parse(val.toString());
   }
 
-
   @Override
   public LocalDateTime getLocalDateTime(String key) {
     Object val = get(key);
@@ -223,12 +238,8 @@ public List getObjectList(String... keys) {
     return Arrays.stream(keys).map(key -> getObject(key)).collect(Collectors.toList());
   }
 
-
   @Override
   public List getStringList(String... keys) {
     return Arrays.stream(keys).map(key -> getString(key)).collect(Collectors.toList());
   }
-
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/InsertResult.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/InsertResult.java
index bb013301..e93ba107 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/InsertResult.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/InsertResult.java
@@ -1,13 +1,11 @@
 package org.nkjmlab.sorm4j.result;
 
-/**
- * Represents a result from an insert operation with the auto-generated keys.
- */
+/** Represents a result from an insert operation with the auto-generated keys. */
 public interface InsertResult {
 
   /**
-   * Returns the row count by executing a insert statement
-   * {@link java.sql.PreparedStatement#executeUpdate()}.
+   * Returns the row count by executing a insert statement {@link
+   * java.sql.PreparedStatement#executeUpdate()}.
    */
   int[] getRowsModified();
 
@@ -24,5 +22,4 @@ public interface InsertResult {
    * @return
    */
   RowMap getGeneratedKeys();
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaData.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaData.java
index 773ff3d3..a22b5cef 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaData.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaData.java
@@ -28,10 +28,18 @@ public final class JdbcDatabaseMetaData {
   private final Map> jdbcIndexesMetaData;
   private final List tableNames;
 
-  public JdbcDatabaseMetaData(String databaseProductName, String databaseProductVersion,
-      String driverName, String driverVersion, String jdbcDriverVersion,
-      int defaultTransactionIsolation, int maxConnections, String url, String userName,
-      String searchStringEscape, Map tables,
+  public JdbcDatabaseMetaData(
+      String databaseProductName,
+      String databaseProductVersion,
+      String driverName,
+      String driverVersion,
+      String jdbcDriverVersion,
+      int defaultTransactionIsolation,
+      int maxConnections,
+      String url,
+      String userName,
+      String searchStringEscape,
+      Map tables,
       Map> indexes) {
     this.databaseProductName = databaseProductName;
     this.databaseProductVersion = databaseProductVersion;
@@ -48,52 +56,42 @@ public JdbcDatabaseMetaData(String databaseProductName, String databaseProductVe
     this.tableNames = tables.keySet().stream().collect(Collectors.toList());
   }
 
-
   public String getDatabaseProductName() {
     return databaseProductName;
   }
 
-
   public String getDatabaseProductVersion() {
     return databaseProductVersion;
   }
 
-
   public String getDriverName() {
     return driverName;
   }
 
-
   public String getDriverVersion() {
     return driverVersion;
   }
 
-
   public String getSearchStringEscape() {
     return searchStringEscape;
   }
 
-
   public String getUrl() {
     return url;
   }
 
-
   public String getUserName() {
     return userName;
   }
 
-
   public String getJdbcDriverVersion() {
     return jdbcDriverVersion;
   }
 
-
   public int getDefaultTransactionIsolation() {
     return defaultTransactionIsolation;
   }
 
-
   public int getMaxConnections() {
     return maxConnections;
   }
@@ -102,7 +100,6 @@ public Map getJdbcTablesMetaData() {
     return jdbcTablesMetaData;
   }
 
-
   public Map> getJdbcIndexesMetaData() {
     return jdbcIndexesMetaData;
   }
@@ -113,65 +110,117 @@ public List getTableNames() {
 
   @Override
   public String toString() {
-    return "DatabaseMetaDataImpl [databaseProductName=" + databaseProductName
-        + ", databaseProductVersion=" + databaseProductVersion + ", driverName=" + driverName
-        + ", driverVersion=" + driverVersion + ", url=" + url + ", userName=" + userName
-        + ", jdbcDriverVersion=" + jdbcDriverVersion + ", defaultTransactionIsolation="
-        + defaultTransactionIsolation + ", maxConnections=" + maxConnections
-        + ", jdbcTablesMetaData=" + jdbcTablesMetaData + ", jdbcIndexesMetaData="
-        + jdbcIndexesMetaData + "]";
+    return "DatabaseMetaDataImpl [databaseProductName="
+        + databaseProductName
+        + ", databaseProductVersion="
+        + databaseProductVersion
+        + ", driverName="
+        + driverName
+        + ", driverVersion="
+        + driverVersion
+        + ", url="
+        + url
+        + ", userName="
+        + userName
+        + ", jdbcDriverVersion="
+        + jdbcDriverVersion
+        + ", defaultTransactionIsolation="
+        + defaultTransactionIsolation
+        + ", maxConnections="
+        + maxConnections
+        + ", jdbcTablesMetaData="
+        + jdbcTablesMetaData
+        + ", jdbcIndexesMetaData="
+        + jdbcIndexesMetaData
+        + "]";
   }
 
   public static JdbcDatabaseMetaData of(DatabaseMetaData metaData) throws SQLException {
     try (ResultSet resultSet =
         metaData.getTables(null, "PUBLIC", null, new String[] {"TABLE", "VIEW"})) {
 
-      Map tables = mapColumnsInResultSetToMap(resultSet,
-          List.of("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE", "REMARKS", "TYPE_CAT",
-              "TYPE_SCHEM", "TYPE_NAME", "SELF_REFERENCING_COL_NAME", "REF_GENERATION")).stream()
-                  .map(e -> new JdbcTableMetaData(e))
-                  .collect(Collectors.toMap(m -> m.get("TABLE_NAME"), m -> m, (v1, v2) -> v1));
+      Map tables =
+          mapColumnsInResultSetToMap(
+                  resultSet,
+                  List.of(
+                      "TABLE_CAT",
+                      "TABLE_SCHEM",
+                      "TABLE_NAME",
+                      "TABLE_TYPE",
+                      "REMARKS",
+                      "TYPE_CAT",
+                      "TYPE_SCHEM",
+                      "TYPE_NAME",
+                      "SELF_REFERENCING_COL_NAME",
+                      "REF_GENERATION"))
+              .stream()
+              .map(e -> new JdbcTableMetaData(e))
+              .collect(Collectors.toMap(m -> m.get("TABLE_NAME"), m -> m, (v1, v2) -> v1));
 
       Map> indexes = new HashMap<>();
       for (Entry jdbcTableEntry : tables.entrySet()) {
         String tableName = jdbcTableEntry.getKey();
         try (ResultSet indexInfo = metaData.getIndexInfo(null, null, tableName, false, false)) {
-          Map l = mapColumnsInResultSetToMap(indexInfo,
-              List.of("TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "INDEX_QUALIFIER", "INDEX_NAME",
-                  "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC", "CARDINALITY", "PAGES",
-                  "FILTER_CONDITION")).stream().map(e -> new JdbcIndexMetaData(e))
-                      .collect(Collectors.toMap(m -> m.get("INDEX_NAME"), m -> m, (v1, v2) -> v1));
+          Map l =
+              mapColumnsInResultSetToMap(
+                      indexInfo,
+                      List.of(
+                          "TABLE_CAT",
+                          "TABLE_SCHEM",
+                          "TABLE_NAME",
+                          "INDEX_QUALIFIER",
+                          "INDEX_NAME",
+                          "TYPE",
+                          "ORDINAL_POSITION",
+                          "COLUMN_NAME",
+                          "ASC_OR_DESC",
+                          "CARDINALITY",
+                          "PAGES",
+                          "FILTER_CONDITION"))
+                  .stream()
+                  .map(e -> new JdbcIndexMetaData(e))
+                  .collect(Collectors.toMap(m -> m.get("INDEX_NAME"), m -> m, (v1, v2) -> v1));
           indexes.put(tableName, l);
         }
       }
       Object[] params = {metaData.getJDBCMajorVersion(), metaData.getJDBCMinorVersion()};
 
-
-      return new JdbcDatabaseMetaData(metaData.getDatabaseProductName(),
-          metaData.getDatabaseProductVersion(), metaData.getDriverName(),
+      return new JdbcDatabaseMetaData(
+          metaData.getDatabaseProductName(),
+          metaData.getDatabaseProductVersion(),
+          metaData.getDriverName(),
           metaData.getDriverVersion(),
           ParameterizedStringFormatter.LENGTH_256.format("{}.{}", params),
-          metaData.getDefaultTransactionIsolation(), metaData.getMaxConnections(),
-          metaData.getURL(), metaData.getUserName(), metaData.getSearchStringEscape(), tables,
+          metaData.getDefaultTransactionIsolation(),
+          metaData.getMaxConnections(),
+          metaData.getURL(),
+          metaData.getUserName(),
+          metaData.getSearchStringEscape(),
+          tables,
           indexes);
     }
   }
 
-
-
-  private static List> mapColumnsInResultSetToMap(ResultSet resultSet,
-      List columns) throws SQLException {
+  private static List> mapColumnsInResultSetToMap(
+      ResultSet resultSet, List columns) throws SQLException {
     List> result = new ArrayList<>();
 
     while (resultSet.next()) {
-      Map index = columns.stream().collect(Collectors.toMap(col -> col, col -> {
-        try {
-          String s = resultSet.getString(col);
-          return s != null ? s : "NULL";
-        } catch (SQLException e) {
-          return "NA";
-        }
-      }, (v1, v2) -> v2, LinkedHashMap::new));
+      Map index =
+          columns.stream()
+              .collect(
+                  Collectors.toMap(
+                      col -> col,
+                      col -> {
+                        try {
+                          String s = resultSet.getString(col);
+                          return s != null ? s : "NULL";
+                        } catch (SQLException e) {
+                          return "NA";
+                        }
+                      },
+                      (v1, v2) -> v2,
+                      LinkedHashMap::new));
       result.add(index);
     }
     return result;
@@ -193,8 +242,8 @@ public String get(String key) {
     public String toString() {
       return "JdbcTableMetaData [map=" + map + "]";
     }
-
   }
+
   public static class JdbcIndexMetaData {
     private Map map;
 
@@ -210,6 +259,5 @@ public String get(String key) {
     public String toString() {
       return "JdbcIndexMetaData [map=" + map + "]";
     }
-
   }
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/ResultSetStream.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/ResultSetStream.java
index a602d84b..970230fa 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/ResultSetStream.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/result/ResultSetStream.java
@@ -11,6 +11,4 @@ public interface ResultSetStream {
   void accept(ConsumerHandler> handler);
 
    R apply(FunctionHandler, R> handler);
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/NamedParameterSqlParser.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/NamedParameterSqlParser.java
index 8012219f..d576b315 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/NamedParameterSqlParser.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/NamedParameterSqlParser.java
@@ -8,8 +8,7 @@
 /**
  * SQL parser for named parameters.
  *
- * 

- * Following characters could be used for named parameters. + *

Following characters could be used for named parameters. * *

  * 
@@ -18,7 +17,6 @@
  * 
* * @author yuu_nkjm - * */ @Experimental public interface NamedParameterSqlParser extends ParameterizedSqlParser { @@ -59,13 +57,12 @@ public interface NamedParameterSqlParser extends ParameterizedSqlParser { * @return */ @Experimental - static NamedParameterSqlParser of(String sql, char prefix, char suffix, - ColumnToFieldAccessorMapper columnFieldMapper) { + static NamedParameterSqlParser of( + String sql, char prefix, char suffix, ColumnToFieldAccessorMapper columnFieldMapper) { return new NamedParameterSqlParserImpl(sql, prefix, suffix, columnFieldMapper); } /** - * * @param sql * @param columnFieldMapper * @return @@ -75,14 +72,12 @@ static NamedParameterSqlParser of(String sql, ColumnToFieldAccessorMapper column return of(sql, ':', Character.MIN_VALUE, columnFieldMapper); } - /** * Creates {@link NamedParameterSqlParser} object. * * @param sql * @return */ - static NamedParameterSqlParser of(String sql) { return new NamedParameterSqlParserImpl(sql); } @@ -97,6 +92,4 @@ static NamedParameterSqlParser of(String sql) { static ParameterizedSql parse(String sql, Map namedParameters) { return NamedParameterSqlParser.of(sql).bindAll(namedParameters).parse(); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/OrderedParameterSqlParser.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/OrderedParameterSqlParser.java index 6d1add31..8363073e 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/OrderedParameterSqlParser.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/OrderedParameterSqlParser.java @@ -5,11 +5,10 @@ import org.nkjmlab.sorm4j.internal.sql.ParameterizedSqlImpl; /** - * SQL parser for ordered parameters. The instance could be convert to {@link ParameterizedSql}. The class - * could treat {@link List} parameter. + * SQL parser for ordered parameters. The instance could be convert to {@link ParameterizedSql}. The + * class could treat {@link List} parameter. * * @author nkjm - * */ public interface OrderedParameterSqlParser extends ParameterizedSqlParser { @@ -49,5 +48,4 @@ static ParameterizedSql parse(String sql, Object... parameters) { static OrderedParameterSqlParser of(String sql) { return new OrderedParameterSqlParserImpl(sql); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/ParameterizedSql.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/ParameterizedSql.java index 1f964776..d45f2a6d 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/ParameterizedSql.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/ParameterizedSql.java @@ -2,14 +2,11 @@ import org.nkjmlab.sorm4j.internal.sql.ParameterizedSqlImpl; - /** * This class represents a SQL statement with ordered parameters. * * @author nkjm - * */ - public interface ParameterizedSql { /** @@ -49,12 +46,10 @@ static ParameterizedSql of(String sql) { * * @param sql * @param parameters ordered parameters without special parameters (e.g. named parameter, list - * parameter and embedded parameter) + * parameter and embedded parameter) * @return */ static ParameterizedSql of(String sql, Object... parameters) { return ParameterizedSqlImpl.of(sql, parameters); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/ParameterizedSqlParser.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/ParameterizedSqlParser.java index ff792610..30d953cf 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/ParameterizedSqlParser.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/sql/ParameterizedSqlParser.java @@ -47,12 +47,17 @@ static ParameterizedSql parse(String sql, Map parameters) { */ @Experimental public static String embedParameter(String sql, Object... parameters) { - String ret = ParameterizedStringFormatter.newString(sql, "{?}", parameters.length, - index -> parameters[index] == null ? null : parameters[index].toString()); + String ret = + ParameterizedStringFormatter.newString( + sql, + "{?}", + parameters.length, + index -> parameters[index] == null ? null : parameters[index].toString()); if (ret.contains("{?}")) { Object[] params = {sql, parameters}; - throw new SormException(ParameterizedStringFormatter.LENGTH_256 - .format("Could not embed all parameters. sql={},parameters={}", params)); + throw new SormException( + ParameterizedStringFormatter.LENGTH_256.format( + "Could not embed all parameters. sql={},parameters={}", params)); } else { return ret; } @@ -72,18 +77,18 @@ public static String embedParameter(String sql, Map parameters) // Ordered by position in the sentence TreeMap orderdParams = new TreeMap<>(); - parameters.keySet().stream().forEach(key -> { - int pos = sql.indexOf("{:" + key + "}"); - if (pos == -1) { - return; - } - orderdParams.put(pos, parameters.get(key)); - }); + parameters.keySet().stream() + .forEach( + key -> { + int pos = sql.indexOf("{:" + key + "}"); + if (pos == -1) { + return; + } + orderdParams.put(pos, parameters.get(key)); + }); String _sql = sql.replaceAll("\\{:.*?\\}", "{?}"); Object[] _parameters = orderdParams.values().toArray(); return embedParameter(_sql, _parameters); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java index 8b3e1a7f..48138a79 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java @@ -39,5 +39,4 @@ public Sorm getOrm() { public String getTableName() { return tableName; } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/Table.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/Table.java index 21e0c99b..33a79a58 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/Table.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/Table.java @@ -14,9 +14,7 @@ public interface Table extends TableMappedOrm { @Override Sorm getOrm(); - static Table create(Sorm sorm, Class objectClass) { return new BasicTable<>(sorm, objectClass); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/BasicCommand.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/BasicCommand.java index 67155145..45b07f50 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/BasicCommand.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/BasicCommand.java @@ -19,6 +19,4 @@ public interface BasicCommand extends Command { static BasicCommand from(OrmConnection conn, String sql) { return new BasicCommandImpl(conn, sql); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/Command.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/Command.java index 094256e9..ed794104 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/Command.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/Command.java @@ -11,42 +11,34 @@ import org.nkjmlab.sorm4j.mapping.RowMapper; import org.nkjmlab.sorm4j.sql.ParameterizedSql; - /** * An executable request * * @author nkjm - * */ @Experimental public interface Command { - - /** * Creates a {@link Command} from SQL string. * * @param sql * @return */ - static Command create(OrmConnection conn, ParameterizedSql sql) { return BasicCommand.from(conn, sql.getSql()).addParameter(sql.getParameters()); } - /** * Creates a {@link BasicCommand} from SQL string. * * @param sql * @return */ - static BasicCommand create(OrmConnection conn, String sql) { return BasicCommand.from(conn, sql); } - /** * Creates a {@link NamedParameterCommand} from SQL string. * @@ -54,12 +46,11 @@ static BasicCommand create(OrmConnection conn, String sql) { * @param parameters * @return */ - static NamedParameterCommand create(OrmConnection conn, String sql, - Map parameters) { + static NamedParameterCommand create( + OrmConnection conn, String sql, Map parameters) { return NamedParameterCommand.of(conn, sql).bindAll(parameters); } - /** * Creates a {@link OrderedParameterCommand} from SQL string. * @@ -80,7 +71,6 @@ static OrderedParameterCommand create(OrmConnection conn, String sql, Object... */ T executeQuery(ResultSetTraverser resultSetTraverser); - /** * Executes a query and apply the given mapper to the each row in returned result set. * @@ -97,7 +87,6 @@ static OrderedParameterCommand create(OrmConnection conn, String sql, Object... */ int executeUpdate(); - /** * Reads an object from the database. * @@ -133,7 +122,6 @@ static OrderedParameterCommand create(OrmConnection conn, String sql, Object... * Reads results as List of {@link Tuple2} for reading JOIN SQL results typically. * * @see {@link OrmColumnAliasPrefix} for use column alias prefix. - * * @param * @param * @param t1 @@ -147,17 +135,12 @@ static OrderedParameterCommand create(OrmConnection conn, String sql, Object... * Reads results as List of {@link Tuple3} for reading JOIN SQL results typically. * * @see {@link OrmColumnAliasPrefix} for use column alias prefix. - * * @param * @param * @param t1 * @param t2 * @return */ - @Experimental List> readTupleList(Class t1, Class t2, Class t3); - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/NamedParameterCommand.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/NamedParameterCommand.java index ea42c643..1f7603cb 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/NamedParameterCommand.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/NamedParameterCommand.java @@ -6,17 +6,14 @@ import org.nkjmlab.sorm4j.internal.util.command.NamedParameterCommandImpl; import org.nkjmlab.sorm4j.sql.NamedParameterSqlParser; - /** * An executable request with named parameters. * * @author nkjm - * */ @Experimental public interface NamedParameterCommand extends NamedParameterSqlParser, Command { - @Override NamedParameterCommand bindAll(Map keyValuePairOfNamedParameters); @@ -36,5 +33,4 @@ public interface NamedParameterCommand extends NamedParameterSqlParser, Command static NamedParameterCommand of(OrmConnection conn, String sql) { return new NamedParameterCommandImpl(conn, sql); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/OrderedParameterCommand.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/OrderedParameterCommand.java index ef60276c..690823c2 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/OrderedParameterCommand.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/command/OrderedParameterCommand.java @@ -9,7 +9,6 @@ * An executable request with ordered parameters. * * @author nkjm - * */ @Experimental public interface OrderedParameterCommand extends OrderedParameterSqlParser, Command { @@ -30,5 +29,4 @@ public interface OrderedParameterCommand extends OrderedParameterSqlParser, Comm static OrderedParameterCommand of(OrmConnection conn, String sql) { return new OrderedParameterCommandImpl(conn, sql); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/GeometryString.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/GeometryString.java index 1382c5d2..635a3836 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/GeometryString.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/GeometryString.java @@ -4,11 +4,9 @@ import org.nkjmlab.sorm4j.annotation.Experimental; /** - * * @see Well-known text - * representation of geometry - Wikipedia - * + * "https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry">Well-known text + * representation of geometry - Wikipedia * @author nkjm */ @Experimental @@ -44,12 +42,9 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof GeometryString)) - return false; + if (this == obj) return true; + if (!(obj instanceof GeometryString)) return false; GeometryString other = (GeometryString) obj; return Objects.equals(text, other.text); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/JsonByte.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/JsonByte.java index 2cb29833..54ae5902 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/JsonByte.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/JsonByte.java @@ -24,5 +24,4 @@ public byte[] getBytes() { public String toString() { return new String(bytes, StandardCharsets.UTF_8); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/OrmJsonColumnContainer.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/OrmJsonColumnContainer.java index fe594a11..a7d8df79 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/OrmJsonColumnContainer.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/datatype/OrmJsonColumnContainer.java @@ -9,5 +9,4 @@ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.PARAMETER, ElementType.FIELD}) @Experimental -public @interface OrmJsonColumnContainer { -} +public @interface OrmJsonColumnContainer {} diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/BasicH2Table.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/BasicH2Table.java index 60fbbb83..a4f91aaf 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/BasicH2Table.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/BasicH2Table.java @@ -8,7 +8,6 @@ @Experimental public class BasicH2Table extends BasicTableWithDefinition implements H2Table { - /** * This table instance is bind to the table name defined in the given {@link TableDefinition}. * @@ -57,5 +56,4 @@ public BasicH2Table dropTableIfExistsCascade() { H2Table.super.dropTableIfExistsCascade(); return this; } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/H2Table.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/H2Table.java index a442ab4d..e5c7d372 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/H2Table.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/H2Table.java @@ -16,10 +16,13 @@ default H2CsvReadSql.Builder csvReadSqlBuilder(File csvFile) { return H2CsvReadSql.builder(csvFile, getValueType()); } - default String getReadCsvWithHeaderSql(File csvFile, Charset charset, char fieldSeparator, - Character fieldDelimiter) { - H2CsvReadSql.Builder builder = csvReadSqlBuilder(csvFile).setCharset(charset) - .setFieldSeparator(fieldSeparator).setFieldDelimiter(fieldDelimiter); + default String getReadCsvWithHeaderSql( + File csvFile, Charset charset, char fieldSeparator, Character fieldDelimiter) { + H2CsvReadSql.Builder builder = + csvReadSqlBuilder(csvFile) + .setCharset(charset) + .setFieldSeparator(fieldSeparator) + .setFieldDelimiter(fieldDelimiter); return builder.build().getCsvReadAndSelectSql(); } @@ -27,14 +30,18 @@ default List readCsvWithHeader(File csvFile) { return readCsvWithHeader(csvFile, StandardCharsets.UTF_8, ',', null); } - default List readCsvWithHeader(File csvFile, Charset charset, char fieldSeparator, - Character fieldDelimiter) { + default List readCsvWithHeader( + File csvFile, Charset charset, char fieldSeparator, Character fieldDelimiter) { try { - return getOrm().readList(getValueType(), - getReadCsvWithHeaderSql(csvFile, charset, fieldSeparator, fieldDelimiter)); + return getOrm() + .readList( + getValueType(), + getReadCsvWithHeaderSql(csvFile, charset, fieldSeparator, fieldDelimiter)); } catch (Exception e) { - throw new IllegalArgumentException("Error occurs in: " - + getReadCsvWithHeaderSql(csvFile, charset, fieldSeparator, fieldDelimiter), e); + throw new IllegalArgumentException( + "Error occurs in: " + + getReadCsvWithHeaderSql(csvFile, charset, fieldSeparator, fieldDelimiter), + e); } } @@ -46,11 +53,16 @@ default File writeCsv(File toFile, String selectSql) { return writeCsv(toFile, selectSql, StandardCharsets.UTF_8, ',', null); } - default File writeCsv(File toFile, String selectSql, Charset charset, char fieldSeparator, + default File writeCsv( + File toFile, + String selectSql, + Charset charset, + char fieldSeparator, Character fieldDelimiter) { - getOrm().executeUpdate(H2CsvFunctions.getCallCsvWriteSql(toFile, selectSql, charset, - fieldSeparator, fieldDelimiter)); + getOrm() + .executeUpdate( + H2CsvFunctions.getCallCsvWriteSql( + toFile, selectSql, charset, fieldSeparator, fieldDelimiter)); return toFile; } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/datasource/H2LocalDataSourceFactory.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/datasource/H2LocalDataSourceFactory.java index 2769fb93..371ddfa0 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/datasource/H2LocalDataSourceFactory.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/datasource/H2LocalDataSourceFactory.java @@ -16,13 +16,11 @@ * A factory of local data source with h2 database. * * * * @author nkjm - * */ @Experimental public class H2LocalDataSourceFactory { @@ -37,9 +35,8 @@ public class H2LocalDataSourceFactory { private final String embeddedModeJdbcUrl; private final String mixedModeJdbcUrl; - - private H2LocalDataSourceFactory(File databaseDirectory, String databaseName, String username, - String password) { + private H2LocalDataSourceFactory( + File databaseDirectory, String databaseName, String username, String password) { this.username = username; this.password = password; this.databaseName = databaseName; @@ -81,7 +78,6 @@ public String getMixedModeJdbcUrl() { return getMixedModeJdbcUrl(new String[0]); } - public String getInMemoryModeJdbcUrl(String... options) { return inMemoryModeJdbcUrl + toUrlOption(options); } @@ -174,7 +170,7 @@ public JdbcConnectionPool createMixedModeDataSource(String... options) { * Make a new file database in not exists * * @return true if and only if the directory was created,along with all necessary parent - * directories; false otherwise + * directories; false otherwise */ public boolean makeFileDatabaseIfNotExists() { if (getDatabaseFile().exists()) { @@ -219,7 +215,6 @@ public static Builder builder() { return new Builder(); } - /** * Initializes a newly created {@link H2LocalDataSourceFactory.Builder} object; you can get * {{@code LocalDataSourceFactory} object via build method. "~/" or "~\" in the database directory @@ -230,24 +225,34 @@ public static Builder builder() { * @param username * @param password */ - - public static Builder builder(File databaseDirectory, String databaseName, String username, - String password) { + public static Builder builder( + File databaseDirectory, String databaseName, String username, String password) { return new Builder(databaseDirectory, databaseName, username, password); } - - @Override public String toString() { - return "H2LocalDataSourceFactory [databaseDirectory=" + databaseDirectory + ", databaseName=" - + databaseName + ", username=" + username + ", password=" + password + ", databasePath=" - + databasePath + ", inMemoryModeJdbcUrl=" + inMemoryModeJdbcUrl + ", serverModeJdbcUrl=" - + serverModeJdbcUrl + ", embeddedModeJdbcUrl=" + embeddedModeJdbcUrl + ", mixedModeJdbcUrl=" - + mixedModeJdbcUrl + "]"; + return "H2LocalDataSourceFactory [databaseDirectory=" + + databaseDirectory + + ", databaseName=" + + databaseName + + ", username=" + + username + + ", password=" + + password + + ", databasePath=" + + databasePath + + ", inMemoryModeJdbcUrl=" + + inMemoryModeJdbcUrl + + ", serverModeJdbcUrl=" + + serverModeJdbcUrl + + ", embeddedModeJdbcUrl=" + + embeddedModeJdbcUrl + + ", mixedModeJdbcUrl=" + + mixedModeJdbcUrl + + "]"; } - public static class Builder { private File databaseDirectory = new File(System.getProperty("java.io.tmpdir")); private String databaseName = "tmph2db"; @@ -286,8 +291,11 @@ public H2LocalDataSourceFactory.Builder setDatabaseDirectory(File databaseDirect if (!allowPrefixes.contains(prefix) && !databaseDirectoryPath.isAbsolute()) { throw new IllegalArgumentException( - "the databaseDirectory path should be startWith " + allowPrefixes - + " or absolute path. The given is [" + databaseDirectoryPath.getPath() + "]"); + "the databaseDirectory path should be startWith " + + allowPrefixes + + " or absolute path. The given is [" + + databaseDirectoryPath.getPath() + + "]"); } this.databaseDirectory = new File(SystemPropertyUtils.getTildeExpandAbsolutePath(databaseDirectoryPath)); @@ -307,7 +315,6 @@ public H2LocalDataSourceFactory.Builder setDatabaseName(String dbName) { public H2LocalDataSourceFactory build() { return new H2LocalDataSourceFactory(databaseDirectory, databaseName, username, password); } - } /** @@ -316,10 +323,7 @@ public H2LocalDataSourceFactory build() { * @return */ public static DataSource createTemporalInMemoryDataSource() { - return JdbcConnectionPool - .create("jdbc:h2:mem:" + UUID.randomUUID().toString() + ";DB_CLOSE_DELAY=-1;", "", ""); + return JdbcConnectionPool.create( + "jdbc:h2:mem:" + UUID.randomUUID().toString() + ";DB_CLOSE_DELAY=-1;", "", ""); } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerProcess.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerProcess.java index 8474223b..d390e1fb 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerProcess.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerProcess.java @@ -53,7 +53,6 @@ static boolean isActive(int port) { } } - /** * Starts H2 server process and wait for start server. * @@ -65,17 +64,27 @@ static boolean isActive(int port) { static boolean awaitStartServer(H2ServerProperties props, long timeout, TimeUnit unit) { if (isActive(props.port)) { - log.info("H2 {} server has been already active at http://localhost:{}", props.serverType, + log.info( + "H2 {} server has been already active at http://localhost:{}", + props.serverType, props.port); return true; } try { - log.info("H2 {} Server will be start => {}", props.serverType, Stream.of(props.args) - .filter(arg -> !arg.equals(props.password)).collect(Collectors.toList())); + log.info( + "H2 {} Server will be start => {}", + props.serverType, + Stream.of(props.args) + .filter(arg -> !arg.equals(props.password)) + .collect(Collectors.toList())); ProcessBuilder pb = new ProcessBuilder(props.args); pb.redirectErrorStream(true); - log.info("Wait up [{} {}] for H2 {} server starts at port {}.", timeout, unit, - props.serverType, props.port); + log.info( + "Wait up [{} {}] for H2 {} server starts at port {}.", + timeout, + unit, + props.serverType, + props.port); pb.start(); } catch (IOException e) { throw Try.rethrow(e); @@ -92,15 +101,14 @@ static boolean awaitStartServer(H2ServerProperties props, long timeout, TimeUnit } TimeUnit.SECONDS.sleep(1); } - log.info("[{} msec] H2 {} server is active at http://localhost:{}", - System.currentTimeMillis() - start, props.serverType, props.port); + log.info( + "[{} msec] H2 {} server is active at http://localhost:{}", + System.currentTimeMillis() - start, + props.serverType, + props.port); return true; } catch (InterruptedException e) { throw Try.rethrow(e); } - } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerProperties.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerProperties.java index 8bea747a..0c58ec49 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerProperties.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerProperties.java @@ -6,7 +6,6 @@ * This class represents H2 server properties. * * @author nkjm - * */ @Experimental public class H2ServerProperties { @@ -22,7 +21,4 @@ public H2ServerProperties(String serverType, int port, String password, String[] this.password = password; this.args = args; } - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerPropertiesBuilder.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerPropertiesBuilder.java index c6f5b78c..127df4a8 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerPropertiesBuilder.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2ServerPropertiesBuilder.java @@ -31,7 +31,6 @@ public H2ServerPropertiesBuilder setH2ClassPath(String h2ClassPath) { return getThisBuilder(); } - public H2ServerPropertiesBuilder setServerType(String serverType) { this.serverType = serverType; return getThisBuilder(); @@ -59,7 +58,4 @@ public String getH2ClassPath() { } public abstract H2ServerProperties build(); - - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProcess.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProcess.java index 73b1d40e..4563aaea 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProcess.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProcess.java @@ -17,7 +17,6 @@ public H2TcpServerProcess(H2TcpServerProperties properties) { super(properties); } - /** * @see #awaitShutdown(long, TimeUnit) * @return @@ -37,15 +36,19 @@ public boolean awaitShutdown(long timeout, TimeUnit unit) { return awaitShutdownTcpServer((H2TcpServerProperties) properties, timeout, unit); } - private static boolean awaitShutdownTcpServer(H2TcpServerProperties props, long timeout, - TimeUnit unit) { + private static boolean awaitShutdownTcpServer( + H2TcpServerProperties props, long timeout, TimeUnit unit) { if (!isActive(props.port)) { log.info("H2 TCP server is not active at {}.", props.port); return true; } try { - log.info("Wait up [{} {}] for H2 {} server shutdowns at port {}.", timeout, unit, - props.serverType, props.port); + log.info( + "Wait up [{} {}] for H2 {} server shutdowns at port {}.", + timeout, + unit, + props.serverType, + props.port); Server.shutdownTcpServer("tcp://localhost:" + props.port, props.password, false, false); } catch (SQLException e) { throw Try.rethrow(e); @@ -67,5 +70,4 @@ private static boolean awaitShutdownTcpServer(H2TcpServerProperties props, long log.info("H2 TCP server is not active."); return true; } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProperties.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProperties.java index 84c3deb1..87c6fe52 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProperties.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProperties.java @@ -5,11 +5,7 @@ import java.util.List; import org.nkjmlab.sorm4j.annotation.Experimental; -/** - * - * @author nkjm - * - */ +/** @author nkjm */ @Experimental public class H2TcpServerProperties extends H2ServerProperties { @@ -29,10 +25,7 @@ public static Builder builder() { public static class Builder extends H2ServerPropertiesBuilder { private static final int DEFAULT_TCP_PORT = 9092; - - /** - * This constructor is for external libraries. - */ + /** This constructor is for external libraries. */ public Builder() { super("TCP", DEFAULT_TCP_PORT, ""); } @@ -53,6 +46,4 @@ public Builder getThisBuilder() { return this; } } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebBrowsingService.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebBrowsingService.java index fc514b50..e5d209f0 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebBrowsingService.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebBrowsingService.java @@ -16,7 +16,6 @@ public class H2WebBrowsingService { private final WebServer webServer; /** - * * @param dataSource * @param keepAlive is false, the Web console server shutdown after the main thread finishes. */ @@ -28,11 +27,13 @@ public WebServer getWebServer() { return webServer; } - private static WebServer startTemporalWebConsoleServer(boolean keepAlive) { try { - Server server = Server.createWebServer(keepAlive ? new String[] {"-webPort", "0"} - : new String[] {"-webPort", "0", "-webDaemon"}); + Server server = + Server.createWebServer( + keepAlive + ? new String[] {"-webPort", "0"} + : new String[] {"-webPort", "0", "-webDaemon"}); server.start(); log.info("H2 temporal Web console server started at {}", server.getURL()); WebServer webServer = (WebServer) server.getService(); @@ -46,12 +47,9 @@ private static WebServer startTemporalWebConsoleServer(boolean keepAlive) { * Open a new browser tab or window. * * @param conn - * * @see #startTemporalWebConsoleServer(boolean) - * * @return */ - public void open(Connection conn) { try { webServer.addSession(conn); @@ -68,12 +66,9 @@ public void open(Connection conn) { * * @param dataSource * @return - * * @see #startTemporalWebConsoleServer(boolean) */ public void open(DataSource dataSource) { Try.runOrElseThrow(() -> open(dataSource.getConnection()), Try::rethrow); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcess.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcess.java index f551a56e..4008f141 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcess.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcess.java @@ -15,7 +15,6 @@ public H2WebConsoleServerProcess(H2WebConsoleServerProperties properties) { this.properties = properties; } - public boolean awaitStart() { return awaitStart(DEFAULT_TIMEOUT, DEFAULT_TIMEUNIT); } @@ -25,9 +24,7 @@ public boolean awaitStart() { * * @param props */ - public boolean awaitStart(long timeout, TimeUnit unit) { return H2ServerProcess.awaitStartServer(properties, timeout, unit); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProperties.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProperties.java index 6711a752..f3b38af6 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProperties.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProperties.java @@ -7,9 +7,8 @@ /** * @see Settings of the H2 - * Console + * Console * @author nkjm - * */ @Experimental public class H2WebConsoleServerProperties extends H2ServerProperties { @@ -21,10 +20,7 @@ public H2WebConsoleServerProperties(String serverType, int port, String password public static class Builder extends H2ServerPropertiesBuilder { private static final int DEFAULT_WEBCONSOLE_PORT = 8082; - /** - * This constructor is for external libraries. - */ - + /** This constructor is for external libraries. */ public Builder() { super("WEB_CONSOLE", DEFAULT_WEBCONSOLE_PORT, ""); } @@ -37,8 +33,8 @@ public H2WebConsoleServerProperties build() { args.addAll(Arrays.asList(options)); args.add("-webAdminPassword"); args.add(password); - return new H2WebConsoleServerProperties(serverType, port, password, - args.toArray(String[]::new)); + return new H2WebConsoleServerProperties( + serverType, port, password, args.toArray(String[]::new)); } @Override diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/CsvColumn.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/CsvColumn.java index d0bdf825..d0d45d5d 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/CsvColumn.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/CsvColumn.java @@ -8,17 +8,18 @@ /** * Mapping a csv column to a table column. + * *
Example.
* *
  * 
  *   @OrmRecord
-  public static class Item {
-    @CsvColumn("parsedatetime(delivery_date, 'y/MM/d')")
-    public LocalDate deliveryDate;
-    @CsvColumn("`price/prices`")
-    public int price;
-  }
+ * public static class Item {
+ * @CsvColumn("parsedatetime(delivery_date, 'y/MM/d')")
+ * public LocalDate deliveryDate;
+ * @CsvColumn("`price/prices`")
+ * public int price;
+ * }
  * 
  * 
* @@ -34,5 +35,4 @@ public static class Item { public @interface CsvColumn { String value(); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvFunctions.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvFunctions.java index c6a4ebd1..16300872 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvFunctions.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvFunctions.java @@ -27,17 +27,28 @@ private H2CsvFunctions() {} * @param fieldSeparator * @return */ - public static String getCallCsvWriteSql(File toFile, String selectSql, Charset charset, - char fieldSeparator, Character fieldDelimiter) { + public static String getCallCsvWriteSql( + File toFile, + String selectSql, + Charset charset, + char fieldSeparator, + Character fieldDelimiter) { String _fieldSeparator = toStringChar(fieldSeparator); - String csvOptions = literal("charset=" + charset.name()) + createFiledDelimiter(fieldDelimiter) - + createFieldSepartor(_fieldSeparator); - String csvStmt = "call csvwrite(" + literal(toFile.getAbsolutePath()) + "," + literal(selectSql) - + "," + csvOptions + ")"; + String csvOptions = + literal("charset=" + charset.name()) + + createFiledDelimiter(fieldDelimiter) + + createFieldSepartor(_fieldSeparator); + String csvStmt = + "call csvwrite(" + + literal(toFile.getAbsolutePath()) + + "," + + literal(selectSql) + + "," + + csvOptions + + ")"; return csvStmt; } - private static String createFieldSepartor(String _fieldSeparator) { return "||" + literal(" fieldSeparator=") + "||" + _fieldSeparator; } @@ -63,28 +74,38 @@ private static String createFiledDelimiter(Character fieldDelimiter) { * @param fieldSeparator * @return */ - public static String getCsvReadSql(File csvFile, List csvColumns, Charset charset, - char fieldSeparator, Character fieldDelimiter) { + public static String getCsvReadSql( + File csvFile, + List csvColumns, + Charset charset, + char fieldSeparator, + Character fieldDelimiter) { String _fieldSeparator = toStringChar(fieldSeparator); - String csvOptions = literal("charset=" + charset.name()) + (fieldDelimiter != null - ? ("||" + literal(" fieldDelimiter=") + "||" + toStringChar(fieldDelimiter)) - : "") + ("||" + literal(" fieldSeparator=") + "||" + _fieldSeparator); - String colSql = (csvColumns == null || csvColumns.size() == 0 ? "null" - : String.join("||" + _fieldSeparator + "||", csvColumns.stream() - .map(col -> literal(col.toUpperCase().replace("`", ""))).toArray(String[]::new))); + String csvOptions = + literal("charset=" + charset.name()) + + (fieldDelimiter != null + ? ("||" + literal(" fieldDelimiter=") + "||" + toStringChar(fieldDelimiter)) + : "") + + ("||" + literal(" fieldSeparator=") + "||" + _fieldSeparator); + String colSql = + (csvColumns == null || csvColumns.size() == 0 + ? "null" + : String.join( + "||" + _fieldSeparator + "||", + csvColumns.stream() + .map(col -> literal(col.toUpperCase().replace("`", ""))) + .toArray(String[]::new))); String readCsvSql = "csvread(" + literal(csvFile.getAbsolutePath()) + "," + colSql + "," + csvOptions + ")"; return readCsvSql; } - private static String toStringChar(char fieldSeparator) { return "char(" + ((int) fieldSeparator) + ")"; } /** - * * @param selectedColumns columns in select clause. null or empty means the all columns. * @param csvFile * @param csvColumns @@ -92,13 +113,18 @@ private static String toStringChar(char fieldSeparator) { * @param fieldSeparator * @return */ - public static String getCsvReadAndSelectSql(List selectedColumns, File csvFile, - List csvColumns, Charset charset, char fieldSeparator, Character fieldDelimiter) { + public static String getCsvReadAndSelectSql( + List selectedColumns, + File csvFile, + List csvColumns, + Charset charset, + char fieldSeparator, + Character fieldDelimiter) { return "select " - + (selectedColumns == null || selectedColumns.size() == 0 ? "*" + + (selectedColumns == null || selectedColumns.size() == 0 + ? "*" : String.join(",", selectedColumns)) - + " from " + getCsvReadSql(csvFile, csvColumns, charset, fieldSeparator, fieldDelimiter); + + " from " + + getCsvReadSql(csvFile, csvColumns, charset, fieldSeparator, fieldDelimiter); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvReadSql.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvReadSql.java index 3384ba82..ebab8318 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvReadSql.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvReadSql.java @@ -31,7 +31,11 @@ public H2CsvReadSql(List columns, String csvReadAndSelectSql) { } public String getCsvReadAndInsertSql(String tableName) { - return "insert into " + tableName + "(" + String.join(",", columns) + ") " + return "insert into " + + tableName + + "(" + + String.join(",", columns) + + ") " + getCsvReadAndSelectSql(); } @@ -52,16 +56,14 @@ public static Builder builder(File csvFile) { } public static class Builder { - /** - * Columns for SQL. null or empty means the all columns. - */ + /** Columns for SQL. null or empty means the all columns. */ private List columns = new ArrayList<>(); + private Map aliases = new HashMap<>(); - /** - * Columns in CSV files. null or empty means using the first row as the header. - */ + /** Columns in CSV files. null or empty means using the first row as the header. */ private List csvColumns = new ArrayList<>(); + private File csvFile; private Charset charset = StandardCharsets.UTF_8; private char fieldSeparator = ','; @@ -76,24 +78,29 @@ public Builder(File csvFile, Class ormRecordClass) { setOrmRecordClass(ormRecordClass); } - private Builder() {} public H2CsvReadSql build() { List selectedColumns = new ArrayList<>(columns); - aliases.entrySet().forEach(en -> { - int index = selectedColumns.indexOf(en.getKey()); - if (index == -1) { - Object[] params = {en.getKey(), columns}; - throw new IllegalStateException(ParameterizedStringFormatter.LENGTH_256 - .format("{} is not found in Columns {}", params)); - } - selectedColumns.set(index, en.getValue()); - }); - - return new H2CsvReadSql(columns, H2CsvFunctions.getCsvReadAndSelectSql(selectedColumns, - csvFile, csvColumns, charset, fieldSeparator, fieldDelimiter)); + aliases + .entrySet() + .forEach( + en -> { + int index = selectedColumns.indexOf(en.getKey()); + if (index == -1) { + Object[] params = {en.getKey(), columns}; + throw new IllegalStateException( + ParameterizedStringFormatter.LENGTH_256.format( + "{} is not found in Columns {}", params)); + } + selectedColumns.set(index, en.getValue()); + }); + + return new H2CsvReadSql( + columns, + H2CsvFunctions.getCsvReadAndSelectSql( + selectedColumns, csvFile, csvColumns, charset, fieldSeparator, fieldDelimiter)); } public Builder setCsvFile(File csvFile) { @@ -116,7 +123,6 @@ public Builder setFieldDelimiter(Character fieldDelimiter) { return this; } - public Builder setCharset(String charset) { return setCharset(Charset.forName(charset)); } @@ -139,30 +145,41 @@ public Builder setCsvColumns(String... csvColumns) { return setCsvColumns(Arrays.asList(csvColumns)); } - public Builder mapCsvColumnToTableColumn(String expression, String column) { aliases.put(column, expression + " as " + column); return this; } - - @Override public String toString() { - return "Builder [columns=" + columns + ", aliases=" + aliases + ", csvColumns=" + csvColumns - + ", csvFile=" + csvFile + ", charset=" + charset + ", fieldSeparator=" + fieldSeparator - + ", fieldDelimiter=" + fieldDelimiter + "]"; + return "Builder [columns=" + + columns + + ", aliases=" + + aliases + + ", csvColumns=" + + csvColumns + + ", csvFile=" + + csvFile + + ", charset=" + + charset + + ", fieldSeparator=" + + fieldSeparator + + ", fieldDelimiter=" + + fieldDelimiter + + "]"; } public Builder setOrmRecordClass(Class ormRecordClass) { Annotation[][] parameterAnnotationsOfConstructor = TableDefinition.getCanonicalConstructor(ormRecordClass) - .map(constructor -> constructor.getParameterAnnotations()).orElse(null); + .map(constructor -> constructor.getParameterAnnotations()) + .orElse(null); - Field[] fields = Stream.of(ormRecordClass.getDeclaredFields()) - .filter(f -> !java.lang.reflect.Modifier.isStatic(f.getModifiers())) - .toArray(Field[]::new); + Field[] fields = + Stream.of(ormRecordClass.getDeclaredFields()) + .filter(f -> !java.lang.reflect.Modifier.isStatic(f.getModifiers())) + .toArray(Field[]::new); List csvSkipColumns = new ArrayList<>(); @@ -178,24 +195,24 @@ public Builder setOrmRecordClass(Class ormRecordClass) { } for (Annotation ann : anns) { if (ann instanceof CsvColumn) { - mapCsvColumnToTableColumn(((CsvColumn) ann).value(), - StringCache.toUpperSnakeCase(field.getName())); + mapCsvColumnToTableColumn( + ((CsvColumn) ann).value(), StringCache.toUpperSnakeCase(field.getName())); } else if (ann instanceof SkipCsvRead) { csvSkipColumns.add(field); } - } } - setTableColumns(Stream.of(fields).map(f -> { - return csvSkipColumns.contains(f) ? "null as " + StringCache.toUpperSnakeCase(f.getName()) - : StringCache.toUpperSnakeCase(f.getName()); - }).toArray(String[]::new)); + setTableColumns( + Stream.of(fields) + .map( + f -> { + return csvSkipColumns.contains(f) + ? "null as " + StringCache.toUpperSnakeCase(f.getName()) + : StringCache.toUpperSnakeCase(f.getName()); + }) + .toArray(String[]::new)); return this; } - - } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/SkipCsvRead.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/SkipCsvRead.java index 65218ac8..42332a66 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/SkipCsvRead.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/sql/SkipCsvRead.java @@ -5,15 +5,11 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; - /** * The csvread function of the H2 database skips columns based on their annotations. * * @author nkjm - * */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.PARAMETER, ElementType.FIELD}) -public @interface SkipCsvRead { - -} +public @interface SkipCsvRead {} diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonColumnValueToJavaObjectConverter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonColumnValueToJavaObjectConverter.java index af2e4ff3..33e6135f 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonColumnValueToJavaObjectConverter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonColumnValueToJavaObjectConverter.java @@ -21,18 +21,21 @@ public class JacksonColumnValueToJavaObjectConverter implements ColumnValueToJav private final Map, Boolean> ormJsonContainer = new ConcurrentHashMap<>(); - public JacksonColumnValueToJavaObjectConverter(ObjectMapper objectMapper, - Class... ormJsonColumnContainerClasses) { + public JacksonColumnValueToJavaObjectConverter( + ObjectMapper objectMapper, Class... ormJsonColumnContainerClasses) { this.objectMapper = objectMapper; Arrays.stream(ormJsonColumnContainerClasses).forEach(c -> ormJsonContainer.put(c, true)); } private boolean isOrmJsonContainer(Class type) { - return ormJsonContainer.computeIfAbsent(type, - key -> ArrayUtils.getInternalComponentType(type) - .getAnnotation(OrmJsonColumnContainer.class) != null - || List.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type) - || ormJsonContainer.getOrDefault(ArrayUtils.getInternalComponentType(type), false)); + return ormJsonContainer.computeIfAbsent( + type, + key -> + ArrayUtils.getInternalComponentType(type).getAnnotation(OrmJsonColumnContainer.class) + != null + || List.class.isAssignableFrom(type) + || Map.class.isAssignableFrom(type) + || ormJsonContainer.getOrDefault(ArrayUtils.getInternalComponentType(type), false)); } @Override diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonSormContext.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonSormContext.java index d4e55313..af109fdb 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonSormContext.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonSormContext.java @@ -11,14 +11,15 @@ public class JacksonSormContext { private JacksonSormContext() {} - public static SormContext.Builder builder(ObjectMapper objectMapper, - Class... ormJsonColumnContainerClasses) { + public static SormContext.Builder builder( + ObjectMapper objectMapper, Class... ormJsonColumnContainerClasses) { return SormContext.builder() - .setColumnValueToJavaObjectConverters(new DefaultColumnValueToJavaObjectConverters( - new JacksonColumnValueToJavaObjectConverter(objectMapper, - ormJsonColumnContainerClasses))) - .setSqlParametersSetter(new DefaultSqlParametersSetter( - new JacksonSqlParameterSetter(objectMapper, ormJsonColumnContainerClasses))); + .setColumnValueToJavaObjectConverters( + new DefaultColumnValueToJavaObjectConverters( + new JacksonColumnValueToJavaObjectConverter( + objectMapper, ormJsonColumnContainerClasses))) + .setSqlParametersSetter( + new DefaultSqlParametersSetter( + new JacksonSqlParameterSetter(objectMapper, ormJsonColumnContainerClasses))); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonSqlParameterSetter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonSqlParameterSetter.java index e4b8b428..b0f69a14 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonSqlParameterSetter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jackson/JacksonSqlParameterSetter.java @@ -19,18 +19,21 @@ public class JacksonSqlParameterSetter implements SqlParameterSetter { private final ObjectMapper objectMapper; private final Map, Boolean> ormJsonContainer = new ConcurrentHashMap<>(); - public JacksonSqlParameterSetter(ObjectMapper objectMapper, - Class... ormJsonColumnContainerClasses) { + public JacksonSqlParameterSetter( + ObjectMapper objectMapper, Class... ormJsonColumnContainerClasses) { this.objectMapper = objectMapper; Arrays.stream(ormJsonColumnContainerClasses).forEach(c -> ormJsonContainer.put(c, true)); } private boolean isOrmJsonContainer(Class type) { - return ormJsonContainer.computeIfAbsent(type, - key -> ArrayUtils.getInternalComponentType(type) - .getAnnotation(OrmJsonColumnContainer.class) != null - || List.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type) - || ormJsonContainer.getOrDefault(ArrayUtils.getInternalComponentType(type), false)); + return ormJsonContainer.computeIfAbsent( + type, + key -> + ArrayUtils.getInternalComponentType(type).getAnnotation(OrmJsonColumnContainer.class) + != null + || List.class.isAssignableFrom(type) + || Map.class.isAssignableFrom(type) + || ormJsonContainer.getOrDefault(ArrayUtils.getInternalComponentType(type), false)); } @Override diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/GeometryJts.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/GeometryJts.java index 51d05d1d..55609414 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/GeometryJts.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/GeometryJts.java @@ -27,16 +27,11 @@ public int hashCode() { return Objects.hash(geometry); } - @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof GeometryJts)) - return false; + if (this == obj) return true; + if (!(obj instanceof GeometryJts)) return false; GeometryJts other = (GeometryJts) obj; return Objects.equals(geometry, other.geometry); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsColumnValueToJavaObjectConverter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsColumnValueToJavaObjectConverter.java index 8981e3ba..5f411c1f 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsColumnValueToJavaObjectConverter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsColumnValueToJavaObjectConverter.java @@ -12,14 +12,15 @@ @Experimental public class JtsColumnValueToJavaObjectConverter implements ColumnValueToJavaObjectConverter { - private final Map, Boolean> jtsContainer = new ConcurrentHashMap<>(); private boolean isJtsContainer(Class type) { - return jtsContainer.computeIfAbsent(type, - key -> org.nkjmlab.sorm4j.util.jts.GeometryJts.class.isAssignableFrom(type) - || org.nkjmlab.sorm4j.util.jts.GeometryJts.class - .isAssignableFrom(ArrayUtils.getInternalComponentType(type))); + return jtsContainer.computeIfAbsent( + type, + key -> + org.nkjmlab.sorm4j.util.jts.GeometryJts.class.isAssignableFrom(type) + || org.nkjmlab.sorm4j.util.jts.GeometryJts.class.isAssignableFrom( + ArrayUtils.getInternalComponentType(type))); } @Override diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsSormContext.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsSormContext.java index 63886417..c599f72a 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsSormContext.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsSormContext.java @@ -16,5 +16,4 @@ public static SormContext.Builder builder() { new DefaultColumnValueToJavaObjectConverters(new JtsColumnValueToJavaObjectConverter())) .setSqlParametersSetter(new DefaultSqlParametersSetter(new JtsSqlParameterSetter())); } - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsSqlParameterSetter.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsSqlParameterSetter.java index 93973a09..b49d2e08 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsSqlParameterSetter.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/jts/JtsSqlParameterSetter.java @@ -13,10 +13,12 @@ public class JtsSqlParameterSetter implements SqlParameterSetter { private final Map, Boolean> jtsContainer = new ConcurrentHashMap<>(); private boolean isJtsContainer(Class type) { - return jtsContainer.computeIfAbsent(type, - key -> org.nkjmlab.sorm4j.util.jts.GeometryJts.class.isAssignableFrom(type) - || org.nkjmlab.sorm4j.util.jts.GeometryJts.class - .isAssignableFrom(ArrayUtils.getInternalComponentType(type))); + return jtsContainer.computeIfAbsent( + type, + key -> + org.nkjmlab.sorm4j.util.jts.GeometryJts.class.isAssignableFrom(type) + || org.nkjmlab.sorm4j.util.jts.GeometryJts.class.isAssignableFrom( + ArrayUtils.getInternalComponentType(type))); } @Override diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/LogPoint.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/LogPoint.java index 64701cae..d9584ceb 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/LogPoint.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/LogPoint.java @@ -16,7 +16,6 @@ public final class LogPoint { this.logger = logger; } - private long getElapsedTime() { return System.nanoTime() - startTime; } @@ -29,38 +28,31 @@ public void logAfterMultiRow(int[] result) { logger.logAfterMultiRow(name, getElapsedTime(), result); } - public void logAfterQuery(Object ret) { logger.logAfterQuery(getTag(), getElapsedTime(), ret); } - public void logAfterUpdate(int ret) { logger.logAfterUpdate(name, getElapsedTime(), ret); } - public void logBeforeMultiRow(Connection con, Class objectClass, int length, - String tableName) { + public void logBeforeMultiRow( + Connection con, Class objectClass, int length, String tableName) { logger.logBeforeMultiRow(getTag(), con, objectClass, length, tableName); this.startTime = System.nanoTime(); } - public void logBeforeSql(Connection connection, ParameterizedSql sql) { logger.logBeforeSql(getTag(), connection, sql); this.startTime = System.nanoTime(); } - public void logBeforeSql(Connection connection, String sql, Object... parameters) { logger.logBeforeSql(getTag(), connection, sql, parameters); this.startTime = System.nanoTime(); } - public void logMapping(String mappingInfo) { logger.logMapping(getTag(), mappingInfo); } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/LoggerContext.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/LoggerContext.java index e35733b8..92ebf047 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/LoggerContext.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/LoggerContext.java @@ -17,16 +17,15 @@ * Logger for Sorm4j. * * @author nkjm - * */ public final class LoggerContext { - /** - * Logging Categories - * - */ + /** Logging Categories */ public enum Category { - MAPPING, EXECUTE_QUERY, MULTI_ROW, EXECUTE_UPDATE; + MAPPING, + EXECUTE_QUERY, + MULTI_ROW, + EXECUTE_UPDATE; } public static Builder builder() { @@ -39,15 +38,16 @@ public static Builder builder() { private final Map, SormLogger> loggers = new ConcurrentHashMap<>(); - private LoggerContext(Supplier loggerSupplier, - Set enabledCategories) { + private LoggerContext( + Supplier loggerSupplier, Set enabledCategories) { this.loggerSupplier = loggerSupplier; this.enabledCategories = enabledCategories.size() == 0 ? Collections.emptySet() : EnumSet.copyOf(enabledCategories); } public Optional createLogPoint(LoggerContext.Category category, Class callerClass) { - return isEnable(category) ? Optional.of(new LogPoint(category.name(), getLogger(callerClass))) + return isEnable(category) + ? Optional.of(new LogPoint(category.name(), getLogger(callerClass))) : Optional.empty(); } @@ -61,18 +61,21 @@ public boolean isEnable(LoggerContext.Category category) { @Override public String toString() { - return "LoggerContext [enabledCategories=" + enabledCategories + ", logger=" - + getLogger(LoggerContext.class) + "]"; + return "LoggerContext [enabledCategories=" + + enabledCategories + + ", logger=" + + getLogger(LoggerContext.class) + + "]"; } public static Supplier getDefaultLoggerSupplier() { - return Log4jSormLogger.enableLogger ? Log4jSormLogger::getLogger + return Log4jSormLogger.enableLogger + ? Log4jSormLogger::getLogger : (Slf4jSormLogger.enableLogger ? Slf4jSormLogger::getLogger : JulSormLogger::getLogger); } public static class Builder { - private Supplier loggerSupplier; private final Set onCategories = new HashSet<>(); @@ -94,9 +97,7 @@ public Builder disable(LoggerContext.Category... categories) { return this; } - /** - * Disables logging all categories. See {@link LoggerContext.Category}. - */ + /** Disables logging all categories. See {@link LoggerContext.Category}. */ public Builder disableAll() { disable(LoggerContext.Category.values()); return this; @@ -112,9 +113,7 @@ public Builder enable(LoggerContext.Category... categories) { return this; } - /** - * Enables logging all categories. See {@link LoggerContext.Category}. - */ + /** Enables logging all categories. See {@link LoggerContext.Category}. */ public Builder enableAll() { enable(LoggerContext.Category.values()); return this; @@ -125,6 +124,4 @@ public Builder setLoggerSupplier(Supplier loggerSupplier) { return this; } } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/SormLogger.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/SormLogger.java index 47e2e018..7e89b323 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/SormLogger.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/logger/SormLogger.java @@ -31,8 +31,8 @@ public interface SormLogger { void logBeforeSql(String tag, Connection connection, ParameterizedSql psql); - void logBeforeMultiRow(String tag, Connection connection, Class objectClass, int length, - String tableName); + void logBeforeMultiRow( + String tag, Connection connection, Class objectClass, int length, String tableName); void logAfterQuery(String tag, long elapsedTime, Object ret); @@ -41,5 +41,4 @@ void logBeforeMultiRow(String tag, Connection connection, Class objectClass, void logAfterMultiRow(String tag, long elapsedTime, int[] result); void logMapping(String tag, String mappingInfo); - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/JoinSql.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/JoinSql.java index b6401abd..add6fa48 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/JoinSql.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/JoinSql.java @@ -35,12 +35,10 @@ private Builder(TableMetaData tableMetaData) { this.froms.add(tableMetaData.getTableName()); } - private Builder(TableMappedOrm first) { this(first.getTableMetaData()); } - public JoinSql.Builder joinUsing(TableMetaData other, String... columnsForJoin) { return joinUsing("join", other, columnsForJoin); } @@ -73,18 +71,18 @@ public JoinSql.Builder leftJoinOn(TableMappedOrm other, String onCondition) { return leftJoinOn(other.getTableMetaData(), onCondition); } - private JoinSql.Builder joinUsing(String joinType, TableMetaData tableMetaData, - String... columnsForJoin) { + private JoinSql.Builder joinUsing( + String joinType, TableMetaData tableMetaData, String... columnsForJoin) { return join(joinType, tableMetaData, "using (" + String.join(",", columnsForJoin) + ")"); } - private JoinSql.Builder joinOn(String joinType, TableMetaData tableMetaData, - String onCondition) { + private JoinSql.Builder joinOn( + String joinType, TableMetaData tableMetaData, String onCondition) { return join(joinType, tableMetaData, "on " + onCondition); } - public JoinSql.Builder join(String joinType, TableMetaData otherTableMetaData, - String joinCondition) { + public JoinSql.Builder join( + String joinType, TableMetaData otherTableMetaData, String joinCondition) { columns.addAll(otherTableMetaData.getColumnAliases()); froms.add(String.join(" ", joinType, otherTableMetaData.getTableName(), joinCondition)); return this; @@ -105,7 +103,6 @@ public Builder where(Condition condition) { return this; } - /** * Creates where clause. * @@ -129,7 +126,6 @@ public Builder orderBy(String... order) { return this; } - /** * Creates limit clause. * @@ -169,9 +165,6 @@ public String build() { sql.append("limit " + limit); } return sql.toString(); - } } - - } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/SelectSql.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/SelectSql.java index d0da052a..785b4196 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/SelectSql.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/SelectSql.java @@ -8,12 +8,10 @@ import java.util.stream.Collectors; import org.nkjmlab.sorm4j.annotation.Experimental; - /** * API of creates a select SQL statement. * * @author nkjm - * */ @Experimental public final class SelectSql { @@ -56,18 +54,15 @@ public String build() { return toString(); } - /** - * Add distinct keyword to SQL. - */ - + /** Add distinct keyword to SQL. */ public Builder distinct() { this.distinct = true; return this; } - /** * Creates from clause. + * *

* *

@@ -93,7 +88,6 @@ public Builder groupBy(String... columns) {
       return this;
     }
 
-
     /**
      * Creates having clause with the given {@link Condition}.
      *
@@ -105,8 +99,6 @@ public Builder having(Condition condition) {
       return this;
     }
 
-
-
     /**
      * Creates having clause.
      *
@@ -118,7 +110,6 @@ public Builder having(String expr) {
       return this;
     }
 
-
     /**
      * Creates limit clause.
      *
@@ -129,8 +120,6 @@ public Builder limit(int limit) {
       return limit(limit, 0);
     }
 
-
-
     /**
      * Creates limit clause with offset.
      *
@@ -142,8 +131,6 @@ public Builder limit(int limit, int offset) {
       return this;
     }
 
-
-
     /**
      * Creates order by clause.
      *
@@ -156,11 +143,10 @@ public Builder orderBy(String... order) {
       return this;
     }
 
-
     /**
      * Creates select clause. The default value is "*".
-     * 

- * For example, + * + *

For example, * *

      * select("id","name","age") returns "select id, name, age"
@@ -174,7 +160,6 @@ public Builder select(String... columns) {
       return this;
     }
 
-
     /**
      * Creates prettified string.
      *
@@ -222,14 +207,11 @@ public String toPrettyString(boolean prettyPrint) {
       return sql.toString();
     }
 
-
     @Override
     public String toString() {
       return toPrettyString(false);
     }
 
-
-
     /**
      * Creates where clause.
      *
@@ -241,7 +223,6 @@ public Builder where(Condition condition) {
       return this;
     }
 
-
     /**
      * Creates where clause.
      *
@@ -252,14 +233,12 @@ public Builder where(String expr) {
       where = expr;
       return this;
     }
-
   }
 
   /**
    * Value object represents conditions of where clause or having clause. This object could include
    * AND and OR operators.
    */
-
   public static class Condition {
     private final Object condition;
 
@@ -288,7 +267,6 @@ private Condition(Object left, String op, Object right) {
       this.condition = left + " " + op.trim() + " " + right;
     }
 
-
     @Override
     public String toString() {
       return condition.toString();
@@ -316,11 +294,9 @@ public static String selectCountFrom(String tableName) {
   }
 
   /**
-   * 

* Creates AS alias. * - *

- * For example, + *

For example, * *

    * as("avg(score)", "avg_score")  returns "avg(score) as avg_score"
@@ -347,15 +323,16 @@ public static String castAs(String src, String toType) {
   }
 
   public static String columnWithTableName(String tableName, String... colNames) {
-    return wrapSpace(Arrays.stream(colNames).map(col -> column(tableName, col))
-        .collect(Collectors.joining(",")));
+    return wrapSpace(
+        Arrays.stream(colNames)
+            .map(col -> column(tableName, col))
+            .collect(Collectors.joining(",")));
   }
 
   public static String column(String tableName, String colName) {
     return wrapSpace(tableName + "." + colName);
   }
 
-
   public static String from(String tableName) {
     return wrapSpace("from " + tableName);
   }
@@ -372,7 +349,7 @@ public static String where(Condition searchCondition) {
     return where(searchCondition.toString());
   }
 
-  /** operator **/
+  /** operator * */
 
   /**
    * Creates a string of binary operator and operands which wrapped parentheses.
@@ -397,11 +374,9 @@ public static String op(Object left, String operator, Object right) {
   }
 
   /**
-   * 

* Creates {@link Condition} instance. * - *

- * For example, + *

For example, * *

    * and(cond("id=?"), "name=?")  returns "id=? and name=?"
@@ -418,17 +393,15 @@ public static Condition cond(String cond) {
    * @param operator
    * @param right
    */
-
   public static Condition cond(Object left, String operator, Object right) {
     return new Condition(left, operator, right);
   }
 
-  /** Conditions **/
+  /** Conditions * */
   /**
-   * 

* Creates AND condition with concatenating arguments. - *

- * For example, + * + *

For example, * *

    * and("id=?", "name=?") returns "id=? and name=?"
@@ -442,10 +415,9 @@ public static Condition and(Object... conds) {
   }
 
   /**
-   * 

* Creates OR condition with concatenating arguments. - *

- * For example, + * + *

For example, * *

    * or("id=?", "name=?") returns "id=? or name=?"
@@ -464,7 +436,6 @@ public static Condition in(Object colName, List values) {
     return new Condition(wrapSpace(colName + IN + wrapParentheses(literal(values))));
   }
 
-
   public static String groupBy(Object... groups) {
     return wrapSpace("group by " + joinCommaAndSpace(groups));
   }
@@ -495,8 +466,7 @@ public static String orderByDesc(Object column) {
     return orderBy(column, "desc");
   }
 
-  /** functions **/
-
+  /** functions * */
   public static String func(String functionName, Object args) {
     return wrapSpace(functionName + wrapParentheses(args));
   }
@@ -517,14 +487,12 @@ public static String avg(String column) {
     return func("avg", column);
   }
 
-
   /**
    * Converts the given arguments to SQL literal.
    *
    * @param element
    * @return
    */
-
   public static String literal(Object element) {
     if (element == null) {
       return "null";
@@ -536,8 +504,8 @@ public static String literal(Object element) {
       }
       return "array [" + String.join(", ", ret) + "]";
     } else if (element instanceof List) {
-      return String.join(", ",
-          ((List) element).stream().map(e -> literal(e)).toArray(String[]::new));
+      return String.join(
+          ", ", ((List) element).stream().map(e -> literal(e)).toArray(String[]::new));
     }
 
     final String str = element.toString();
@@ -575,8 +543,8 @@ public static String joinSpace(Object... elements) {
   }
 
   public static String joinObjects(String delimiter, Object... elements) {
-    return String.join(delimiter,
-        Arrays.stream(elements).map(o -> o.toString()).toArray(String[]::new));
+    return String.join(
+        delimiter, Arrays.stream(elements).map(o -> o.toString()).toArray(String[]::new));
   }
 
   public static String wrapParentheses(Object str) {
@@ -596,6 +564,4 @@ public static String wrapSingleQuote(Object str) {
   public static String wrapSpace(Object str) {
     return " " + (str == null ? "null" : str.toString().trim()) + " ";
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/SqlKeyword.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/SqlKeyword.java
index e89f11bd..9c90ce24 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/SqlKeyword.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/sql/SqlKeyword.java
@@ -7,7 +7,7 @@
  *
  * @author nkjm
  * @see SQL reserved words -
- *      Wikipedia
+ *     Wikipedia
  */
 @Experimental
 public interface SqlKeyword {
@@ -87,8 +87,9 @@ public interface SqlKeyword {
   public static final String IS_NULL = wrapSpace("is null");
   public static final String IS_NOT_NULL = wrapSpace("is not null");
 
-  /** Data type **/
+  /** Data type * */
   public static final String ARRAY = wrapSpace("array");
+
   public static final String BIGINT = wrapSpace("bigint");
   public static final String BOOLEAN = wrapSpace("boolean");
   public static final String CHAR = wrapSpace("char");
@@ -108,10 +109,10 @@ public interface SqlKeyword {
   public static final String NOT_NULL = wrapSpace("not null");
   public static final String PRIMARY_KEY = wrapSpace("primary key");
 
-  /** util **/
+  /** util * */
   public static final String STAR = wrapSpace("*");
-  public static final String SELECT_STAR = wrapSpace("select *");
 
+  public static final String SELECT_STAR = wrapSpace("select *");
 
   public static String chars(int num) {
     return wrapSpace("char(" + num + ")");
@@ -125,10 +126,7 @@ public static String decimal(int precision, int scale) {
     return wrapSpace("decimal(" + precision + "," + scale + ")");
   }
 
-
   private static String wrapSpace(String str) {
     return " " + (str == null ? "null" : str.toString()) + " ";
   }
-
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/BasicTableWithDefinition.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/BasicTableWithDefinition.java
index eb71650d..7c2142f0 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/BasicTableWithDefinition.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/BasicTableWithDefinition.java
@@ -29,5 +29,4 @@ public BasicTableWithDefinition(Sorm sorm, Class valueType) {
   public TableDefinition getTableDefinition() {
     return tableDefinition;
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableDefinition.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableDefinition.java
index d127828c..217d3c31 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableDefinition.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableDefinition.java
@@ -43,7 +43,6 @@
  *
  * @see {@link TableMetaData}
  * @author nkjm
- *
  */
 @Experimental
 public final class TableDefinition {
@@ -57,36 +56,38 @@ public static TableDefinition.Builder builder(String tableName) {
     return new TableDefinition.Builder(tableName);
   }
 
-
   public static TableDefinition.Builder builder(Class ormRecordClass) {
 
     Builder builder = TableDefinition.builder(toTableName(ormRecordClass));
 
-    Optional.ofNullable(ormRecordClass.getAnnotation(PrimaryKeyColumns.class)).map(a -> a.value())
+    Optional.ofNullable(ormRecordClass.getAnnotation(PrimaryKeyColumns.class))
+        .map(a -> a.value())
         .ifPresent(val -> builder.setPrimaryKey(val));
 
     Optional.ofNullable(ormRecordClass.getAnnotationsByType(IndexColumns.class))
         .ifPresent(vals -> Arrays.stream(vals).forEach(v -> builder.addIndexDefinition(v.value())));
 
-    Optional.ofNullable(ormRecordClass.getAnnotationsByType(UniqueColumns.class)).ifPresent(
-        vals -> Arrays.stream(vals).forEach(v -> builder.addUniqueConstraint(v.value())));
+    Optional.ofNullable(ormRecordClass.getAnnotationsByType(UniqueColumns.class))
+        .ifPresent(
+            vals -> Arrays.stream(vals).forEach(v -> builder.addUniqueConstraint(v.value())));
 
     Optional.ofNullable(ormRecordClass.getAnnotationsByType(CheckConstraint.class))
         .ifPresent(vals -> Arrays.stream(vals).forEach(v -> builder.addCheckConstraint(v.value())));
 
+    Annotation[][] parameterAnnotationsOfConstructor =
+        getCanonicalConstructor(ormRecordClass)
+            .map(constructor -> constructor.getParameterAnnotations())
+            .orElse(null);
 
-    Annotation[][] parameterAnnotationsOfConstructor = getCanonicalConstructor(ormRecordClass)
-        .map(constructor -> constructor.getParameterAnnotations()).orElse(null);
-
-    Field[] fields = Stream.of(ormRecordClass.getDeclaredFields())
-        .filter(f -> !Modifier.isStatic(f.getModifiers())).toArray(Field[]::new);
-
+    Field[] fields =
+        Stream.of(ormRecordClass.getDeclaredFields())
+            .filter(f -> !Modifier.isStatic(f.getModifiers()))
+            .toArray(Field[]::new);
 
     for (int i = 0; i < fields.length; i++) {
       Field field = fields[i];
       List opt = new ArrayList<>();
 
-
       Set anns = new LinkedHashSet<>();
       Arrays.stream(field.getAnnotations()).forEach(a -> anns.add(a));
 
@@ -95,7 +96,8 @@ public static TableDefinition.Builder builder(Class ormRecordClass) {
       }
 
       opt.add(
-          anns.stream().filter(ann -> ann instanceof OrmJsonColumnContainer).count() > 0 ? "json"
+          anns.stream().filter(ann -> ann instanceof OrmJsonColumnContainer).count() > 0
+              ? "json"
               : TableDefinition.toSqlDataType(field.getType()));
 
       for (Annotation ann : anns) {
@@ -114,14 +116,12 @@ public static TableDefinition.Builder builder(Class ormRecordClass) {
         } else if (ann instanceof Default) {
           opt.add("default " + ((Default) ann).value());
         }
-
       }
       builder.addColumnDefinition(toUpperSnakeCase(field.getName()), opt.toArray(String[]::new));
     }
     return builder;
   }
 
-
   public static String toTableName(Class ormRecordClass) {
     OrmTable ann = ormRecordClass.getAnnotation(OrmTable.class);
     if (ann == null || ann.value().length() == 0) {
@@ -133,9 +133,11 @@ public static String toTableName(Class ormRecordClass) {
 
   public static Optional> getCanonicalConstructor(Class recordClass) {
     try {
-      Class[] componentTypes = Arrays.stream(recordClass.getDeclaredFields())
-          .filter(f -> !java.lang.reflect.Modifier.isStatic(f.getModifiers())).map(f -> f.getType())
-          .toArray(Class[]::new);
+      Class[] componentTypes =
+          Arrays.stream(recordClass.getDeclaredFields())
+              .filter(f -> !java.lang.reflect.Modifier.isStatic(f.getModifiers()))
+              .map(f -> f.getType())
+              .toArray(Class[]::new);
       return Optional.of(recordClass.getDeclaredConstructor(componentTypes));
     } catch (NoSuchMethodException | SecurityException e) {
       return Optional.empty();
@@ -153,9 +155,13 @@ public static Optional> getCanonicalConstructor(Class recordCl
 
   private final List createIndexStatements;
 
-
-  private TableDefinition(String tableName, String tableSchema, List columnNames,
-      String createTableStatement, String dropTableStatement, List createIndexStatements) {
+  private TableDefinition(
+      String tableName,
+      String tableSchema,
+      List columnNames,
+      String createTableStatement,
+      String dropTableStatement,
+      List createIndexStatements) {
     this.tableName = tableName;
     this.tableNameAndColumnDefinitions = tableSchema;
     this.columnNames = Collections.unmodifiableList(columnNames);
@@ -166,10 +172,19 @@ private TableDefinition(String tableName, String tableSchema, List colum
 
   @Override
   public String toString() {
-    return "TableDefinition [tableName=" + tableName + ", tableNameAndColumnDefinitions="
-        + tableNameAndColumnDefinitions + ", columnNames=" + columnNames + ", createTableStatement="
-        + createTableStatement + ", dropTableStatement=" + dropTableStatement
-        + ", createIndexStatements=" + createIndexStatements + "]";
+    return "TableDefinition [tableName="
+        + tableName
+        + ", tableNameAndColumnDefinitions="
+        + tableNameAndColumnDefinitions
+        + ", columnNames="
+        + columnNames
+        + ", createTableStatement="
+        + createTableStatement
+        + ", dropTableStatement="
+        + dropTableStatement
+        + ", createIndexStatements="
+        + createIndexStatements
+        + "]";
   }
 
   public TableDefinition createIndexesIfNotExists(Orm orm) {
@@ -191,7 +206,6 @@ public void dropTableIfExistsCascade(Sorm orm) {
     orm.executeUpdate(getDropTableIfExistsStatement() + " cascade");
   }
 
-
   public List getColumnNames() {
     return columnNames;
   }
@@ -267,46 +281,78 @@ public String getTableNameAndColumnDefinitions() {
 
   public static class Builder {
     private static String createPrimaryKeyConstraint(String[] primaryKeys) {
-      return (primaryKeys == null || primaryKeys.length == 0) ? ""
+      return (primaryKeys == null || primaryKeys.length == 0)
+          ? ""
           : ", primary key" + "(" + join(", ", primaryKeys) + ")";
     }
 
     private static String createUniqueConstraint(List uniqueColumnPairs) {
-      return (uniqueColumnPairs == null || uniqueColumnPairs.size() == 0) ? ""
-          : ", " + String.join(", ", uniqueColumnPairs.stream()
-              .map(u -> "unique" + "(" + join(", ", u) + ")").toArray(String[]::new));
+      return (uniqueColumnPairs == null || uniqueColumnPairs.size() == 0)
+          ? ""
+          : ", "
+              + String.join(
+                  ", ",
+                  uniqueColumnPairs.stream()
+                      .map(u -> "unique" + "(" + join(", ", u) + ")")
+                      .toArray(String[]::new));
     }
 
     private static String createCheckConstraint(List checkConditions) {
-      return (checkConditions == null || checkConditions.size() == 0) ? ""
-          : ", " + String.join(", ",
-              checkConditions.stream().map(u -> "check" + "(" + u + ")").toArray(String[]::new));
+      return (checkConditions == null || checkConditions.size() == 0)
+          ? ""
+          : ", "
+              + String.join(
+                  ", ",
+                  checkConditions.stream()
+                      .map(u -> "check" + "(" + u + ")")
+                      .toArray(String[]::new));
     }
 
     private static List getColumunNames(Map columnDefinitions) {
-      return columnDefinitions.entrySet().stream().map(e -> e.getKey())
+      return columnDefinitions.entrySet().stream()
+          .map(e -> e.getKey())
           .collect(Collectors.toList());
     }
 
     private static List getColumuns(Map columnDefinisions) {
       return columnDefinisions.keySet().stream()
-          .map(columnName -> columnName + " "
-              + join(" ", Arrays.stream(columnDefinisions.get(columnName)).map(s -> s.trim())
-                  .collect(Collectors.toList())))
+          .map(
+              columnName ->
+                  columnName
+                      + " "
+                      + join(
+                          " ",
+                          Arrays.stream(columnDefinisions.get(columnName))
+                              .map(s -> s.trim())
+                              .collect(Collectors.toList())))
           .collect(Collectors.toList());
     }
 
-    private static String getCreateIndexOnStatement(String indexName, String tableName,
-        String... columns) {
-      return "create index if not exists " + indexName + " on " + tableName + "("
-          + String.join(", ", columns) + ")";
+    private static String getCreateIndexOnStatement(
+        String indexName, String tableName, String... columns) {
+      return "create index if not exists "
+          + indexName
+          + " on "
+          + tableName
+          + "("
+          + String.join(", ", columns)
+          + ")";
     }
 
-    private static String getTableSchema(String tableName, Map columns,
-        String[] primaryKeys, List uniqueColumnPairs, List checkConditions) {
-      String schema = tableName + "(" + join(", ", getColumuns(columns))
-          + createPrimaryKeyConstraint(primaryKeys) + createUniqueConstraint(uniqueColumnPairs)
-          + createCheckConstraint(checkConditions) + ")";
+    private static String getTableSchema(
+        String tableName,
+        Map columns,
+        String[] primaryKeys,
+        List uniqueColumnPairs,
+        List checkConditions) {
+      String schema =
+          tableName
+              + "("
+              + join(", ", getColumuns(columns))
+              + createPrimaryKeyConstraint(primaryKeys)
+              + createUniqueConstraint(uniqueColumnPairs)
+              + createCheckConstraint(checkConditions)
+              + ")";
       return schema;
     }
 
@@ -322,13 +368,10 @@ private static String[] toStringArray(Enum[] enums) {
 
     private final List uniqueColumnPairs;
 
-
     private final List indexColumns;
 
     private final List checkConditions;
 
-
-
     private Builder(String tableName) {
       this.columnDefinitions = new LinkedHashMap<>();
       this.uniqueColumnPairs = new ArrayList<>();
@@ -351,8 +394,7 @@ public Builder addColumnDefinition(Enum columnName, String... dataTypeAndOpti
     /**
      * Adds an column definition.
      *
-     * 

- * For example, + *

For example, * *

      * addUniqueConstraint("id","name")  converted to "UNIQUE (id, name)"
@@ -377,7 +419,6 @@ public Builder addIndexDefinition(Enum... indexColumnPair) {
       return this;
     }
 
-
     /**
      * Adds a column pair for an index key. The name of index is automatically generated.
      *
@@ -406,8 +447,7 @@ public Builder addUniqueConstraint(Enum... uniqueColumnPair) {
     /**
      * Adds an unique constraint.
      *
-     * 

- * For example, + *

For example, * *

      * addUniqueConstraint("id","name")  converted to "UNIQUE (id, name)"
@@ -425,7 +465,6 @@ public Builder addCheckConstraint(String... checkConditions) {
       return this;
     }
 
-
     /**
      * Builds a {@link TableDefinition}.
      *
@@ -433,15 +472,21 @@ public Builder addCheckConstraint(String... checkConditions) {
      */
     public TableDefinition build() {
       if (columnDefinitions.isEmpty()) {
-        return new TableDefinition(tableName, "", Collections.emptyList(), "", "",
-            Collections.emptyList());
+        return new TableDefinition(
+            tableName, "", Collections.emptyList(), "", "", Collections.emptyList());
       } else {
-        String tableSchema = getTableSchema(tableName, columnDefinitions, primaryKeys,
-            uniqueColumnPairs, checkConditions);
+        String tableSchema =
+            getTableSchema(
+                tableName, columnDefinitions, primaryKeys, uniqueColumnPairs, checkConditions);
         String createTableStatement = "create table if not exists " + tableSchema;
         String dropTableStatement = "drop table if exists " + tableName;
-        return new TableDefinition(tableName, tableSchema, getColumunNames(), createTableStatement,
-            dropTableStatement, getCreateIndexIfNotExistsStatements());
+        return new TableDefinition(
+            tableName,
+            tableSchema,
+            getColumunNames(),
+            createTableStatement,
+            dropTableStatement,
+            getCreateIndexIfNotExistsStatements());
       }
     }
 
@@ -451,12 +496,13 @@ private List getColumunNames() {
 
     private List getCreateIndexIfNotExistsStatements() {
       return indexColumns.stream()
-          .map(columns -> getCreateIndexOnStatement(
-              "index_in_" + tableName + "_on_" + join("_", columns), tableName, columns))
+          .map(
+              columns ->
+                  getCreateIndexOnStatement(
+                      "index_in_" + tableName + "_on_" + join("_", columns), tableName, columns))
           .collect(Collectors.toList());
     }
 
-
     public Builder setPrimaryKey(Enum... attributes) {
       setPrimaryKey(toStringArray(attributes));
       return this;
@@ -465,8 +511,7 @@ public Builder setPrimaryKey(Enum... attributes) {
     /**
      * Sets attributes as primary key attributes.
      *
-     * 

- * For example, + *

For example, * *

      * setPrimaryKey("id","name")  converted to "PRIMARY KEY (id, name)"
@@ -491,18 +536,15 @@ public Builder setTableName(String tableName) {
     }
   }
 
-
   public static String toSqlDataType(Class type) {
     if (type.getAnnotation(OrmJsonColumnContainer.class) != null) {
       return "json";
-
     }
-    if (ArrayUtils.getInternalComponentType(type)
-        .getAnnotation(OrmJsonColumnContainer.class) != null) {
+    if (ArrayUtils.getInternalComponentType(type).getAnnotation(OrmJsonColumnContainer.class)
+        != null) {
       return "json";
     }
 
-
     switch (type.getName()) {
       case "int":
       case "java.lang.Integer":
@@ -571,5 +613,4 @@ public static String toSqlDataType(Class type) {
         }
     }
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableWithDefinition.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableWithDefinition.java
index 00438f5d..c952427e 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableWithDefinition.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableWithDefinition.java
@@ -13,7 +13,6 @@ public interface TableWithDefinition extends Table {
    */
   TableDefinition getTableDefinition();
 
-
   default TableWithDefinition createTableIfNotExists() {
     getTableDefinition().createTableIfNotExists(getOrm());
     return this;
@@ -38,5 +37,4 @@ default TableWithDefinition dropTableIfExistsCascade() {
   default String getTableName() {
     return getTableDefinition().getTableName();
   }
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/AutoIncrement.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/AutoIncrement.java
index f9fd88c9..b2b55279 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/AutoIncrement.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/AutoIncrement.java
@@ -7,6 +7,4 @@
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.PARAMETER, ElementType.FIELD})
-public @interface AutoIncrement {
-
-}
+public @interface AutoIncrement {}
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/CheckConstraint.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/CheckConstraint.java
index 08e4a25e..a53f5930 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/CheckConstraint.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/CheckConstraint.java
@@ -5,16 +5,11 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-/**
- * Defines indexes.
- */
+/** Defines indexes. */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
 public @interface CheckConstraint {
 
-  /**
-   * Name of the index
-   */
+  /** Name of the index */
   String value();
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/Index.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/Index.java
index 6b0d8e2d..869d9514 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/Index.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/Index.java
@@ -7,6 +7,4 @@
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.PARAMETER, ElementType.FIELD})
-public @interface Index {
-
-}
+public @interface Index {}
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/IndexColumns.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/IndexColumns.java
index d31e5473..d9753470 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/IndexColumns.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/IndexColumns.java
@@ -6,17 +6,12 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-/**
- * Defines index pair.
- */
+/** Defines index pair. */
 @Repeatable(RepeatableIndexColumns.class)
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
 public @interface IndexColumns {
 
-  /**
-   * Name of the index
-   */
+  /** Name of the index */
   String[] value();
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/NotNull.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/NotNull.java
index dad96925..f4181e9a 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/NotNull.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/NotNull.java
@@ -7,6 +7,4 @@
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.PARAMETER, ElementType.FIELD})
-public @interface NotNull {
-
-}
+public @interface NotNull {}
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/PrimaryKey.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/PrimaryKey.java
index 9509c01b..709a9c06 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/PrimaryKey.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/PrimaryKey.java
@@ -7,6 +7,4 @@
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.PARAMETER, ElementType.FIELD})
-public @interface PrimaryKey {
-
-}
+public @interface PrimaryKey {}
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/PrimaryKeyColumns.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/PrimaryKeyColumns.java
index 64148b91..f97fc8a8 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/PrimaryKeyColumns.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/PrimaryKeyColumns.java
@@ -9,5 +9,4 @@
 @Target(ElementType.TYPE)
 public @interface PrimaryKeyColumns {
   String[] value();
-
 }
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/Unique.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/Unique.java
index a249e385..fd5c3484 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/Unique.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/Unique.java
@@ -7,6 +7,4 @@
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.PARAMETER, ElementType.FIELD})
-public @interface Unique {
-
-}
+public @interface Unique {}
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/UniqueColumns.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/UniqueColumns.java
index bb85ebd8..4f9fe5b6 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/UniqueColumns.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/annotation/UniqueColumns.java
@@ -11,5 +11,4 @@
 @Target(ElementType.TYPE)
 public @interface UniqueColumns {
   String[] value();
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/common/ColumnMetaDataTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/common/ColumnMetaDataTest.java
index 2b626081..9fc61404 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/common/ColumnMetaDataTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/common/ColumnMetaDataTest.java
@@ -28,15 +28,13 @@ void testCompareTo() {
     // c1 and c4 are diffrent
     assertThat(c1.equals(c4)).isFalse();
 
-
     // c1 and c3 are different
     assertThat(c1.equals(c3)).isFalse();
     assertThat(c1.compareTo(c3)).isLessThan(0);
 
-
-    assertThat(new ColumnMetaData("a", 0, "b", 0, "c", "d", "e")
-        .equals(new ColumnMetaData("a", 0, "b", 0, "c", "d", "e"))).isTrue();
-
+    assertThat(
+            new ColumnMetaData("a", 0, "b", 0, "c", "d", "e")
+                .equals(new ColumnMetaData("a", 0, "b", 0, "c", "d", "e")))
+        .isTrue();
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/common/TupleTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/common/TupleTest.java
index 4aede74d..11e9c893 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/common/TupleTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/common/TupleTest.java
@@ -37,5 +37,4 @@ void testOfT3() {
     assertThat(t1.hashCode()).isEqualTo(t2.hashCode());
     assertThat(t1.toString()).isEqualTo("(t1, t2, t3)");
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToJavaObjectConvertersTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToJavaObjectConvertersTest.java
index 78840fbe..95455041 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToJavaObjectConvertersTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultColumnValueToJavaObjectConvertersTest.java
@@ -15,54 +15,59 @@ class DefaultColumnValueToJavaObjectConvertersTest {
 
   @Test
   void testConvertTo() {
-    ColumnValueToJavaObjectConverter columnValueConverter = new ColumnValueToJavaObjectConverter() {
-
-      @Override
-      public boolean test(Class toType) {
-        return toType.equals(String.class);
-      }
-
-      @Override
-      public Object convertTo(ResultSet resultSet, int columnIndex, int columnType, Class toType)
-          throws SQLException {
-        return resultSet.getString(columnIndex).toString();
-
-      }
-
-    };
-
-    SqlParameterSetter parameterSetter = new SqlParameterSetter() {
-
-      @Override
-      public boolean test(PreparedStatement stmt, int parameterIndex, Object parameter)
-          throws SQLException {
-        return parameter.getClass().equals(java.net.Inet4Address.class);
-      }
-
-      @Override
-      public void setParameter(PreparedStatement stmt, int parameterIndex, Object parameter)
-          throws SQLException {
-        stmt.setString(parameterIndex, parameter.toString());
-      }
-    };
-    PreparedStatementSupplier supplier = new PreparedStatementSupplier() {
-      @Override
-      public PreparedStatement prepareStatement(Connection connection, String sql,
-          String[] autoGeneratedColumnsArray) throws SQLException {
-        return connection.prepareStatement(sql, autoGeneratedColumnsArray);
-      }
-
-      @Override
-      public PreparedStatement prepareStatement(Connection connection, String sql)
-          throws SQLException {
-        return connection.prepareStatement(sql);
-      }
-    };
-    SormContext context = SormContext.builder()
-        .setColumnValueToJavaObjectConverters(
-            new DefaultColumnValueToJavaObjectConverters(columnValueConverter))
-        .setSqlParametersSetter(new DefaultSqlParametersSetter(parameterSetter))
-        .setPreparedStatementSupplier(supplier).build();
+    ColumnValueToJavaObjectConverter columnValueConverter =
+        new ColumnValueToJavaObjectConverter() {
+
+          @Override
+          public boolean test(Class toType) {
+            return toType.equals(String.class);
+          }
+
+          @Override
+          public Object convertTo(
+              ResultSet resultSet, int columnIndex, int columnType, Class toType)
+              throws SQLException {
+            return resultSet.getString(columnIndex).toString();
+          }
+        };
+
+    SqlParameterSetter parameterSetter =
+        new SqlParameterSetter() {
+
+          @Override
+          public boolean test(PreparedStatement stmt, int parameterIndex, Object parameter)
+              throws SQLException {
+            return parameter.getClass().equals(java.net.Inet4Address.class);
+          }
+
+          @Override
+          public void setParameter(PreparedStatement stmt, int parameterIndex, Object parameter)
+              throws SQLException {
+            stmt.setString(parameterIndex, parameter.toString());
+          }
+        };
+    PreparedStatementSupplier supplier =
+        new PreparedStatementSupplier() {
+          @Override
+          public PreparedStatement prepareStatement(
+              Connection connection, String sql, String[] autoGeneratedColumnsArray)
+              throws SQLException {
+            return connection.prepareStatement(sql, autoGeneratedColumnsArray);
+          }
+
+          @Override
+          public PreparedStatement prepareStatement(Connection connection, String sql)
+              throws SQLException {
+            return connection.prepareStatement(sql);
+          }
+        };
+    SormContext context =
+        SormContext.builder()
+            .setColumnValueToJavaObjectConverters(
+                new DefaultColumnValueToJavaObjectConverters(columnValueConverter))
+            .setSqlParametersSetter(new DefaultSqlParametersSetter(parameterSetter))
+            .setPreparedStatementSupplier(supplier)
+            .build();
 
     Sorm sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables(context);
 
@@ -74,8 +79,5 @@ public PreparedStatement prepareStatement(Connection connection, String sql)
     } catch (Exception e) {
       fail();
     }
-
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetterTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetterTest.java
index 9428f3fc..0d198a9f 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetterTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetterTest.java
@@ -58,7 +58,6 @@ void testArray() {
       assertThat(toSqlArray("java.lang.Long", conn, TestUtils.LONG_ARRAY).getBaseType())
           .isEqualTo(JDBCType.BIGINT.getVendorTypeNumber());
 
-
       assertThat(toSqlArray("float", conn, TestUtils.PRIMITIVE_FLOAT_ARRAY).getBaseType())
           .isEqualTo(JDBCType.REAL.getVendorTypeNumber());
 
@@ -71,14 +70,12 @@ void testArray() {
       assertThat(toSqlArray("java.lang.Double", conn, TestUtils.DOUBLE_ARRAY).getBaseType())
           .isEqualTo(JDBCType.DOUBLE.getVendorTypeNumber());
 
-
       assertThat(toSqlArray("java.lang.String", conn, TestUtils.STRING_ARRAY).getBaseType())
           .isEqualTo(JDBCType.VARCHAR.getVendorTypeNumber());
 
       assertThat(
-          toSqlArray("java.math.BigDecimal", conn, TestUtils.BIG_DECIMAL_ARRAY).getBaseType())
-              .isEqualTo(JDBCType.NUMERIC.getVendorTypeNumber());
-
+              toSqlArray("java.math.BigDecimal", conn, TestUtils.BIG_DECIMAL_ARRAY).getBaseType())
+          .isEqualTo(JDBCType.NUMERIC.getVendorTypeNumber());
 
       assertThat(toSqlArray("java.sql.Date", conn, TestUtils.DATE_ARRAY).getBaseType())
           .isEqualTo(JDBCType.DATE.getVendorTypeNumber());
@@ -94,11 +91,13 @@ void testArray() {
           .isEqualTo(JDBCType.TIMESTAMP_WITH_TIMEZONE.getVendorTypeNumber());
 
       assertThat(
-          toSqlArray("java.time.OffsetTime", conn, TestUtils.OFFSET_TIME_ARRAY).getBaseType())
-              .isEqualTo(JDBCType.TIME_WITH_TIMEZONE.getVendorTypeNumber());
+              toSqlArray("java.time.OffsetTime", conn, TestUtils.OFFSET_TIME_ARRAY).getBaseType())
+          .isEqualTo(JDBCType.TIME_WITH_TIMEZONE.getVendorTypeNumber());
 
-      assertThat(toSqlArray("java.time.OffsetDateTime", conn, TestUtils.OFFSET_DATE_TIME_ARRAY)
-          .getBaseType()).isEqualTo(JDBCType.TIMESTAMP_WITH_TIMEZONE.getVendorTypeNumber());
+      assertThat(
+              toSqlArray("java.time.OffsetDateTime", conn, TestUtils.OFFSET_DATE_TIME_ARRAY)
+                  .getBaseType())
+          .isEqualTo(JDBCType.TIMESTAMP_WITH_TIMEZONE.getVendorTypeNumber());
 
       assertThat(toSqlArray("java.time.LocalDate", conn, TestUtils.LOCAL_DATE_ARRAY).getBaseType())
           .isEqualTo(JDBCType.DATE.getVendorTypeNumber());
@@ -106,14 +105,14 @@ void testArray() {
       assertThat(toSqlArray("java.time.LocalTime", conn, TestUtils.LOCAL_TIME_ARRAY).getBaseType())
           .isEqualTo(JDBCType.TIME.getVendorTypeNumber());
 
-      assertThat(toSqlArray("java.time.LocalDateTime", conn, TestUtils.LOCAL_DATE_TIME_ARRAY)
-          .getBaseType()).isEqualTo(JDBCType.TIMESTAMP.getVendorTypeNumber());
-
+      assertThat(
+              toSqlArray("java.time.LocalDateTime", conn, TestUtils.LOCAL_DATE_TIME_ARRAY)
+                  .getBaseType())
+          .isEqualTo(JDBCType.TIMESTAMP.getVendorTypeNumber());
 
       assertThat(toSqlArray("java.lang.Object", conn, TestUtils.OBJECT_ARRAY).getBaseType())
           .isEqualTo(JDBCType.JAVA_OBJECT.getVendorTypeNumber());
 
-
     } catch (SQLException e) {
       throw Try.rethrow(e);
     }
@@ -127,8 +126,8 @@ void testSetParameters() {
         "CREATE TABLE TA (id int auto_increment primary key, arry " + "INTEGER" + " ARRAY[10])");
 
     sorm.readFirst(RowMap.class, "select * from TA where arry=?", new boolean[] {true, false});
-    sorm.readFirst(RowMap.class, "select * from TA where arry=?",
-        (Object) new Boolean[] {true, false});
+    sorm.readFirst(
+        RowMap.class, "select * from TA where arry=?", (Object) new Boolean[] {true, false});
     sorm.readFirst(RowMap.class, "select * from TA where arry=?", new double[] {0.1d});
     sorm.readFirst(RowMap.class, "select * from TA where arry=?", (Object) new Double[] {0.1d});
 
@@ -140,8 +139,8 @@ void testSetParameters() {
       setter.setParameters(pstmt, new Object[] {});
 
       setter.setParameters(pstmt, Instant.now());
-      setter.setParameters(pstmt,
-          DefaultSqlParametersSetterTest.class.getResourceAsStream("log4j2.xml"));
+      setter.setParameters(
+          pstmt, DefaultSqlParametersSetterTest.class.getResourceAsStream("log4j2.xml"));
       setter.setParameters(pstmt, new StringReader("a"));
 
     } catch (SQLException e) {
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultTableNameMapperTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultTableNameMapperTest.java
index 639ab946..91af3916 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultTableNameMapperTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultTableNameMapperTest.java
@@ -17,20 +17,21 @@ static void setUp() {
     sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables();
   }
 
-
   @Test
   void testToValidTableName() {
-    sorm.acceptHandler(m -> {
-      assertThat(
-          new DefaultTableNameMapper().getTableName("guests", m.getJdbcConnection().getMetaData()))
+    sorm.acceptHandler(
+        m -> {
+          assertThat(
+                  new DefaultTableNameMapper()
+                      .getTableName("guests", m.getJdbcConnection().getMetaData()))
               .isEqualTo("GUESTS");
-
-    });
+        });
     try {
-      sorm.acceptHandler(m -> {
-        new DefaultTableNameMapper().getTableName("aaa", m.getJdbcConnection().getMetaData());
-        failBecauseExceptionWasNotThrown(Exception.class);
-      });
+      sorm.acceptHandler(
+          m -> {
+            new DefaultTableNameMapper().getTableName("aaa", m.getJdbcConnection().getMetaData());
+            failBecauseExceptionWasNotThrown(Exception.class);
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("does not match any existing table");
     }
@@ -38,12 +39,12 @@ void testToValidTableName() {
 
   @Test
   void testGetTableName() {
-    sorm.acceptHandler(m -> {
-      String name = new DefaultTableNameMapper().getTableName(Guest.class,
-          m.getJdbcConnection().getMetaData());
-      assertThat(name).isEqualTo(new TableName("GUESTS").getName());
-    });
+    sorm.acceptHandler(
+        m -> {
+          String name =
+              new DefaultTableNameMapper()
+                  .getTableName(Guest.class, m.getJdbcConnection().getMetaData());
+          assertThat(name).isEqualTo(new TableName("GUESTS").getName());
+        });
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/FieldAccessorTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/FieldAccessorTest.java
index 3a1cadea..794c2152 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/FieldAccessorTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/FieldAccessorTest.java
@@ -9,11 +9,13 @@ class FieldAccessorTest {
   @Test
   void testAccessor() {
     FieldAccessor ac = new FieldAccessor(null, null, null, null);
-    assertThatThrownBy(() -> ac.get("foo")).isInstanceOfSatisfying(SormException.class,
-        e -> assertThat(e.getMessage()).isEqualTo("No valid getter for foo"));
-    assertThatThrownBy(() -> ac.set("foo", null)).isInstanceOfSatisfying(SormException.class,
-        e -> assertThat(e.getMessage()).isEqualTo("No valid setter for foo"));
-
+    assertThatThrownBy(() -> ac.get("foo"))
+        .isInstanceOfSatisfying(
+            SormException.class,
+            e -> assertThat(e.getMessage()).isEqualTo("No valid getter for foo"));
+    assertThatThrownBy(() -> ac.set("foo", null))
+        .isInstanceOfSatisfying(
+            SormException.class,
+            e -> assertThat(e.getMessage()).isEqualTo("No valid setter for foo"));
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/ResultSetMapperTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/ResultSetMapperTest.java
index 32ca2b1c..3f1b9ce2 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/ResultSetMapperTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/ResultSetMapperTest.java
@@ -20,18 +20,24 @@ void setUp() {
     sorm.acceptHandler(conn -> conn.insert(PLAYER_ALICE, PLAYER_BOB));
   }
 
-
   @Test
   void testMapRowsClassOfTResultSet() {
-    sorm.applyHandler(conn -> conn.executeQuery(ParameterizedSql.of("select * from players"),
-        conn.getResultSetTraverser(Player.class)));
+    sorm.applyHandler(
+        conn ->
+            conn.executeQuery(
+                ParameterizedSql.of("select * from players"),
+                conn.getResultSetTraverser(Player.class)));
   }
 
   @Test
   void testMapRowsResultSet() {
     assertThat(
-        sorm.applyHandler(conn -> conn.executeQuery(ParameterizedSql.of("select * from players"),
-            conn.getResultSetTraverser(RowMap.class))).size()).isEqualTo(2);
+            sorm.applyHandler(
+                    conn ->
+                        conn.executeQuery(
+                            ParameterizedSql.of("select * from players"),
+                            conn.getResultSetTraverser(RowMap.class)))
+                .size())
+        .isEqualTo(2);
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/engine/TestPostgreSQLSqlMapper.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/engine/TestPostgreSQLSqlMapper.java
index 3b8a1d8e..71afbb25 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/engine/TestPostgreSQLSqlMapper.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/engine/TestPostgreSQLSqlMapper.java
@@ -1,6 +1,5 @@
 package org.nkjmlab.sorm4j.engine;
 
-
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -55,63 +54,60 @@ public class TestPostgreSQLSqlMapper {
 
   @BeforeAll
   static void beforAll() {
-    dataSource = DbEngineTestUtils.getDataSource(TestPostgreSQLSqlMapper.class,
-        "jdbc:h2:mem:postgre;MODE=PostgreSQL");
+    dataSource =
+        DbEngineTestUtils.getDataSource(
+            TestPostgreSQLSqlMapper.class, "jdbc:h2:mem:postgre;MODE=PostgreSQL");
     DbEngineTestUtils.executeSql(dataSource, TestPostgreSQLSqlMapper.class, "sql-mapper-test.sql");
 
-
-
-    ColumnValueToJavaObjectConverter columnValueConverter = new ColumnValueToJavaObjectConverter() {
-
-      @Override
-      public boolean test(Class toType) {
-        return toType.equals(PGobject.class);
-      }
-
-      @Override
-      public Object convertTo(ResultSet resultSet, int columnIndex, int columnType, Class toType)
-          throws SQLException {
-        return PGobject.class.cast(resultSet.getObject(columnIndex));
-      }
-
-    };
-
-
-
-    SqlParameterSetter parameterSetter = new SqlParameterSetter() {
-
-      @Override
-      public boolean test(PreparedStatement stmt, int parameterIndex, Object parameter)
-          throws SQLException {
-        return parameter.getClass().equals(java.net.InetAddress.class);
-      }
-
-      @Override
-      public void setParameter(PreparedStatement stmt, int parameterIndex, Object parameter)
-          throws SQLException {
-        PGobject pg = new PGobject();
-        pg.setType("inet");
-        pg.setValue(((InetAddress) parameter).getHostAddress());
-        stmt.setObject(parameterIndex, pg);
-      }
-    };
-
-
-
-    context = SormContext.builder()
-        .setColumnValueToJavaObjectConverters(
-            new DefaultColumnValueToJavaObjectConverters(columnValueConverter))
-        .setSqlParametersSetter(new DefaultSqlParametersSetter(parameterSetter)).build();
-
+    ColumnValueToJavaObjectConverter columnValueConverter =
+        new ColumnValueToJavaObjectConverter() {
+
+          @Override
+          public boolean test(Class toType) {
+            return toType.equals(PGobject.class);
+          }
+
+          @Override
+          public Object convertTo(
+              ResultSet resultSet, int columnIndex, int columnType, Class toType)
+              throws SQLException {
+            return PGobject.class.cast(resultSet.getObject(columnIndex));
+          }
+        };
+
+    SqlParameterSetter parameterSetter =
+        new SqlParameterSetter() {
+
+          @Override
+          public boolean test(PreparedStatement stmt, int parameterIndex, Object parameter)
+              throws SQLException {
+            return parameter.getClass().equals(java.net.InetAddress.class);
+          }
+
+          @Override
+          public void setParameter(PreparedStatement stmt, int parameterIndex, Object parameter)
+              throws SQLException {
+            PGobject pg = new PGobject();
+            pg.setType("inet");
+            pg.setValue(((InetAddress) parameter).getHostAddress());
+            stmt.setObject(parameterIndex, pg);
+          }
+        };
+
+    context =
+        SormContext.builder()
+            .setColumnValueToJavaObjectConverters(
+                new DefaultColumnValueToJavaObjectConverters(columnValueConverter))
+            .setSqlParametersSetter(new DefaultSqlParametersSetter(parameterSetter))
+            .build();
   }
 
-
   /**
    * @see https://github.com/orangain/compare-sql-mappers/
-   *
    * @throws SQLException
    */
   private static final ZoneOffset JST_OFFSET = ZoneOffset.of("+09:00");
+
   private static final LocalDate LOCAL_DATE = LocalDate.of(2019, 9, 27);
   private static final LocalTime LOCAL_TIME = LocalTime.of(13, 23);
   private static final LocalDateTime LOCAL_DATE_TIME = LocalDateTime.of(LOCAL_DATE, LOCAL_TIME);
@@ -123,7 +119,7 @@ public void setParameter(PreparedStatement stmt, int parameterIndex, Object para
   @Test
   public void testMapTest() throws SQLException, MalformedURLException, UnknownHostException {
     try (Connection conn = dataSource.getConnection();
-        OrmConnection c = OrmConnection.of(conn, context);) {
+        OrmConnection c = OrmConnection.of(conn, context); ) {
 
       // log.debug(c.readFirst(RowMap.class, "select * from sql_mapper_test"));
       doTest(c, "c_boolean by boolean", "c_boolean", true);
@@ -135,10 +131,17 @@ public void testMapTest() throws SQLException, MalformedURLException, UnknownHos
       doTest(c, "testName", "c_varchar", "varchar");
       doTest(c, "testName", "c_text", "long long text");
       doTest(c, "testName", "c_text", new StringReader("long long text"));
-      doTest(c, "c_bytea by byte[]", "c_bytea",
+      doTest(
+          c,
+          "c_bytea by byte[]",
+          "c_bytea",
           new byte[] {(byte) 0xde, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF});
-      doTest(c, "c_bytea by byte[]", "c_bytea", new ByteArrayInputStream(
-          new byte[] {(byte) 0xde, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF}));
+      doTest(
+          c,
+          "c_bytea by byte[]",
+          "c_bytea",
+          new ByteArrayInputStream(
+              new byte[] {(byte) 0xde, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF}));
       doTest(c, "testName", "c_uuid", UUID.fromString("33ee757a-19b3-45dc-be79-f1d65ac5d1a4"));
       doTest(c, "testName", "c_date", LOCAL_DATE);
       doTest(c, "testName", "c_date", Date.valueOf(LOCAL_DATE));
@@ -161,14 +164,13 @@ public void testMapTest() throws SQLException, MalformedURLException, UnknownHos
       doTest(c, "c_varchar_array by String[]", "c_varchar_array", new String[] {"A", "B", "C"});
       // doTest(c, "c_varchar_array by List", "c_varchar_array", List.of("A", "B", "C"));
 
-
       log.debug("Array test --------");
       // doTestInClause(c, "c integer by List", "c_integer", List.of(1, 2, 3));
       doTestInClause(c, "c integer by Integer[]", "c_integer", new Integer[] {1, 2, 3});
       doTestInClause(c, "c integer by int[]", "c_integer", new int[] {1, 2, 3});
       // doTestInClause(c, "c_varchar by List", "c_varchar", List.of("integer", "varchar", "text"));
-      doTestInClause(c, "c_varchar by String[]", "c_varchar",
-          new String[] {"integer", "varchar", "text"});
+      doTestInClause(
+          c, "c_varchar by String[]", "c_varchar", new String[] {"integer", "varchar", "text"});
     }
   }
 
@@ -177,8 +179,8 @@ private void doTest(OrmConnection c, String testName, String column, Object para
     convertResultSetToJavaObjectTest(c, testName, column, param);
   }
 
-  private void convertResultSetToJavaObjectTest(OrmConnection c, String testName, String column,
-      Object param) {
+  private void convertResultSetToJavaObjectTest(
+      OrmConnection c, String testName, String column, Object param) {
     String messagePrefix = "map: " + column + "(" + param.getClass() + ") ";
     try {
       Class clazz = toClass(param.getClass());
@@ -186,8 +188,15 @@ private void convertResultSetToJavaObjectTest(OrmConnection c, String testName,
       if (equals(retFromDb, param)) {
         // log.debug("[" + testName + "] " + messagePrefix + "success ret =>" + retFromDb);
       } else {
-        log.error("[" + testName + "] " + messagePrefix + "fail ret => " + retFromDb + ", param => "
-            + param);
+        log.error(
+            "["
+                + testName
+                + "] "
+                + messagePrefix
+                + "fail ret => "
+                + retFromDb
+                + ", param => "
+                + param);
       }
     } catch (Exception e) {
       log.error("Exception [" + testName + "] " + messagePrefix + "fail => " + e.getMessage());
@@ -257,7 +266,9 @@ public static boolean equalsArray(Object arr1, Object arr2) {
     }
     if (!arr1.getClass().isArray() || !arr2.getClass().isArray()) {
       Object[] params = {arr1.getClass(), arr2.getClass()};
-      throw new IllegalArgumentException(ParameterizedStringFormatter.LENGTH_256.format("args should be array. arr1={}, arr2={}", params));
+      throw new IllegalArgumentException(
+          ParameterizedStringFormatter.LENGTH_256.format(
+              "args should be array. arr1={}, arr2={}", params));
     }
     int l1 = Array.getLength(arr1);
 
@@ -278,8 +289,11 @@ public static boolean equalsArray(Object arr1, Object arr2) {
   private void bindToSqlTest(OrmConnection c, String testName, String column, Object param) {
     String messagePrefix = "bind: " + column + "(" + param.getClass() + ") ";
     try {
-      Map ret = c.readFirst(RowMap.class,
-          "SELECT " + column + " FROM sql_mapper_test WHERE " + column + "=?", param);
+      Map ret =
+          c.readFirst(
+              RowMap.class,
+              "SELECT " + column + " FROM sql_mapper_test WHERE " + column + "=?",
+              param);
       if (ret != null) {
         // log.debug("[" + testName + "] " + messagePrefix + "success => " + ret);
       } else {
@@ -289,7 +303,6 @@ private void bindToSqlTest(OrmConnection c, String testName, String column, Obje
       log.error("[" + testName + "] " + messagePrefix + "fail => " + e.getMessage());
       // e.printStackTrace();
     }
-
   }
 
   private void doTestInClause(OrmConnection c, String testName, String column, Object param) {
@@ -299,9 +312,11 @@ private void doTestInClause(OrmConnection c, String testName, String column, Obj
   private void bindInClauseTest(OrmConnection c, String testName, String column, Object param) {
     String messagePrefix = "bindIn: " + column + "(" + param.getClass() + ") ";
     try {
-      ParameterizedSql statement = OrderedParameterSqlParser
-          .of("SELECT " + column + " FROM sql_mapper_test WHERE " + column + " in()")
-          .addParameter(param).parse();
+      ParameterizedSql statement =
+          OrderedParameterSqlParser.of(
+                  "SELECT " + column + " FROM sql_mapper_test WHERE " + column + " in()")
+              .addParameter(param)
+              .parse();
       Map ret = c.readFirst(RowMap.class, statement);
       if (ret != null) {
         // log.debug("[" + testName + "] " + messagePrefix + "success => " + ret);
@@ -312,7 +327,4 @@ private void bindInClauseTest(OrmConnection c, String testName, String column, O
       log.error("[" + testName + "] " + messagePrefix + "fail => " + e.getMessage());
     }
   }
-
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmConnectionImplTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmConnectionImplTest.java
index 87a9162a..269ef2aa 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmConnectionImplTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmConnectionImplTest.java
@@ -37,14 +37,15 @@ void setUp() {
 
   @Test
   void testDelete() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(PLAYER_ALICE);
-      assertThat(conn.exists(PLAYER_ALICE)).isTrue();
-      assertThat(conn.exists(PLAYER_BOB)).isFalse();
-      assertThat(conn.exists("players", PLAYER_ALICE)).isTrue();
-      assertThat(conn.exists("players", PLAYER_BOB)).isFalse();
-      conn.readFirst(Guest.class, "select * from players");
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(PLAYER_ALICE);
+          assertThat(conn.exists(PLAYER_ALICE)).isTrue();
+          assertThat(conn.exists(PLAYER_BOB)).isFalse();
+          assertThat(conn.exists("players", PLAYER_ALICE)).isTrue();
+          assertThat(conn.exists("players", PLAYER_BOB)).isFalse();
+          conn.readFirst(Guest.class, "select * from players");
+        });
   }
 
   @Test
@@ -61,8 +62,9 @@ void testJoin() {
     assertThat(result.get(0).getT2().getClass()).isEqualTo(Player.class);
     assertThat(result.get(0).toString()).contains("Alice");
 
-    List> result1 = sorm.joinOn(Guest.class, Player.class, Sport.class,
-        "guests.id=players.id", "players.id=sports.id");
+    List> result1 =
+        sorm.joinOn(
+            Guest.class, Player.class, Sport.class, "guests.id=players.id", "players.id=sports.id");
 
     assertThat(result1.get(0).getT1().getClass()).isEqualTo(Guest.class);
     assertThat(result1.get(0).getT1().getName()).isEqualTo(GUEST_ALICE.getName());
@@ -71,266 +73,301 @@ void testJoin() {
     assertThat(result1.get(0).getT3().getClass()).isEqualTo(Sport.class);
     assertThat(result1.get(0).getT3().getName()).isEqualTo(TENNIS.getName());
     assertThat(result1.get(0).toString()).contains("Alice");
-
   }
 
   @Test
   void testTupleList() {
-    sorm.acceptHandler(m -> {
-      m.insert(GUEST_ALICE, GUEST_BOB);
-      m.insert(PLAYER_ALICE, PLAYER_BOB);
-      m.insert(SormTestUtils.SOCCER);
-      m.insert(SormTestUtils.TENNIS);
-
-      List> result = m.readTupleList(Guest.class, Player.class,
-          "select g.id as gid, g.name as gname, g.address as gaddress, p.id as pid, p.name as pname, p.address as paddress from guests g join players p on g.id=p.id");
-
-      assertThat(result.get(0).getT1().getClass()).isEqualTo(Guest.class);
-      assertThat(result.get(0).getT2().getClass()).isEqualTo(Player.class);
-      assertThat(result.get(0).toString()).contains("Alice");
-
-      List> result1 =
-          m.readTupleList(Guest.class, Player.class, Sport.class,
-              "select g.id as gid, g.name as gname, g.address as gaddress, "
-                  + "p.id as pid, p.name as pname, p.address as paddress, "
-                  + "s.id sportdotid, s.name sportdotname " + "from guests g "
-                  + "join players p on g.id=p.id " + "join sports s on g.id=s.id");
-
-      assertThat(result1.get(0).getT1().getClass()).isEqualTo(Guest.class);
-      assertThat(result1.get(0).getT1().getName()).isEqualTo(GUEST_ALICE.getName());
-      assertThat(result1.get(0).getT2().getClass()).isEqualTo(Player.class);
-      assertThat(result1.get(0).getT2().getName()).isEqualTo(PLAYER_ALICE.getName());
-      assertThat(result1.get(0).getT3().getClass()).isEqualTo(Sport.class);
-      assertThat(result1.get(0).getT3().getName()).isEqualTo(TENNIS.getName());
-      assertThat(result1.get(0).toString()).contains("Alice");
-
-
-    });
+    sorm.acceptHandler(
+        m -> {
+          m.insert(GUEST_ALICE, GUEST_BOB);
+          m.insert(PLAYER_ALICE, PLAYER_BOB);
+          m.insert(SormTestUtils.SOCCER);
+          m.insert(SormTestUtils.TENNIS);
+
+          List> result =
+              m.readTupleList(
+                  Guest.class,
+                  Player.class,
+                  "select g.id as gid, g.name as gname, g.address as gaddress, p.id as pid, p.name as pname, p.address as paddress from guests g join players p on g.id=p.id");
+
+          assertThat(result.get(0).getT1().getClass()).isEqualTo(Guest.class);
+          assertThat(result.get(0).getT2().getClass()).isEqualTo(Player.class);
+          assertThat(result.get(0).toString()).contains("Alice");
+
+          List> result1 =
+              m.readTupleList(
+                  Guest.class,
+                  Player.class,
+                  Sport.class,
+                  "select g.id as gid, g.name as gname, g.address as gaddress, "
+                      + "p.id as pid, p.name as pname, p.address as paddress, "
+                      + "s.id sportdotid, s.name sportdotname "
+                      + "from guests g "
+                      + "join players p on g.id=p.id "
+                      + "join sports s on g.id=s.id");
+
+          assertThat(result1.get(0).getT1().getClass()).isEqualTo(Guest.class);
+          assertThat(result1.get(0).getT1().getName()).isEqualTo(GUEST_ALICE.getName());
+          assertThat(result1.get(0).getT2().getClass()).isEqualTo(Player.class);
+          assertThat(result1.get(0).getT2().getName()).isEqualTo(PLAYER_ALICE.getName());
+          assertThat(result1.get(0).getT3().getClass()).isEqualTo(Sport.class);
+          assertThat(result1.get(0).getT3().getName()).isEqualTo(TENNIS.getName());
+          assertThat(result1.get(0).toString()).contains("Alice");
+        });
   }
 
   @Test
   void testNamedRequest1() {
-    int row = sorm.applyHandler(
-        conn -> Command.create(conn, "insert into players values(:id, :name, :address)")
-            .bindBean(new Player(1, "Frank", "Tokyo")).executeUpdate());
+    int row =
+        sorm.applyHandler(
+            conn ->
+                Command.create(conn, "insert into players values(:id, :name, :address)")
+                    .bindBean(new Player(1, "Frank", "Tokyo"))
+                    .executeUpdate());
     assertThat(row).isEqualTo(1);
   }
 
-
   @Test
   void testNamedRequest() {
     AtomicInteger id = new AtomicInteger(10);
 
-
-    int row = sorm.applyHandler(
-        conn -> Command.create(conn, "insert into players values(:id, :name, :address)")
-            .bindAll(Map.of("id", id.incrementAndGet(), "name", "Frank", "address", "Tokyo"))
-            .executeUpdate());
+    int row =
+        sorm.applyHandler(
+            conn ->
+                Command.create(conn, "insert into players values(:id, :name, :address)")
+                    .bindAll(
+                        Map.of("id", id.incrementAndGet(), "name", "Frank", "address", "Tokyo"))
+                    .executeUpdate());
     assertThat(row).isEqualTo(1);
 
-    row = sorm.applyHandler(
-        conn -> Command.create(conn, "insert into players values(:id, :name, :address)")
-            .bind("id", id.incrementAndGet()).bind("name", "Frank").bind("address", "Tokyo")
-            .executeUpdate());
+    row =
+        sorm.applyHandler(
+            conn ->
+                Command.create(conn, "insert into players values(:id, :name, :address)")
+                    .bind("id", id.incrementAndGet())
+                    .bind("name", "Frank")
+                    .bind("address", "Tokyo")
+                    .executeUpdate());
     assertThat(row).isEqualTo(1);
 
-    row = sorm.applyHandler(conn -> {
-      NamedParameterSqlParser sql =
-          NamedParameterSqlParser.of("insert into players values(`id`, `name`, `address`)", '`',
-              '`', new DefaultColumnToFieldAccessorMapper());
-      sql.bind("id", id.incrementAndGet()).bind("name", "Frank").bind("address", "Tokyo");
-      return conn.executeUpdate(sql.parse());
-    });
+    row =
+        sorm.applyHandler(
+            conn -> {
+              NamedParameterSqlParser sql =
+                  NamedParameterSqlParser.of(
+                      "insert into players values(`id`, `name`, `address`)",
+                      '`',
+                      '`',
+                      new DefaultColumnToFieldAccessorMapper());
+              sql.bind("id", id.incrementAndGet()).bind("name", "Frank").bind("address", "Tokyo");
+              return conn.executeUpdate(sql.parse());
+            });
     assertThat(row).isEqualTo(1);
 
-
-    var ret = sorm.applyHandler(conn -> Command.create(conn, "select * from players where id=:id")
-        .bind("id", id.get()).executeQuery(conn.getResultSetTraverser(Player.class)));
+    var ret =
+        sorm.applyHandler(
+            conn ->
+                Command.create(conn, "select * from players where id=:id")
+                    .bind("id", id.get())
+                    .executeQuery(conn.getResultSetTraverser(Player.class)));
 
     assertThat(ret.size()).isEqualTo(1);
   }
 
   @Test
   void testClose() {
-    sorm.acceptHandler(m -> {
-      m.close();
-      try {
-        assertThat(m.getJdbcConnection().isClosed()).isTrue();
-      } catch (SQLException e) {
-        fail();
-      }
-    });
+    sorm.acceptHandler(
+        m -> {
+          m.close();
+          try {
+            assertThat(m.getJdbcConnection().isClosed()).isTrue();
+          } catch (SQLException e) {
+            fail();
+          }
+        });
   }
 
-
   @Test
   void testCommint() {
-    sorm.acceptHandler(TRANSACTION_READ_COMMITTED, m -> {
-      m.insert(PLAYER_ALICE);
-      Player p = m.readOne(Player.class, "SELECT * FROM PLAYERS");
-      assertThat(p.getName()).isEqualTo(PLAYER_ALICE.getName());
-      // auto roll-back;
-    });
-    sorm.acceptHandler(TRANSACTION_READ_COMMITTED, m -> {
-      m.insert(PLAYER_ALICE);
-      m.commit();
-      m.close();
-    });
-    sorm.acceptHandler(m -> {
-      Player p = m.readOne(Player.class, "SELECT * FROM PLAYERS");
-      assertThat(p.getName()).isEqualTo(PLAYER_ALICE.getName());
-    });
+    sorm.acceptHandler(
+        TRANSACTION_READ_COMMITTED,
+        m -> {
+          m.insert(PLAYER_ALICE);
+          Player p = m.readOne(Player.class, "SELECT * FROM PLAYERS");
+          assertThat(p.getName()).isEqualTo(PLAYER_ALICE.getName());
+          // auto roll-back;
+        });
+    sorm.acceptHandler(
+        TRANSACTION_READ_COMMITTED,
+        m -> {
+          m.insert(PLAYER_ALICE);
+          m.commit();
+          m.close();
+        });
+    sorm.acceptHandler(
+        m -> {
+          Player p = m.readOne(Player.class, "SELECT * FROM PLAYERS");
+          assertThat(p.getName()).isEqualTo(PLAYER_ALICE.getName());
+        });
   }
 
   @Test
   void testDeleteOnStringT() {
-    sorm.acceptHandler(m -> {
-      Player a = PLAYER_ALICE;
-      Player b = PLAYER_BOB;
-      m.insertIn("players1", a);
-      m.deleteIn("players1", a);
-      assertThat(m.readList(Player.class, "select * from players1").size()).isEqualTo(0);
-      m.insertIn("players1", a, b);
-      m.deleteIn("players1", a, b);
-      assertThat(m.readList(Player.class, "select * from players1").size()).isEqualTo(0);
-    });
+    sorm.acceptHandler(
+        m -> {
+          Player a = PLAYER_ALICE;
+          Player b = PLAYER_BOB;
+          m.insertIn("players1", a);
+          m.deleteIn("players1", a);
+          assertThat(m.readList(Player.class, "select * from players1").size()).isEqualTo(0);
+          m.insertIn("players1", a, b);
+          m.deleteIn("players1", a, b);
+          assertThat(m.readList(Player.class, "select * from players1").size()).isEqualTo(0);
+        });
   }
 
   @Test
   void testDeleteT() {
-    sorm.acceptHandler(m -> {
-      Player a = PLAYER_ALICE;
-      Player b = PLAYER_BOB;
-      m.insert(a, b);
-      m.delete(a, b);
-      assertThat(m.selectAll(Player.class).size()).isEqualTo(0);
-
-      m.insert(a, b);
-      m.delete(a);
-      m.delete(b);
-      assertThat(m.selectAll(Player.class).size()).isEqualTo(0);
-
-      m.insert(a, b);
-      m.delete(List.of(a, b));
-      assertThat(m.selectAll(Player.class).size()).isEqualTo(0);
-
-    });
+    sorm.acceptHandler(
+        m -> {
+          Player a = PLAYER_ALICE;
+          Player b = PLAYER_BOB;
+          m.insert(a, b);
+          m.delete(a, b);
+          assertThat(m.selectAll(Player.class).size()).isEqualTo(0);
+
+          m.insert(a, b);
+          m.delete(a);
+          m.delete(b);
+          assertThat(m.selectAll(Player.class).size()).isEqualTo(0);
+
+          m.insert(a, b);
+          m.delete(List.of(a, b));
+          assertThat(m.selectAll(Player.class).size()).isEqualTo(0);
+        });
   }
 
-
   @Test
   void testInsertAndGetOnStringT() {
     Guest a = GUEST_ALICE;
-    sorm.acceptHandler(m -> {
-      InsertResult g = m.insertAndGet(new Guest[] {});
-      assertThat(g.countRowsModified()).isEqualTo(0);
-    });
-
-
-    sorm.acceptHandler(m -> {
-      InsertResult g = m.insertAndGet(a);
-      assertThat(g.getGeneratedKeys().get("id")).isEqualTo(1);
-    });
-    sorm.acceptHandler(m -> {
-      InsertResult g = m.insertAndGetIn("players1", a);
-      assertThat(g.getGeneratedKeys().get("id")).isNull();
-    });
+    sorm.acceptHandler(
+        m -> {
+          InsertResult g = m.insertAndGet(new Guest[] {});
+          assertThat(g.countRowsModified()).isEqualTo(0);
+        });
+
+    sorm.acceptHandler(
+        m -> {
+          InsertResult g = m.insertAndGet(a);
+          assertThat(g.getGeneratedKeys().get("id")).isEqualTo(1);
+        });
+    sorm.acceptHandler(
+        m -> {
+          InsertResult g = m.insertAndGetIn("players1", a);
+          assertThat(g.getGeneratedKeys().get("id")).isNull();
+        });
   }
 
   @Test
   void testInsertAndGetOnList() {
     Guest a = GUEST_ALICE;
-    sorm.acceptHandler(m -> {
-      InsertResult g = m.insertAndGetIn("players1", List.of());
-      assertThat(g.toString()).contains("InsertResult");
-      assertThat(g.countRowsModified()).isEqualTo(0);
-    });
-    sorm.acceptHandler(m -> {
-      InsertResult g = m.insertAndGet(List.of(a));
-      assertThat(g.getGeneratedKeys().get("id")).isEqualTo(1);
-    });
-    sorm.acceptHandler(m -> {
-      InsertResult g = m.insertAndGetIn("guests", List.of(GUEST_BOB));
-      assertThat(g.getGeneratedKeys().get("id")).isEqualTo(2);
-    });
+    sorm.acceptHandler(
+        m -> {
+          InsertResult g = m.insertAndGetIn("players1", List.of());
+          assertThat(g.toString()).contains("InsertResult");
+          assertThat(g.countRowsModified()).isEqualTo(0);
+        });
+    sorm.acceptHandler(
+        m -> {
+          InsertResult g = m.insertAndGet(List.of(a));
+          assertThat(g.getGeneratedKeys().get("id")).isEqualTo(1);
+        });
+    sorm.acceptHandler(
+        m -> {
+          InsertResult g = m.insertAndGetIn("guests", List.of(GUEST_BOB));
+          assertThat(g.getGeneratedKeys().get("id")).isEqualTo(2);
+        });
   }
 
   @Test
   void testInsertAndGetOnStringT0() {
     Guest a = GUEST_ALICE;
     Guest b = GUEST_BOB;
-    sorm.acceptHandler(m -> {
-      InsertResult g = m.insertAndGet(a, b);
-      assertThat(g.getGeneratedKeys().get("id")).isEqualTo(2);
-    });
+    sorm.acceptHandler(
+        m -> {
+          InsertResult g = m.insertAndGet(a, b);
+          assertThat(g.getGeneratedKeys().get("id")).isEqualTo(2);
+        });
   }
 
   @Test
   void testInsertAndGetOnStringT1() {
     Guest a = GUEST_ALICE;
     Guest b = GUEST_BOB;
-    sorm.acceptHandler(m -> {
-      InsertResult g = m.insertAndGetIn("guests", a, b);
-      assertThat(g.getGeneratedKeys().get("id")).isEqualTo(2);
-    });
+    sorm.acceptHandler(
+        m -> {
+          InsertResult g = m.insertAndGetIn("guests", a, b);
+          assertThat(g.getGeneratedKeys().get("id")).isEqualTo(2);
+        });
   }
 
-
-
   @Test
   void testInsertAndRead() {
-    sorm.acceptHandler(m -> {
-      Guest a = GUEST_ALICE;
-      m.insert(a);
-      Guest g = m.readFirst(Guest.class, "SELECT * FROM GUESTS");
-      assertThat(g.getAddress()).isEqualTo(a.getAddress());
-      assertThat(g.getName()).isEqualTo(a.getName());
-      m.deleteAll(Guest.class);
-      assertThat(m.readList(Guest.class, "select * from guests").size()).isEqualTo(0);
-    });
+    sorm.acceptHandler(
+        m -> {
+          Guest a = GUEST_ALICE;
+          m.insert(a);
+          Guest g = m.readFirst(Guest.class, "SELECT * FROM GUESTS");
+          assertThat(g.getAddress()).isEqualTo(a.getAddress());
+          assertThat(g.getName()).isEqualTo(a.getName());
+          m.deleteAll(Guest.class);
+          assertThat(m.readList(Guest.class, "select * from guests").size()).isEqualTo(0);
+        });
   }
 
   @Test
   void testInsertOnStringT() {
-    sorm.acceptHandler(m -> {
-      Player a = PLAYER_ALICE;
-      Player b = PLAYER_BOB;
-      m.insertIn("players1", a, b);
-      assertThat(m.readList(Player.class, "select * from players1")).contains(a, b);
-      m.deleteAllIn("players1");
-      assertThat(m.readList(Player.class, "select * from players1").size()).isEqualTo(0);
-    });
-    sorm.acceptHandler(m -> {
-      Player a = PLAYER_ALICE;
-      Player b = PLAYER_BOB;
-      m.insertIn("players1", List.of(a, b));
-      assertThat(m.readList(Player.class, "select * from players1")).contains(a, b);
-      m.deleteIn("players1", List.of(a, b));
-      assertThat(m.readList(Player.class, "select * from players1").size()).isEqualTo(0);
-    });
+    sorm.acceptHandler(
+        m -> {
+          Player a = PLAYER_ALICE;
+          Player b = PLAYER_BOB;
+          m.insertIn("players1", a, b);
+          assertThat(m.readList(Player.class, "select * from players1")).contains(a, b);
+          m.deleteAllIn("players1");
+          assertThat(m.readList(Player.class, "select * from players1").size()).isEqualTo(0);
+        });
+    sorm.acceptHandler(
+        m -> {
+          Player a = PLAYER_ALICE;
+          Player b = PLAYER_BOB;
+          m.insertIn("players1", List.of(a, b));
+          assertThat(m.readList(Player.class, "select * from players1")).contains(a, b);
+          m.deleteIn("players1", List.of(a, b));
+          assertThat(m.readList(Player.class, "select * from players1").size()).isEqualTo(0);
+        });
   }
 
-
   @Test
   void testExec() {
-    sorm.acceptHandler(m -> {
-      m.insert(PLAYER_ALICE);
-      assertThat(m.executeUpdate("delete from players")).isEqualTo(1);
-      m.insert(PLAYER_ALICE, PLAYER_BOB);
-      assertThat(m.executeUpdate(ParameterizedSql.of("delete from players", new Object[0])))
-          .isEqualTo(2);;
-
-    });
+    sorm.acceptHandler(
+        m -> {
+          m.insert(PLAYER_ALICE);
+          assertThat(m.executeUpdate("delete from players")).isEqualTo(1);
+          m.insert(PLAYER_ALICE, PLAYER_BOB);
+          assertThat(m.executeUpdate(ParameterizedSql.of("delete from players", new Object[0])))
+              .isEqualTo(2);
+          ;
+        });
   }
 
-
   @Test
   void testMergeError() {
     try {
-      sorm.acceptHandler(m -> {
-        Guest a = GUEST_ALICE;
-        m.merge(a);
-      });
+      sorm.acceptHandler(
+          m -> {
+            Guest a = GUEST_ALICE;
+            m.merge(a);
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("Parameter \"#3\" is not set;");
     }
@@ -354,11 +391,12 @@ void testmergeInT() {
   @Test
   void testMergesError() {
     try {
-      sorm.acceptHandler(m -> {
-        Guest a = GUEST_ALICE;
-        Guest b = GUEST_BOB;
-        m.merge(a, b);
-      });
+      sorm.acceptHandler(
+          m -> {
+            Guest a = GUEST_ALICE;
+            Guest b = GUEST_BOB;
+            m.merge(a, b);
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("SQL");
     }
@@ -377,156 +415,168 @@ void testMergeT() {
     assertThat(sorm.selectByPrimaryKey(Player.class, a.getId()).readAddress()).isEqualTo("UPDATED");
   }
 
-
   @Test
   void testReadAllLazy() {
     Player a = PLAYER_ALICE;
     Player b = PLAYER_BOB;
 
-    sorm.acceptHandler(m -> {
-      m.insert(a, b);
-
-      try {
-        m.readFirst(Player.class, "select * from hoge");
-        failBecauseExceptionWasNotThrown(Exception.class);
-      } catch (Exception e) {
-      }
-
-      try {
-        m.readList(Player.class, "select * from hoge");
-        failBecauseExceptionWasNotThrown(Exception.class);
-      } catch (Exception e) {
-      }
-
-
-
-      assertThat(m.readList(Integer.class, "select id from players")).contains(1, 2);
-
-
-      try {
-        m.readList(Integer.class, "select * from players");
-        failBecauseExceptionWasNotThrown(Exception.class);
-      } catch (Exception e) {
-        assertThat(e.getMessage()).contains("but 1 column was expected to load data into");
-      }
-    });
-
-
+    sorm.acceptHandler(
+        m -> {
+          m.insert(a, b);
+
+          try {
+            m.readFirst(Player.class, "select * from hoge");
+            failBecauseExceptionWasNotThrown(Exception.class);
+          } catch (Exception e) {
+          }
+
+          try {
+            m.readList(Player.class, "select * from hoge");
+            failBecauseExceptionWasNotThrown(Exception.class);
+          } catch (Exception e) {
+          }
+
+          assertThat(m.readList(Integer.class, "select id from players")).contains(1, 2);
+
+          try {
+            m.readList(Integer.class, "select * from players");
+            failBecauseExceptionWasNotThrown(Exception.class);
+          } catch (Exception e) {
+            assertThat(e.getMessage()).contains("but 1 column was expected to load data into");
+          }
+        });
   }
 
   @Test
   void testReadByPrimaryKey() {
-    sorm.acceptHandler(m -> {
-      Guest a = GUEST_ALICE;
-      m.insert(a);
-      Guest g = m.selectByPrimaryKey(Guest.class, 1);
-      assertThat(g.getAddress()).isEqualTo(a.getAddress());
-      assertThat(g.getName()).isEqualTo(a.getName());
-    });
+    sorm.acceptHandler(
+        m -> {
+          Guest a = GUEST_ALICE;
+          m.insert(a);
+          Guest g = m.selectByPrimaryKey(Guest.class, 1);
+          assertThat(g.getAddress()).isEqualTo(a.getAddress());
+          assertThat(g.getName()).isEqualTo(a.getName());
+        });
   }
 
   @Test
   void testReadList() {
-    sorm.acceptHandler(m -> {
-      Player a = PLAYER_ALICE;
-      Player b = PLAYER_BOB;
-      m.insert(a, b);
-      assertThat(m.readList(Player.class, "select * from players")).contains(a, b);
-      assertThat(m.readList(Player.class, ParameterizedSql.of("select * from players"))).contains(a,
-          b);
-      assertThat(m.readOne(Player.class,
-          OrderedParameterSqlParser.parse("select * from players where id=?", 1))).isEqualTo(a);
-      assertThat(m.readOne(Player.class, "select * from players where id=?", 1)).isEqualTo(a);
-
-
-    });
+    sorm.acceptHandler(
+        m -> {
+          Player a = PLAYER_ALICE;
+          Player b = PLAYER_BOB;
+          m.insert(a, b);
+          assertThat(m.readList(Player.class, "select * from players")).contains(a, b);
+          assertThat(m.readList(Player.class, ParameterizedSql.of("select * from players")))
+              .contains(a, b);
+          assertThat(
+                  m.readOne(
+                      Player.class,
+                      OrderedParameterSqlParser.parse("select * from players where id=?", 1)))
+              .isEqualTo(a);
+          assertThat(m.readOne(Player.class, "select * from players where id=?", 1)).isEqualTo(a);
+        });
   }
 
   @Test
   void testReadOne() {
     try {
-      sorm.acceptHandler(m -> {
-        Guest a = GUEST_ALICE;
-        Guest b = GUEST_BOB;
-        m.insert(a);
-        m.insert(b);
-        Guest g = m.readOne(Guest.class,
-            OrderedParameterSqlParser.parse("select * from guests where id=?", 1));
-        assertThat(g.getAddress()).isEqualTo(a.getAddress());
-        assertThat(g.getName()).isEqualTo(a.getName());
-        g = m.readOne(Guest.class, ParameterizedSql.of("select * from guests"));
-        failBecauseExceptionWasNotThrown(SormException.class);
-      });
+      sorm.acceptHandler(
+          m -> {
+            Guest a = GUEST_ALICE;
+            Guest b = GUEST_BOB;
+            m.insert(a);
+            m.insert(b);
+            Guest g =
+                m.readOne(
+                    Guest.class,
+                    OrderedParameterSqlParser.parse("select * from guests where id=?", 1));
+            assertThat(g.getAddress()).isEqualTo(a.getAddress());
+            assertThat(g.getName()).isEqualTo(a.getName());
+            g = m.readOne(Guest.class, ParameterizedSql.of("select * from guests"));
+            failBecauseExceptionWasNotThrown(SormException.class);
+          });
     } catch (SormException e) {
       assertThat(e.getMessage()).contains("non-unique");
     }
-
   }
 
-
   @Test
   void testTransaction() {
     Guest a = GUEST_ALICE;
-    sorm.acceptHandler(TRANSACTION_READ_COMMITTED, m -> {
-      m.insert(a);
-      m.rollback();
-    });
-
-
-    sorm.acceptHandler(TRANSACTION_READ_COMMITTED, m -> {
-      m.insert(a);
-      Guest g = m.readFirst(Guest.class, "SELECT * FROM GUESTS");
-      assertThat(g.getAddress()).isEqualTo(a.getAddress());
-      g = m.readFirst(Guest.class, ParameterizedSql.of("SELECT * FROM GUESTS"));
-      assertThat(g.getAddress()).isEqualTo(a.getAddress());
-    });
+    sorm.acceptHandler(
+        TRANSACTION_READ_COMMITTED,
+        m -> {
+          m.insert(a);
+          m.rollback();
+        });
+
+    sorm.acceptHandler(
+        TRANSACTION_READ_COMMITTED,
+        m -> {
+          m.insert(a);
+          Guest g = m.readFirst(Guest.class, "SELECT * FROM GUESTS");
+          assertThat(g.getAddress()).isEqualTo(a.getAddress());
+          g = m.readFirst(Guest.class, ParameterizedSql.of("SELECT * FROM GUESTS"));
+          assertThat(g.getAddress()).isEqualTo(a.getAddress());
+        });
   }
 
   @Test
   void testTransactionLevel() {
     Sorm orm = Sorm.create(sorm.getDataSource(), SormContext.builder().build());
 
-    orm.acceptHandler(Connection.TRANSACTION_SERIALIZABLE, m -> {
-      assertThat(m.getJdbcConnection().getTransactionIsolation())
-          .isEqualTo(Connection.TRANSACTION_SERIALIZABLE);
-    });
+    orm.acceptHandler(
+        Connection.TRANSACTION_SERIALIZABLE,
+        m -> {
+          assertThat(m.getJdbcConnection().getTransactionIsolation())
+              .isEqualTo(Connection.TRANSACTION_SERIALIZABLE);
+        });
   }
 
-
   @Test
   void testUpdateOnT() {
     Player a = PLAYER_ALICE;
     Player b = PLAYER_ALICE;
-    sorm.acceptHandler(m -> {
-      m.insert(a);
-      m.updateIn("players", new Player(a.getId(), "UPDATED", "UPDATED"));
-      m.updateIn("players", new Player(a.getId(), "UPDATED", "UPDATED"),
-          new Player(b.getId(), "UPDATED", "UPDATED"));
-      m.updateIn("players", List.of(new Player(a.getId(), "UPDATED", "UPDATED"),
-          new Player(b.getId(), "UPDATED", "UPDATED")));
-      Player p = m.selectByPrimaryKey(Player.class, a.getId());
-      assertThat(p.readAddress()).isEqualTo("UPDATED");
-      p = m.selectByPrimaryKey(Player.class, b.getId());
-      assertThat(p.readAddress()).isEqualTo("UPDATED");
-    });
+    sorm.acceptHandler(
+        m -> {
+          m.insert(a);
+          m.updateIn("players", new Player(a.getId(), "UPDATED", "UPDATED"));
+          m.updateIn(
+              "players",
+              new Player(a.getId(), "UPDATED", "UPDATED"),
+              new Player(b.getId(), "UPDATED", "UPDATED"));
+          m.updateIn(
+              "players",
+              List.of(
+                  new Player(a.getId(), "UPDATED", "UPDATED"),
+                  new Player(b.getId(), "UPDATED", "UPDATED")));
+          Player p = m.selectByPrimaryKey(Player.class, a.getId());
+          assertThat(p.readAddress()).isEqualTo("UPDATED");
+          p = m.selectByPrimaryKey(Player.class, b.getId());
+          assertThat(p.readAddress()).isEqualTo("UPDATED");
+        });
   }
 
   @Test
   void testUpdateT() {
     Player a = PLAYER_ALICE;
     Player b = PLAYER_ALICE;
-    sorm.acceptHandler(m -> {
-      m.insert(a);
-      m.update(new Player(a.getId(), "UPDATED", "UPDATED"));
-      m.update(new Player(a.getId(), "UPDATED", "UPDATED"),
-          new Player(b.getId(), "UPDATED", "UPDATED"));
-      m.update(List.of(new Player(a.getId(), "UPDATED", "UPDATED"),
-          new Player(b.getId(), "UPDATED", "UPDATED")));
-      Player p = m.selectByPrimaryKey(Player.class, a.getId());
-      assertThat(p.readAddress()).isEqualTo("UPDATED");
-      p = m.selectByPrimaryKey(Player.class, b.getId());
-      assertThat(p.readAddress()).isEqualTo("UPDATED");
-    });
+    sorm.acceptHandler(
+        m -> {
+          m.insert(a);
+          m.update(new Player(a.getId(), "UPDATED", "UPDATED"));
+          m.update(
+              new Player(a.getId(), "UPDATED", "UPDATED"),
+              new Player(b.getId(), "UPDATED", "UPDATED"));
+          m.update(
+              List.of(
+                  new Player(a.getId(), "UPDATED", "UPDATED"),
+                  new Player(b.getId(), "UPDATED", "UPDATED")));
+          Player p = m.selectByPrimaryKey(Player.class, a.getId());
+          assertThat(p.readAddress()).isEqualTo("UPDATED");
+          p = m.selectByPrimaryKey(Player.class, b.getId());
+          assertThat(p.readAddress()).isEqualTo("UPDATED");
+        });
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmImplTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmImplTest.java
index e0ec9441..9321c7f7 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmImplTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmImplTest.java
@@ -29,18 +29,19 @@ void setUp() {
     sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables();
   }
 
-
   @Test
   void testReadAll() {
     sorm.insert(PLAYER_ALICE);
     assertThat(sorm.selectAll(Player.class)).contains(PLAYER_ALICE);
 
-    assertThatThrownBy(() -> sorm.readFirst(LocalDateTime.class,
-        ParameterizedSqlParser.parse("select count(*) from players limit 1")))
-            .isInstanceOf(SormException.class);
+    assertThatThrownBy(
+            () ->
+                sorm.readFirst(
+                    LocalDateTime.class,
+                    ParameterizedSqlParser.parse("select count(*) from players limit 1")))
+        .isInstanceOf(SormException.class);
   }
 
-
   @Test
   void testReadByPrimaryKey() {
     sorm.insert(PLAYER_ALICE);
@@ -51,8 +52,9 @@ void testReadByPrimaryKey() {
   void testReadFirstClassOfTParameterizedSql() {
     sorm.insert(PLAYER_ALICE);
     assertThat(
-        sorm.readFirst(Player.class, ParameterizedSqlParser.parse("select * from players limit 1")))
-            .isEqualTo(PLAYER_ALICE);
+            sorm.readFirst(
+                Player.class, ParameterizedSqlParser.parse("select * from players limit 1")))
+        .isEqualTo(PLAYER_ALICE);
   }
 
   @Test
@@ -62,13 +64,14 @@ void testReadFirstClassOfTStringObjectArray() {
         .isEqualTo(PLAYER_ALICE);
   }
 
-
   @Test
   void testReadListClassOfTParameterizedSql() {
     sorm.insert(PLAYER_ALICE);
     assertThat(
-        sorm.readList(Player.class, ParameterizedSqlParser.parse("select * from players limit 1"))
-            .get(0)).isEqualTo(PLAYER_ALICE);
+            sorm.readList(
+                    Player.class, ParameterizedSqlParser.parse("select * from players limit 1"))
+                .get(0))
+        .isEqualTo(PLAYER_ALICE);
   }
 
   @Test
@@ -82,8 +85,9 @@ void testReadListClassOfTStringObjectArray() {
   void testReadOneClassOfTParameterizedSql() {
     sorm.insert(PLAYER_ALICE);
     assertThat(
-        sorm.readOne(Player.class, ParameterizedSqlParser.parse("select * from players limit 1")))
-            .isEqualTo(PLAYER_ALICE);
+            sorm.readOne(
+                Player.class, ParameterizedSqlParser.parse("select * from players limit 1")))
+        .isEqualTo(PLAYER_ALICE);
   }
 
   @Test
@@ -106,7 +110,6 @@ void testDeleteListOfT() {
     assertThat(sorm.getTable(Player.class).count()).isEqualTo(2);
     sorm.delete(List.of(PLAYER_ALICE, PLAYER_BOB));
     assertThat(sorm.getTable(Player.class).count()).isEqualTo(0);
-
   }
 
   @Test
@@ -171,7 +174,6 @@ void testInsertListOfT() {
     assertThat(sorm.getTable(Player.class).count()).isEqualTo(2);
   }
 
-
   @Test
   void testInsertAndGetListOfT() {
     InsertResult ret = sorm.insertAndGet(List.of(GUEST_ALICE, GUEST_BOB));
@@ -325,28 +327,25 @@ void testGetTableMetaDataClassOfQString() {
 
   @Test
   void testOpenMapStream() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(PLAYER_ALICE);
-      ResultSetStream stream =
-          conn.stream(RowMap.class, ParameterizedSql.of("select * from players"));
-      int ret = stream.apply(strm -> strm.collect(Collectors.toList()).size());
-      assertThat(ret).isEqualTo(1);
-
-      ResultSetStream strm1 = conn.streamAll(Player.class);
-      int ret1 = strm1.apply(strm -> strm.collect(Collectors.toList()).size());
-      assertThat(ret1).isEqualTo(1);
-
-      assertThat(conn.getTableSql(PLAYERS1).toString()).contains("PLAYERS1");
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(PLAYER_ALICE);
+          ResultSetStream stream =
+              conn.stream(RowMap.class, ParameterizedSql.of("select * from players"));
+          int ret = stream.apply(strm -> strm.collect(Collectors.toList()).size());
+          assertThat(ret).isEqualTo(1);
 
-      assertThat(conn.mapToTable(Player.class).count()).isEqualTo(1);
-      conn.mapToTable(Player.class, PLAYERS1).insert(PLAYER_ALICE, PLAYER_BOB, PLAYER_CAROL);
-
-      assertThat(conn.mapToTable(Player.class, PLAYERS1).count()).isEqualTo(3);
-
-    });
+          ResultSetStream strm1 = conn.streamAll(Player.class);
+          int ret1 = strm1.apply(strm -> strm.collect(Collectors.toList()).size());
+          assertThat(ret1).isEqualTo(1);
 
+          assertThat(conn.getTableSql(PLAYERS1).toString()).contains("PLAYERS1");
 
+          assertThat(conn.mapToTable(Player.class).count()).isEqualTo(1);
+          conn.mapToTable(Player.class, PLAYERS1).insert(PLAYER_ALICE, PLAYER_BOB, PLAYER_CAROL);
 
+          assertThat(conn.mapToTable(Player.class, PLAYERS1).count()).isEqualTo(3);
+        });
   }
 
   @Test
@@ -362,28 +361,31 @@ void testInsertMapIn() {
 
   @Test
   void testAcceptPreparedStatementHandler() {
-    sorm.executeQuery(con -> con.prepareStatement("select * from players"),
-        sorm.getRowMapper(Player.class));
+    sorm.executeQuery(
+        con -> con.prepareStatement("select * from players"), sorm.getRowMapper(Player.class));
   }
 
   @Test
   void testApplyPreparedStatementHandler() {
-    sorm.executeQuery(con -> con.prepareStatement("select * from players"),
+    sorm.executeQuery(
+        con -> con.prepareStatement("select * from players"),
         sorm.getResultSetTraverser(Player.class));
   }
 
   @Test
   void testExecuteQueryParameterizedSqlResultSetTraverserOfT() {
-    sorm.executeQuery(ParameterizedSqlParser.parse("select * from players"),
+    sorm.executeQuery(
+        ParameterizedSqlParser.parse("select * from players"),
         sorm.getResultSetTraverser(Player.class));
   }
 
   @Test
   void testExecuteQueryParameterizedSqlRowMapperOfT() {
-    sorm.executeQuery(ParameterizedSqlParser.parse("select * from players"),
-        sorm.getRowMapper(Player.class));
+    sorm.executeQuery(
+        ParameterizedSqlParser.parse("select * from players"), sorm.getRowMapper(Player.class));
 
-    sorm.executeQuery(ParameterizedSqlParser.parse("select * from players"),
+    sorm.executeQuery(
+        ParameterizedSqlParser.parse("select * from players"),
         sorm.getResultSetTraverser(Player.class));
   }
 
@@ -397,5 +399,4 @@ void testExecuteUpdateParameterizedSql() {
     sorm.executeUpdate(
         ParameterizedSqlParser.parse("insert into players values(?,?,?)", 9, "A", "B"));
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmStreamTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmStreamTest.java
index 551480d5..1e841d30 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmStreamTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/OrmStreamTest.java
@@ -27,8 +27,5 @@ void test() {
     int ret = sorm.streamAll(Guest.class).apply(strm -> strm.collect(Collectors.toList()).size());
 
     assertThat(ret).isEqualTo(1);
-
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormContextImplTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormContextImplTest.java
index e651fdb0..a5f1e0fa 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormContextImplTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormContextImplTest.java
@@ -25,24 +25,31 @@ class SormContextImplTest {
 
   @Test
   void testBuild() {
-    SormContext context = SormContext.builder()
-        .setColumnToFieldAccessorMapper(new DefaultColumnToFieldAccessorMapper())
-        .setTableNameMapper(new DefaultTableNameMapper())
-        .setColumnValueToMapValueConverters(new DefaultColumnValueToMapValueConverters())
-        .setColumnValueToJavaObjectConverters(new DefaultColumnValueToJavaObjectConverters())
-        .setSqlParametersSetter(new DefaultSqlParametersSetter())
-        .setMultiRowProcessorFactory(MultiRowProcessorFactory.builder().setBatchSize(10)
-            .setBatchSizeWithMultiRow(20).build())
-        .setLoggerContext(LoggerContext.builder().enable(LoggerContext.Category.MAPPING)
-            .disable(LoggerContext.Category.MAPPING).build())
-        .build();
+    SormContext context =
+        SormContext.builder()
+            .setColumnToFieldAccessorMapper(new DefaultColumnToFieldAccessorMapper())
+            .setTableNameMapper(new DefaultTableNameMapper())
+            .setColumnValueToMapValueConverters(new DefaultColumnValueToMapValueConverters())
+            .setColumnValueToJavaObjectConverters(new DefaultColumnValueToJavaObjectConverters())
+            .setSqlParametersSetter(new DefaultSqlParametersSetter())
+            .setMultiRowProcessorFactory(
+                MultiRowProcessorFactory.builder()
+                    .setBatchSize(10)
+                    .setBatchSizeWithMultiRow(20)
+                    .build())
+            .setLoggerContext(
+                LoggerContext.builder()
+                    .enable(LoggerContext.Category.MAPPING)
+                    .disable(LoggerContext.Category.MAPPING)
+                    .build())
+            .build();
 
     Sorm sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables(context);
 
     try (Connection conn = sorm.getJdbcConnection()) {
       assertThatThrownBy(() -> SormImpl.DEFAULT_CONTEXT.getTableName(conn, Temporary.class))
-          .isInstanceOfSatisfying(SormException.class,
-              e -> assertThat(e.getMessage()).contains("TEMPORARIES"));
+          .isInstanceOfSatisfying(
+              SormException.class, e -> assertThat(e.getMessage()).contains("TEMPORARIES"));
     } catch (SQLException e) {
       e.printStackTrace();
     }
@@ -50,23 +57,29 @@ void testBuild() {
     sorm.insert(SormTestUtils.PLAYER_ALICE);
     sorm.insert(SormTestUtils.TENNIS);
 
-
     sorm.selectAll(Guest.class);
     sorm.selectAll(Player.class);
     sorm.selectAll(Sport.class);
 
     assertThatThrownBy(() -> sorm.readList(Temp.class, "select * from guests"))
-        .isInstanceOfSatisfying(SormException.class, e -> assertThat(e.getMessage()).isEqualTo(
-            "The given container class [class org.nkjmlab.sorm4j.internal.SormContextImplTest$Temp] annotated by @OrmRecord should have the canonical constructor."));
+        .isInstanceOfSatisfying(
+            SormException.class,
+            e ->
+                assertThat(e.getMessage())
+                    .isEqualTo(
+                        "The given container class [class org.nkjmlab.sorm4j.internal.SormContextImplTest$Temp] annotated by @OrmRecord should have the canonical constructor."));
 
     assertThatThrownBy(() -> sorm.readList(Temporary.class, "select * from guests"))
-        .isInstanceOfSatisfying(SormException.class, e -> assertThat(e.getMessage()).isEqualTo(
-            "The given container class [class org.nkjmlab.sorm4j.internal.SormContextImplTest$Temporary] should have one or less constructor annotated by @OrmConstructor."));
+        .isInstanceOfSatisfying(
+            SormException.class,
+            e ->
+                assertThat(e.getMessage())
+                    .isEqualTo(
+                        "The given container class [class org.nkjmlab.sorm4j.internal.SormContextImplTest$Temporary] should have one or less constructor annotated by @OrmConstructor."));
 
     // assertThat(context.toString()).contains("created by");
 
     System.out.println(context.toString());
-
   }
 
   @OrmRecord
@@ -75,18 +88,14 @@ public static class Temp {
     public String name;
 
     public Temp() {}
-
   }
-  public static class Temporary {
 
+  public static class Temporary {
 
     @OrmConstructor({""})
     public Temporary() {}
 
     @OrmConstructor({"id"})
     public Temporary(int id) {}
-
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormImplTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormImplTest.java
index d53f9c6b..bc074bc3 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormImplTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormImplTest.java
@@ -23,7 +23,6 @@
 
 class SormImplTest {
 
-
   private Sorm sorm;
 
   @BeforeEach
@@ -43,21 +42,25 @@ void testJoin() {
         sorm.leftJoinOn(Guest.class, Player.class, "guests.id=players.id");
     assertThat(ret.size()).isEqualTo(sorm.selectAll(Guest.class).size());
 
-    List> ret1 = sorm.leftJoinOn(Guest.class, Player.class, Sport.class,
-        "guests.id=players.id", "players.id=sports.id");
+    List> ret1 =
+        sorm.leftJoinOn(
+            Guest.class, Player.class, Sport.class, "guests.id=players.id", "players.id=sports.id");
     assertThat(ret1.size()).isEqualTo(sorm.selectAll(Guest.class).size());
 
-
     sorm.insert(PLAYER_ALICE);
     assertThat(sorm.exists(PLAYER_ALICE)).isTrue();
 
-
-    sorm.readTupleList(Guest.class, Player.class,
+    sorm.readTupleList(
+        Guest.class,
+        Player.class,
         ParameterizedSql.of("select * from guests join players on guests.id=players.id"));
 
-    sorm.readTupleList(Guest.class, Player.class, Sport.class, ParameterizedSql.of(
-        "select * from guests join players on guests.id=players.id join sports on players.id=sports.id"));
-
+    sorm.readTupleList(
+        Guest.class,
+        Player.class,
+        Sport.class,
+        ParameterizedSql.of(
+            "select * from guests join players on guests.id=players.id join sports on players.id=sports.id"));
   }
 
   @Test
@@ -72,10 +75,8 @@ void readMapOne() {
     }
 
     assertThat(sorm.getJdbcDatabaseMetaData().toString()).contains("jdbc");
-
   }
 
-
   @Test
   void testAutoRollback() throws SQLException {
     Guest a = SormTestUtils.GUEST_ALICE;
@@ -87,7 +88,6 @@ void testAutoRollback() throws SQLException {
 
     sorm.applyHandler(Connection.TRANSACTION_READ_COMMITTED, conn -> conn.insert(a));
     assertThat(sorm.selectAll(Guest.class).size() == 0);
-
   }
 
   @Test
@@ -98,7 +98,6 @@ void testException() throws SQLException {
     // Mockito.doThrow(new SQLException("Mock close exception")).when(conMock).close();
     // Mockito.when(dsMock.getConnection()).thenReturn(conMock);
 
-
     Sorm sorm = Sorm.create(dsMock);
     try {
       sorm.getJdbcConnection();
@@ -110,18 +109,19 @@ void testException() throws SQLException {
   @Test
   void testException1() throws SQLException {
 
-
     try {
-      sorm.applyHandler(con -> {
-        throw new RuntimeException("");
-      });
+      sorm.applyHandler(
+          con -> {
+            throw new RuntimeException("");
+          });
       failBecauseExceptionWasNotThrown(Exception.class);
     } catch (Exception e) {
     }
     try {
-      sorm.acceptHandler(con -> {
-        throw new RuntimeException("");
-      });
+      sorm.acceptHandler(
+          con -> {
+            throw new RuntimeException("");
+          });
       failBecauseExceptionWasNotThrown(Exception.class);
     } catch (Exception e) {
     }
@@ -132,7 +132,6 @@ void testToString() {
     assertThat(sorm.toString()).contains("Sorm");
 
     Sorm.create(SormTestUtils.createNewDatabaseDataSource()).getDataSource();
-
   }
 
   private static Guest a = SormTestUtils.GUEST_ALICE;
@@ -144,5 +143,4 @@ void testBeginTransaction() {
       // auto-rollback
     }
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/ValuesObjectTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/ValuesObjectTest.java
index 1300aff6..bafc0ff0 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/ValuesObjectTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/ValuesObjectTest.java
@@ -14,7 +14,6 @@ void testTableName() {
     TableName v1 = new TableName("test");
     TableName v2 = new TableName("test");
     verify(v1, v2);
-
   }
 
   private void verify(Object v1, Object v2) {
@@ -23,7 +22,6 @@ private void verify(Object v1, Object v2) {
     assertThat(v1.equals(v2)).isTrue();
     assertThat(v1.equals("test")).isFalse();
     assertThat(v1.hashCode()).isEqualTo(v2.hashCode());
-
   }
 
   @Test
@@ -31,7 +29,6 @@ void testColumn() {
     ColumnName v1 = new ColumnName("test");
     ColumnName v2 = new ColumnName("test");
     verify(v1, v2);
-
   }
 
   @Test
@@ -39,7 +36,5 @@ void testColumnOrder() {
     ColumnName v1 = new ColumnName("2test");
     ColumnName v2 = new ColumnName("1test");
     assertThat(List.of(v1, v2).stream().sorted().collect(Collectors.toList()).get(0)).isEqualTo(v2);
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/ColumnToAccessorMappingTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/ColumnToAccessorMappingTest.java
index f64f2c27..adc2e457 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/ColumnToAccessorMappingTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/ColumnToAccessorMappingTest.java
@@ -22,44 +22,46 @@ void setUp() {
     sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables();
   }
 
-
   @Test
   void testGetValue() {
     sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables();
     try {
-      sorm.acceptHandler(m -> {
-        ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
-        Guest g = new Guest();
-        tm.getValue(g, "hoge");
-      });
+      sorm.acceptHandler(
+          m -> {
+            ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
+            Guest g = new Guest();
+            tm.getValue(g, "hoge");
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("does not have a corresponding");
     }
 
     try {
-      sorm.acceptHandler(m -> {
-        ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
-        String s = new String();
-        tm.getValue(s, "id");
-      });
+      sorm.acceptHandler(
+          m -> {
+            ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
+            String s = new String();
+            tm.getValue(s, "id");
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("Could not get a value");
     }
-
   }
 
   @Test
   void testInsertAndGetEx() throws SQLException {
     sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables();
     Connection conMock = Mockito.spy(Connection.class);
-    Mockito.doThrow(new SQLException("Mock exception")).when(conMock)
+    Mockito.doThrow(new SQLException("Mock exception"))
+        .when(conMock)
         .prepareStatement(Mockito.anyString(), Mockito.any(String[].class));
     try {
-      sorm.acceptHandler(m -> {
-        Guest a = SormTestUtils.GUEST_ALICE;
-        SqlParametersToTableMapping tm = getTableMapping(m, Guest.class);
-        tm.insertAndGet(conMock, a);
-      });
+      sorm.acceptHandler(
+          m -> {
+            Guest a = SormTestUtils.GUEST_ALICE;
+            SqlParametersToTableMapping tm = getTableMapping(m, Guest.class);
+            tm.insertAndGet(conMock, a);
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("Mock exception");
     }
@@ -69,26 +71,29 @@ void testInsertAndGetEx() throws SQLException {
   void testSetValue() {
     sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables();
     try {
-      sorm.acceptHandler(m -> {
-        ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
-        tm.setValue(new Guest(), "hoge", 0);
-      });
+      sorm.acceptHandler(
+          m -> {
+            ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
+            tm.setValue(new Guest(), "hoge", 0);
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("does not have a corresponding");
     }
     try {
-      sorm.acceptHandler(m -> {
-        ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
-        tm.setValue(new Guest(), "id", "String");
-      });
+      sorm.acceptHandler(
+          m -> {
+            ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
+            tm.setValue(new Guest(), "id", "String");
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("Could not set a value");
     }
     try {
-      sorm.acceptHandler(m -> {
-        ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
-        tm.setValue(new Player(), "name", 1);
-      });
+      sorm.acceptHandler(
+          m -> {
+            ColumnToAccessorMapping tm = getTableMapping(m, Guest.class).getColumnToAccessorMap();
+            tm.setValue(new Player(), "name", 1);
+          });
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("No valid setter for");
     }
@@ -98,14 +103,14 @@ void testSetValue() {
   void testCol() {
     sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables();
 
-    sorm.acceptHandler(m -> {
-      assertThat(getTableMapping(m, Guest.class).toString()).contains("mapped");
-    });
+    sorm.acceptHandler(
+        m -> {
+          assertThat(getTableMapping(m, Guest.class).toString()).contains("mapped");
+        });
   }
 
-  public static  SqlParametersToTableMapping getTableMapping(OrmConnection conn,
-      Class objectClass) {
+  public static  SqlParametersToTableMapping getTableMapping(
+      OrmConnection conn, Class objectClass) {
     return ((OrmConnectionImpl) conn).getTableMapping(objectClass);
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/DefaultResultSetValueGetterTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/DefaultResultSetValueGetterTest.java
index a3eb4036..a22a5226 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/DefaultResultSetValueGetterTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/DefaultResultSetValueGetterTest.java
@@ -29,11 +29,16 @@ void testGetValueBySetterType() {
     LocalDateTimeSample a = LocalDateTimeSample.buildRandom();
     sorm.acceptHandler(con -> con.insert(a));
 
-    LocalDateTimeSample r = sorm.applyHandler(
-        con -> con.readFirst(LocalDateTimeSample.class, "select * from LocalDateTimeSample"));
+    LocalDateTimeSample r =
+        sorm.applyHandler(
+            con -> con.readFirst(LocalDateTimeSample.class, "select * from LocalDateTimeSample"));
     assertThat(r).isEqualTo(a);
-    sorm.acceptHandler(con -> con.insert(Stream.generate(() -> LocalDateTimeSample.buildRandom())
-        .limit(10000).toArray(LocalDateTimeSample[]::new)));
+    sorm.acceptHandler(
+        con ->
+            con.insert(
+                Stream.generate(() -> LocalDateTimeSample.buildRandom())
+                    .limit(10000)
+                    .toArray(LocalDateTimeSample[]::new)));
 
     try {
       sorm.acceptHandler(con -> con.update(a));
@@ -45,16 +50,24 @@ void testGetValueBySetterType() {
     RowMap map = sorm.readFirst(RowMap.class, "select * from LocalDateTimeSample");
 
     assertThat(Arrays.asList(map.getArray("arry", String.class))).isEqualTo(List.of("a", "1"));
-
   }
 
   @Test
   void testGetValueBySqlType() {
-    List.of(java.sql.Types.ROWID, java.sql.Types.REF, java.sql.Types.ROWID, java.sql.Types.REF,
-        java.sql.Types.NUMERIC, java.sql.Types.NULL, java.sql.Types.LONGVARCHAR,
-        java.sql.Types.LONGVARBINARY, java.sql.Types.JAVA_OBJECT, java.sql.Types.FLOAT,
-        java.sql.Types.DATALINK, java.sql.Types.BIT, java.sql.Types.ARRAY);
-
+    List.of(
+        java.sql.Types.ROWID,
+        java.sql.Types.REF,
+        java.sql.Types.ROWID,
+        java.sql.Types.REF,
+        java.sql.Types.NUMERIC,
+        java.sql.Types.NULL,
+        java.sql.Types.LONGVARCHAR,
+        java.sql.Types.LONGVARBINARY,
+        java.sql.Types.JAVA_OBJECT,
+        java.sql.Types.FLOAT,
+        java.sql.Types.DATALINK,
+        java.sql.Types.BIT,
+        java.sql.Types.ARRAY);
   }
 
   @Test
@@ -67,8 +80,7 @@ public static class LocalDateTimeSample {
     public String[] arry;
     public Float fl;
 
-    @OrmIgnore
-    int ignoreCol;
+    @OrmIgnore int ignoreCol;
 
     @OrmIgnore
     public int getIgnoreCol() {
@@ -96,8 +108,15 @@ public static ZonedDateTime randomZonedDateTime() {
 
     @Override
     public String toString() {
-      return "LocalDateTimeSample [time=" + time + ", date=" + date + ", dateTime=" + dateTime
-          + ", arry=" + Arrays.toString(arry) + "]";
+      return "LocalDateTimeSample [time="
+          + time
+          + ", date="
+          + date
+          + ", dateTime="
+          + dateTime
+          + ", arry="
+          + Arrays.toString(arry)
+          + "]";
     }
 
     @Override
@@ -109,19 +128,15 @@ public int hashCode() {
       return result;
     }
 
-
     // without array
     @Override
     public boolean equals(Object obj) {
-      if (this == obj)
-        return true;
-      if (!(obj instanceof LocalDateTimeSample))
-        return false;
+      if (this == obj) return true;
+      if (!(obj instanceof LocalDateTimeSample)) return false;
       LocalDateTimeSample other = (LocalDateTimeSample) obj;
-      return Arrays.deepEquals(arry, other.arry) && Objects.equals(date, other.date)
+      return Arrays.deepEquals(arry, other.arry)
+          && Objects.equals(date, other.date)
           && Objects.equals(dateTime, other.dateTime);
     }
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/BatchOfMultiRowInOneStatementProcessorTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/BatchOfMultiRowInOneStatementProcessorTest.java
index e1c43c12..a2af40cf 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/BatchOfMultiRowInOneStatementProcessorTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/BatchOfMultiRowInOneStatementProcessorTest.java
@@ -23,16 +23,21 @@ class BatchOfMultiRowInOneStatementProcessorTest {
   private static final Player b = SormTestUtils.PLAYER_BOB;
   private static final Player c = SormTestUtils.PLAYER_CAROL;
 
-
-
   @BeforeAll
   static void setUp() {
-    SormContext context = SormContext.builder()
-        .setMultiRowProcessorFactory(MultiRowProcessorFactory.builder()
-            .setMultiRowProcessorType(MultiRowProcessorType.MULTI_ROW_AND_BATCH).build())
-        .setLoggerContext(LoggerContext.builder().enableAll().disableAll()
-            .setLoggerSupplier(() -> Log4jSormLogger.getLogger()).build())
-        .build();
+    SormContext context =
+        SormContext.builder()
+            .setMultiRowProcessorFactory(
+                MultiRowProcessorFactory.builder()
+                    .setMultiRowProcessorType(MultiRowProcessorType.MULTI_ROW_AND_BATCH)
+                    .build())
+            .setLoggerContext(
+                LoggerContext.builder()
+                    .enableAll()
+                    .disableAll()
+                    .setLoggerSupplier(() -> Log4jSormLogger.getLogger())
+                    .build())
+            .build();
     sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables(context);
     assertThat(sorm.getContext().toString())
         .contains(MultiRowProcessorType.MULTI_ROW_AND_BATCH.name());
@@ -43,8 +48,6 @@ void setUpEach() {
     sorm = createSormWithNewDatabaseAndCreateTables();
   }
 
-
-
   @Test
   void testMultiRowInsert() {
     sorm.acceptHandler(conn -> conn.insert(a, b));
@@ -68,15 +71,17 @@ void testMultiRowInsertNull() {
 
   @Test
   void testMultiRowInsertMany() {
-    sorm.acceptHandler(conn -> conn
-        .insert(Stream.generate(() -> GUEST_ALICE).limit(3000).collect(Collectors.toList())));
+    sorm.acceptHandler(
+        conn ->
+            conn.insert(
+                Stream.generate(() -> GUEST_ALICE).limit(3000).collect(Collectors.toList())));
   }
 
   @Test
   void testMultiRowMerge() {
-    sorm.acceptHandler(conn -> conn
-        .merge(Stream.generate(() -> PLAYER_ALICE).limit(3000).collect(Collectors.toList())));
+    sorm.acceptHandler(
+        conn ->
+            conn.merge(
+                Stream.generate(() -> PLAYER_ALICE).limit(3000).collect(Collectors.toList())));
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowInOneStatementProcessorTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowInOneStatementProcessorTest.java
index 1e11798f..80bf56eb 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowInOneStatementProcessorTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/MultiRowInOneStatementProcessorTest.java
@@ -18,55 +18,65 @@ class MultiRowInOneStatementProcessorTest {
   private static final Player b = SormTestUtils.PLAYER_BOB;
   private static final Player c = SormTestUtils.PLAYER_CAROL;
 
-
-  private static List sorms = List.of(SIMPLE_BATCH, MULTI_ROW, MULTI_ROW_AND_BATCH).stream()
-      .map(type -> SormTestUtils.createSormWithNewDatabaseAndCreateTables(SormContext.builder()
-          .setMultiRowProcessorFactory(
-              MultiRowProcessorFactory.builder().setMultiRowProcessorType(type).build())
-          .build()))
-      .collect(Collectors.toList());
-
-
+  private static List sorms =
+      List.of(SIMPLE_BATCH, MULTI_ROW, MULTI_ROW_AND_BATCH).stream()
+          .map(
+              type ->
+                  SormTestUtils.createSormWithNewDatabaseAndCreateTables(
+                      SormContext.builder()
+                          .setMultiRowProcessorFactory(
+                              MultiRowProcessorFactory.builder()
+                                  .setMultiRowProcessorType(type)
+                                  .build())
+                          .build()))
+          .collect(Collectors.toList());
 
   @Test
   void testMultiRowInsert() {
-    sorms.forEach(sorm -> {
-      sorm.deleteAll(Player.class);
-      sorm.insert(a, b);
-    });
-
+    sorms.forEach(
+        sorm -> {
+          sorm.deleteAll(Player.class);
+          sorm.insert(a, b);
+        });
   }
 
   @Test
   void testMultiRowInsertNull() {
-    sorms.forEach(sorm -> {
-      sorm.deleteAll(Player.class);
-      try {
-        sorm.insert(a, b, a, c);
-        failBecauseExceptionWasNotThrown(Exception.class);
-      } catch (Exception e) {
-        assertThat(e.getMessage()).contains("Unique index or primary key violation");
-      }
-      try {
-        sorm.insert(a, b, null);
-        failBecauseExceptionWasNotThrown(Exception.class);
-      } catch (Exception e) {
-        assertThat(e.getMessage()).contains("Fail to get value from");
-      }
-    });
+    sorms.forEach(
+        sorm -> {
+          sorm.deleteAll(Player.class);
+          try {
+            sorm.insert(a, b, a, c);
+            failBecauseExceptionWasNotThrown(Exception.class);
+          } catch (Exception e) {
+            assertThat(e.getMessage()).contains("Unique index or primary key violation");
+          }
+          try {
+            sorm.insert(a, b, null);
+            failBecauseExceptionWasNotThrown(Exception.class);
+          } catch (Exception e) {
+            assertThat(e.getMessage()).contains("Fail to get value from");
+          }
+        });
   }
 
   @Test
   void testMultiRowInsertMany() {
-    sorms.forEach(sorm -> sorm.insert(
-        Stream.generate(() -> SormTestUtils.GUEST_ALICE).limit(3000).collect(Collectors.toList())));
+    sorms.forEach(
+        sorm ->
+            sorm.insert(
+                Stream.generate(() -> SormTestUtils.GUEST_ALICE)
+                    .limit(3000)
+                    .collect(Collectors.toList())));
   }
 
   @Test
   void testMultiRowMerge() {
-    sorms.forEach(sorm -> sorm.merge(Stream.generate(() -> SormTestUtils.PLAYER_ALICE).limit(3000)
-        .collect(Collectors.toList())));
+    sorms.forEach(
+        sorm ->
+            sorm.merge(
+                Stream.generate(() -> SormTestUtils.PLAYER_ALICE)
+                    .limit(3000)
+                    .collect(Collectors.toList())));
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/OrmConfigStoreTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/OrmConfigStoreTest.java
index 34810be4..35e92110 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/OrmConfigStoreTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/OrmConfigStoreTest.java
@@ -28,12 +28,16 @@ class OrmConfigStoreTest {
   void testOrmConfigFail() {
 
     try {
-      SormContext.builder().setMultiRowProcessorFactory(MultiRowProcessorFactory.builder()
-          .setBatchSize(10).setMultiRowSize(20).setBatchSizeWithMultiRow(30).build());
+      SormContext.builder()
+          .setMultiRowProcessorFactory(
+              MultiRowProcessorFactory.builder()
+                  .setBatchSize(10)
+                  .setMultiRowSize(20)
+                  .setBatchSizeWithMultiRow(30)
+                  .build());
     } catch (Exception e) {
       assertThat(e).isInstanceOf(NullPointerException.class);
     }
-
   }
 
   @Test
@@ -41,15 +45,18 @@ void testOrmConfigStore() {
 
     ColumnValueToJavaObjectConverters rsc = DEFAULT_RESULT_SET_CONVERTER;
 
-    SormContext.builder().setColumnToFieldAccessorMapper(DEFAULT_COLUMN_FIELD_MAPPER)
-        .setTableNameMapper(DEFAULT_TABLE_NAME_MAPPER).setColumnValueToJavaObjectConverters(rsc)
+    SormContext.builder()
+        .setColumnToFieldAccessorMapper(DEFAULT_COLUMN_FIELD_MAPPER)
+        .setTableNameMapper(DEFAULT_TABLE_NAME_MAPPER)
+        .setColumnValueToJavaObjectConverters(rsc)
         .setSqlParametersSetter(DEFAULT_SQL_PARAMETER_SETTER)
         .setTableSqlFactory(new DefaultTableSqlFactory())
-        .setMultiRowProcessorFactory(MultiRowProcessorFactory.builder().setBatchSize(10)
-            .setMultiRowSize(20).setBatchSizeWithMultiRow(30).build())
+        .setMultiRowProcessorFactory(
+            MultiRowProcessorFactory.builder()
+                .setBatchSize(10)
+                .setMultiRowSize(20)
+                .setBatchSizeWithMultiRow(30)
+                .build())
         .build();
   }
-
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/SimpleBatchProcessorTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/SimpleBatchProcessorTest.java
index 28346ad9..7a8dd08d 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/SimpleBatchProcessorTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/mapping/multirow/SimpleBatchProcessorTest.java
@@ -24,31 +24,34 @@ class SimpleBatchProcessorTest {
   @BeforeAll
   static void setUp() {
     DataSource ds = SormTestUtils.createNewDatabaseDataSource();
-    SormContext context = SormContext.builder().setMultiRowProcessorFactory(MultiRowProcessorFactory
-        .builder().setMultiRowProcessorType(MultiRowProcessorType.SIMPLE_BATCH).build()).build();
+    SormContext context =
+        SormContext.builder()
+            .setMultiRowProcessorFactory(
+                MultiRowProcessorFactory.builder()
+                    .setMultiRowProcessorType(MultiRowProcessorType.SIMPLE_BATCH)
+                    .build())
+            .build();
     sorm = Sorm.create(ds, context);
   }
 
-
   @BeforeEach
   void setUpEach() {
     sorm = createSormWithNewDatabaseAndCreateTables();
   }
 
-
   @Test
   void testMultiRowInsert() {
     sorm.acceptHandler(conn -> conn.insert(PLAYER_ALICE, PLAYER_BOB));
-    sorm.acceptHandler(TRANSACTION_READ_COMMITTED, tr -> {
-      try {
-        tr.insert(PLAYER_ALICE, null);
-        failBecauseExceptionWasNotThrown(Exception.class);
-      } catch (Exception e) {
-        assertThat(e.getMessage()).contains("it is null");
-      }
-
-    });
-
+    sorm.acceptHandler(
+        TRANSACTION_READ_COMMITTED,
+        tr -> {
+          try {
+            tr.insert(PLAYER_ALICE, null);
+            failBecauseExceptionWasNotThrown(Exception.class);
+          } catch (Exception e) {
+            assertThat(e.getMessage()).contains("it is null");
+          }
+        });
   }
 
   @Test
@@ -59,9 +62,9 @@ void testMultiRowInsertMany() {
 
   @Test
   void testMultiRowMerge() {
-    sorm.acceptHandler(conn -> conn
-        .merge(Stream.generate(() -> PLAYER_ALICE).limit(3000).collect(Collectors.toList())));
+    sorm.acceptHandler(
+        conn ->
+            conn.merge(
+                Stream.generate(() -> PLAYER_ALICE).limit(3000).collect(Collectors.toList())));
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/result/TableMetaDataImplTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/result/TableMetaDataImplTest.java
index 517af142..c6fb1731 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/result/TableMetaDataImplTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/result/TableMetaDataImplTest.java
@@ -20,7 +20,5 @@ void testTableMetaDataImpl() {
 
     assertThat(metaData.getColumns()).containsAll(List.of("ID", "NAME", "ADDRESS"));
     assertThat(metaData.getPrimaryKeys()).containsAll(List.of("ID"));
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ArrayUtilsTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ArrayUtilsTest.java
index 9a81fdc1..21ef33d4 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ArrayUtilsTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ArrayUtilsTest.java
@@ -5,7 +5,6 @@
 
 class ArrayUtilsTest {
 
-
   @Test
   void testToObjectArrayBooleanArray() {
     assertThat(SystemPropertyUtils.getJavaProperties().toString()).contains("java");
@@ -17,34 +16,29 @@ void testToObjectArrayBooleanArray() {
   void testToObjectArrayByteArray() {
     assertThat(ArrayUtils.toObjectArray(new byte[] {(byte) 1, (byte) 2}))
         .isEqualTo(new Byte[] {(byte) 1, (byte) 2});
-
   }
 
   @Test
   void testToObjectArrayCharArray() {
     assertThat(ArrayUtils.toObjectArray(new char[] {'1', '2'}))
         .isEqualTo(new Character[] {'1', '2'});
-
   }
 
   @Test
   void testToObjectArrayDoubleArray() {
     assertThat(ArrayUtils.toObjectArray(new double[] {0.1, 0.2}))
         .isEqualTo(new Double[] {0.1, 0.2});
-
   }
 
   @Test
   void testToObjectArrayFloatArray() {
     assertThat(ArrayUtils.toObjectArray(new float[] {0.1f, 0.2f}))
         .isEqualTo(new Float[] {0.1f, 0.2f});
-
   }
 
   @Test
   void testToObjectArrayIntArray() {
     assertThat(ArrayUtils.toObjectArray(new int[] {1, 2})).isEqualTo(new Integer[] {1, 2});
-
   }
 
   @Test
@@ -58,7 +52,6 @@ void testToObjectArrayShortArray() {
         .isEqualTo(new Short[] {(short) 1, (short) 2});
   }
 
-
   @Test
   void testConvertToObjectArray() {
     assertThat(ArrayUtils.convertToObjectArray(new boolean[] {true}))
@@ -67,8 +60,6 @@ void testConvertToObjectArray() {
     assertThat(ArrayUtils.convertToObjectArray(new char[] {1})).isEqualTo(new Character[] {1});
     assertThat(ArrayUtils.convertToObjectArray(new short[] {1})).isEqualTo(new Short[] {1});
 
-
-
     assertThat(ArrayUtils.convertToObjectArray(new int[] {1})).isEqualTo(new Integer[] {1});
     assertThat(ArrayUtils.convertToObjectArray(new long[] {1})).isEqualTo(new Long[] {1L});
     assertThat(ArrayUtils.convertToObjectArray(new float[] {1})).isEqualTo(new Float[] {1f});
@@ -76,11 +67,9 @@ void testConvertToObjectArray() {
 
     assertThat(ArrayUtils.convertToObjectArray(new int[][] {{1, 2, 3}, {4, 5, 6}}))
         .isEqualTo(new Integer[][] {{1, 2, 3}, {4, 5, 6}});
-    assertThat(ArrayUtils
-        .convertToObjectArray(new int[][][] {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}}))
-            .isEqualTo(new Integer[][][] {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}});
-
+    assertThat(
+            ArrayUtils.convertToObjectArray(
+                new int[][][] {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}}))
+        .isEqualTo(new Integer[][][] {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}});
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ClassUtilsTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ClassUtilsTest.java
index f1f280cc..c1abfaea 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ClassUtilsTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ClassUtilsTest.java
@@ -9,21 +9,51 @@ class ClassUtilsTest {
   @Test
   void testConvertToClass() {
     Map> clazzes =
-        Map.of("java.lang.Boolean", Boolean.class, "java.lang.Character", Character.class,
-            "java.lang.Byte", Byte.class, "java.lang.Short", Short.class, "java.lang.Integer",
-            Integer.class, "java.lang.Long", Long.class, "java.lang.Float", Float.class,
-            "java.lang.Double", Double.class, "java.lang.Object", Object.class);
-
-    clazzes.entrySet()
+        Map.of(
+            "java.lang.Boolean",
+            Boolean.class,
+            "java.lang.Character",
+            Character.class,
+            "java.lang.Byte",
+            Byte.class,
+            "java.lang.Short",
+            Short.class,
+            "java.lang.Integer",
+            Integer.class,
+            "java.lang.Long",
+            Long.class,
+            "java.lang.Float",
+            Float.class,
+            "java.lang.Double",
+            Double.class,
+            "java.lang.Object",
+            Object.class);
+
+    clazzes
+        .entrySet()
         .forEach(en -> assertThat(ClassUtils.convertToClass(en.getKey())).isEqualTo(en.getValue()));
 
-    Map> primitives = Map.of("boolean", boolean.class, "char", char.class, "byte",
-        byte.class, "short", short.class, "int", int.class, "long", long.class, "float",
-        float.class, "double", double.class);
-
-    primitives.entrySet()
+    Map> primitives =
+        Map.of(
+            "boolean",
+            boolean.class,
+            "char",
+            char.class,
+            "byte",
+            byte.class,
+            "short",
+            short.class,
+            "int",
+            int.class,
+            "long",
+            long.class,
+            "float",
+            float.class,
+            "double",
+            double.class);
+
+    primitives
+        .entrySet()
         .forEach(en -> assertThat(ClassUtils.convertToClass(en.getKey())).isEqualTo(en.getValue()));
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ConcurrentCacheTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ConcurrentCacheTest.java
index d42989d0..d838d21f 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ConcurrentCacheTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ConcurrentCacheTest.java
@@ -17,7 +17,5 @@ void test() {
     assertThat(m.size()).isEqualTo(10);
     m.putAll(Map.of("b", "b"));
     assertThat(m.size()).isEqualTo(1);
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/DriverManagerDataSourceTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/DriverManagerDataSourceTest.java
index acfd69b7..39333e1b 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/DriverManagerDataSourceTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/DriverManagerDataSourceTest.java
@@ -69,5 +69,4 @@ void testGetLoginTimeout() {
       fail();
     }
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/JdbcTypeUtilsTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/JdbcTypeUtilsTest.java
index a86e5c73..ee14edb5 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/JdbcTypeUtilsTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/JdbcTypeUtilsTest.java
@@ -10,5 +10,4 @@ class JdbcTypeUtilsTest {
   void test() {
     assertThat(JdbcTypeUtils.convert(new int[] {4}).get(0)).isEqualTo(JDBCType.INTEGER);
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/MethodInvokerInfoUtilsTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/MethodInvokerInfoUtilsTest.java
index e691a483..88a71243 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/MethodInvokerInfoUtilsTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/MethodInvokerInfoUtilsTest.java
@@ -10,10 +10,9 @@ void testGetInvoker() {
     assertThat(MethodInvokerInfoUtils.getInvokerInfo(-1, new Throwable().getStackTrace()))
         .contains(MethodInvokerInfoUtilsTest.class.getName());
     assertThat(
-        MethodInvokerInfoUtils.getInvokerInfo(Integer.MAX_VALUE, new Throwable().getStackTrace()))
-            .isNotNull();
+            MethodInvokerInfoUtils.getInvokerInfo(
+                Integer.MAX_VALUE, new Throwable().getStackTrace()))
+        .isNotNull();
     System.out.println(MethodInvokerInfoUtils.getOutsideInvoker(""));
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ParameterizedStringUtilsTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ParameterizedStringUtilsTest.java
index ebeeddd8..836d39c3 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ParameterizedStringUtilsTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/ParameterizedStringUtilsTest.java
@@ -10,7 +10,5 @@ void testNewStringStringObjectArray() {
     Object[] params = {null, new Object[] {"a", null, new Object[] {1, null}}};
     assertThat(ParameterizedStringFormatter.LENGTH_256.format("{},{}", params))
         .isEqualTo("null,[a, null, [1, null]]]");
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/StringCacheTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/StringCacheTest.java
index 8ab17e9c..d50b6082 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/StringCacheTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/StringCacheTest.java
@@ -8,5 +8,4 @@ class StringCacheTest {
   void testClearAll() {
     StringCache.toCanonicalCase("hoge");
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/StringUtilsTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/StringUtilsTest.java
index f939ec7f..04b01b3f 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/StringUtilsTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/StringUtilsTest.java
@@ -12,12 +12,11 @@ void testContainsIgnoreCase() {
     assertThat(containsAsCanonical(List.of("a", "b"), null));
   }
 
-
   @Test
   void testFormat() {
     Object[] params = {};
     assertThat(ParameterizedStringFormatter.LENGTH_256.format("{}", params)).isEqualTo("{}");
-    assertThat(ParameterizedStringFormatter.LENGTH_256.format("{}", (Object[]) null)).isEqualTo("{}");
+    assertThat(ParameterizedStringFormatter.LENGTH_256.format("{}", (Object[]) null))
+        .isEqualTo("{}");
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/TryTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/TryTest.java
index b44f1201..bb7e6343 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/TryTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/TryTest.java
@@ -14,31 +14,38 @@ class TryTest {
 
   @Test
   void testGetOrDefault() {
-    String s = Try.getOrElse(() -> {
-      throw new RuntimeException("error");
-    }, "test");
+    String s =
+        Try.getOrElse(
+            () -> {
+              throw new RuntimeException("error");
+            },
+            "test");
     assertThat(s).isEqualTo("test");
   }
 
   @Test
   void testCreateRunnable() {
     try {
-      Try.createRunnable(() -> {
-        throw new RuntimeException("try");
-      }, e -> {
-      }).run();
+      Try.createRunnable(
+              () -> {
+                throw new RuntimeException("try");
+              },
+              e -> {})
+          .run();
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
-
   }
 
   @Test
   void testCreateSupplier() {
     try {
-      Try.createSupplier(() -> {
-        throw new RuntimeException("try");
-      }, e -> "").get();
+      Try.createSupplier(
+              () -> {
+                throw new RuntimeException("try");
+              },
+              e -> "")
+          .get();
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
@@ -47,109 +54,124 @@ void testCreateSupplier() {
   @Test
   void testCreateSupplierWithThrow() {
     try {
-      Try.createSupplierWithThrow(() -> {
-        throw new RuntimeException("try");
-      }, Try::rethrow).get();
+      Try.createSupplierWithThrow(
+              () -> {
+                throw new RuntimeException("try");
+              },
+              Try::rethrow)
+          .get();
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
-
   }
 
   @Test
   void testCreateConsumer() {
     try {
-      Try.createConsumer(con -> {
-        throw new RuntimeException("try");
-      }, e -> {
-      }).accept("a");
+      Try.createConsumer(
+              con -> {
+                throw new RuntimeException("try");
+              },
+              e -> {})
+          .accept("a");
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
   }
 
-
-
   @Test
   void testCreateConsumerWithThrow() {
     try {
-      Try.createConsumerWithThrow(con -> {
-        throw new RuntimeException("try");
-      }, Try::rethrow).accept("a");
+      Try.createConsumerWithThrow(
+              con -> {
+                throw new RuntimeException("try");
+              },
+              Try::rethrow)
+          .accept("a");
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
-    Try.createConsumerWithThrow(con -> {
-    }, Try::rethrow).accept("a");
+    Try.createConsumerWithThrow(con -> {}, Try::rethrow).accept("a");
   }
 
-
   @Test
   void testCreateFunction() {
     try {
-      Try.createFunction(con -> {
-        throw new RuntimeException("try");
-      }, e -> "").apply("a");
+      Try.createFunction(
+              con -> {
+                throw new RuntimeException("try");
+              },
+              e -> "")
+          .apply("a");
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
-
   }
 
   @Test
   void testCreateFunctionWithThrow() {
     try {
-      Try.createFunctionWithThrow(con -> {
-        throw new RuntimeException("try");
-      }, Try::rethrow).apply("a");
+      Try.createFunctionWithThrow(
+              con -> {
+                throw new RuntimeException("try");
+              },
+              Try::rethrow)
+          .apply("a");
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
-
   }
 
   @Test
   void testGetOrNull() {
-    Try.getOrElseNull(() -> {
-      throw new RuntimeException("try");
-    });
+    Try.getOrElseNull(
+        () -> {
+          throw new RuntimeException("try");
+        });
   }
 
   @Test
   void testGetOrThrow() {
     try {
-      Try.getOrElseThrow(() -> {
-        throw new RuntimeException("try");
-      }, Try::rethrow);
+      Try.getOrElseThrow(
+          () -> {
+            throw new RuntimeException("try");
+          },
+          Try::rethrow);
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
-    Try.getOrElseThrow(() -> {
-      return null;
-    }, Try::rethrow);
+    Try.getOrElseThrow(
+        () -> {
+          return null;
+        },
+        Try::rethrow);
   }
 
   @Test
   void testRunOrThrow() {
     try {
-      Try.runOrElseThrow(() -> {
-        throw new RuntimeException("try");
-      }, Try::rethrow);
+      Try.runOrElseThrow(
+          () -> {
+            throw new RuntimeException("try");
+          },
+          Try::rethrow);
     } catch (Exception e) {
       assertThat(e.getMessage()).contains("try");
     }
-    Try.runOrElseThrow(() -> {
-    }, Try::rethrow);
+    Try.runOrElseThrow(() -> {}, Try::rethrow);
   }
 
   @Test
   void testCreateBiConsumer() {
-    assertThrowsExactly(NullPointerException.class,
+    assertThrowsExactly(
+        NullPointerException.class,
         () -> Try.createBiConsumer(null, e -> Try.rethrow(e)).accept(null, null));
 
     AtomicInteger i = new AtomicInteger(0);
-    BiConsumer func = Try
-        .createBiConsumer((Integer a, Integer b) -> i.addAndGet(a + b), e -> System.err.println(e));
+    BiConsumer func =
+        Try.createBiConsumer(
+            (Integer a, Integer b) -> i.addAndGet(a + b), e -> System.err.println(e));
 
     func.accept(1, 2);
     assertThat(i.get()).isEqualTo(3);
@@ -157,26 +179,33 @@ void testCreateBiConsumer() {
 
   @Test
   void testCreateBiConsumerWithThrow() {
-    assertThrowsExactly(NullPointerException.class,
+    assertThrowsExactly(
+        NullPointerException.class,
         () -> Try.createBiConsumerWithThrow(null, e -> Try.rethrow(e)).accept(null, null));
 
     AtomicInteger i = new AtomicInteger(0);
-    BiConsumer func = Try.createBiConsumerWithThrow(
-        (Integer a, Integer b) -> i.addAndGet(a + b), e -> Try.rethrow(e));
+    BiConsumer func =
+        Try.createBiConsumerWithThrow(
+            (Integer a, Integer b) -> i.addAndGet(a + b), e -> Try.rethrow(e));
 
     func.accept(1, 2);
     assertThat(i.get()).isEqualTo(3);
 
-    assertThrowsExactly(IllegalAccessError.class,
-        () -> Try.createBiConsumerWithThrow((Integer a, Integer b) -> {
-          throw new IllegalAccessError();
-        }, e -> Try.rethrow(e)).accept(1, 2));
-
+    assertThrowsExactly(
+        IllegalAccessError.class,
+        () ->
+            Try.createBiConsumerWithThrow(
+                    (Integer a, Integer b) -> {
+                      throw new IllegalAccessError();
+                    },
+                    e -> Try.rethrow(e))
+                .accept(1, 2));
   }
 
   @Test
   void testCreateConsumer1() {
-    assertThrowsExactly(NullPointerException.class,
+    assertThrowsExactly(
+        NullPointerException.class,
         () -> Try.createConsumer(null, e -> Try.rethrow(e)).accept(null));
 
     AtomicInteger i = new AtomicInteger(0);
@@ -189,25 +218,36 @@ void testCreateConsumer1() {
 
   @Test
   void testCreateConsumerWithThrow1() {
-    assertThrowsExactly(NullPointerException.class,
+    assertThrowsExactly(
+        NullPointerException.class,
         () -> Try.createConsumerWithThrow(null, e -> Try.rethrow(e)).accept(null));
 
     AtomicInteger i = new AtomicInteger(0);
-    Consumer func = Try.createConsumerWithThrow((Integer a) -> {
-      i.addAndGet(a);
-    }, e -> Try.rethrow(e));
+    Consumer func =
+        Try.createConsumerWithThrow(
+            (Integer a) -> {
+              i.addAndGet(a);
+            },
+            e -> Try.rethrow(e));
 
     func.accept(2);
     assertThat(i.get()).isEqualTo(2);
 
-    assertThrowsExactly(IllegalAccessError.class, () -> Try.createConsumerWithThrow((Integer a) -> {
-      throw new IllegalAccessError();
-    }, e -> Try.rethrow(e)).accept(2));
+    assertThrowsExactly(
+        IllegalAccessError.class,
+        () ->
+            Try.createConsumerWithThrow(
+                    (Integer a) -> {
+                      throw new IllegalAccessError();
+                    },
+                    e -> Try.rethrow(e))
+                .accept(2));
   }
 
   @Test
   void testCreateFunction1() {
-    assertThrowsExactly(NullPointerException.class,
+    assertThrowsExactly(
+        NullPointerException.class,
         () -> Try.createFunction(null, e -> Try.rethrow(e)).apply(null));
 
     AtomicInteger i = new AtomicInteger(0);
@@ -219,7 +259,8 @@ void testCreateFunction1() {
 
   @Test
   void testCreateFunctionWithThrow1() {
-    assertThrowsExactly(NullPointerException.class,
+    assertThrowsExactly(
+        NullPointerException.class,
         () -> Try.createFunctionWithThrow(null, e -> Try.rethrow(e)).apply(null));
 
     AtomicInteger i = new AtomicInteger(0);
@@ -230,16 +271,21 @@ void testCreateFunctionWithThrow1() {
 
     assertThat(i.get()).isEqualTo(2);
 
-    assertThrowsExactly(IllegalAccessError.class, () -> Try.createConsumerWithThrow((Integer a) -> {
-      throw new IllegalAccessError();
-    }, e -> Try.rethrow(e)).accept(2));
-
+    assertThrowsExactly(
+        IllegalAccessError.class,
+        () ->
+            Try.createConsumerWithThrow(
+                    (Integer a) -> {
+                      throw new IllegalAccessError();
+                    },
+                    e -> Try.rethrow(e))
+                .accept(2));
   }
 
   @Test
   void testCreateRunnable1() {
-    assertThrowsExactly(NullPointerException.class,
-        () -> Try.createRunnable(null, e -> Try.rethrow(e)).run());
+    assertThrowsExactly(
+        NullPointerException.class, () -> Try.createRunnable(null, e -> Try.rethrow(e)).run());
 
     AtomicInteger i = new AtomicInteger(0);
     Runnable func = Try.createRunnable(() -> i.incrementAndGet(), e -> System.err.println(e));
@@ -250,7 +296,8 @@ void testCreateRunnable1() {
 
   @Test
   void testCreateRunnableWithThrow() {
-    assertThrowsExactly(NullPointerException.class,
+    assertThrowsExactly(
+        NullPointerException.class,
         () -> Try.createRunnableWithThrow(null, e -> Try.rethrow(e)).run());
 
     AtomicInteger i = new AtomicInteger(0);
@@ -259,15 +306,21 @@ void testCreateRunnableWithThrow() {
     func.run();
     assertThat(i.get()).isEqualTo(1);
 
-    assertThrowsExactly(IllegalAccessError.class, () -> Try.createRunnableWithThrow(() -> {
-      throw new IllegalAccessError();
-    }, e -> Try.rethrow(e)).run());
+    assertThrowsExactly(
+        IllegalAccessError.class,
+        () ->
+            Try.createRunnableWithThrow(
+                    () -> {
+                      throw new IllegalAccessError();
+                    },
+                    e -> Try.rethrow(e))
+                .run());
   }
 
   @Test
   void testCreateSupplier1() {
-    assertThrowsExactly(NullPointerException.class,
-        () -> Try.createSupplier(null, e -> Try.rethrow(e)).get());
+    assertThrowsExactly(
+        NullPointerException.class, () -> Try.createSupplier(null, e -> Try.rethrow(e)).get());
 
     AtomicInteger i = new AtomicInteger(0);
     Supplier func = Try.createSupplier(() -> i.incrementAndGet(), e -> -1);
@@ -277,7 +330,8 @@ void testCreateSupplier1() {
 
   @Test
   void testCreateSupplierWithThrow1() {
-    assertThrowsExactly(NullPointerException.class,
+    assertThrowsExactly(
+        NullPointerException.class,
         () -> Try.createRunnableWithThrow(null, e -> Try.rethrow(e)).run());
 
     AtomicInteger i = new AtomicInteger(0);
@@ -286,9 +340,15 @@ void testCreateSupplierWithThrow1() {
 
     assertThat(func.get()).isEqualTo(1);
 
-    assertThrowsExactly(IllegalAccessError.class, () -> Try.createSupplierWithThrow(() -> {
-      throw new IllegalAccessError();
-    }, e -> Try.rethrow(e)).get());
+    assertThrowsExactly(
+        IllegalAccessError.class,
+        () ->
+            Try.createSupplierWithThrow(
+                    () -> {
+                      throw new IllegalAccessError();
+                    },
+                    e -> Try.rethrow(e))
+                .get());
   }
 
   @Test
@@ -305,33 +365,29 @@ void testGetOrElseNull() {
 
   @Test
   void testGetOrElseThrow() {
-    assertThrowsExactly(NullPointerException.class,
-        () -> Try.getOrElseThrow(null, e -> Try.rethrow(e)));
+    assertThrowsExactly(
+        NullPointerException.class, () -> Try.getOrElseThrow(null, e -> Try.rethrow(e)));
     assertThat(Try.getOrElseThrow(() -> 2, e -> Try.rethrow(e))).isEqualTo(2);
   }
 
   @Test
   void testGetOrElseGet() {
-    assertThrowsExactly(NullPointerException.class,
-        () -> Try.getOrElseGet(null, e -> Try.rethrow(e)));
+    assertThrowsExactly(
+        NullPointerException.class, () -> Try.getOrElseGet(null, e -> Try.rethrow(e)));
     assertThat(Try.getOrElseGet(() -> 2, e -> 3)).isEqualTo(2);
   }
 
-
   @Test
   void testRunOrElseDo() {
-    assertThrowsExactly(NullPointerException.class,
-        () -> Try.runOrElseDo(null, e -> Try.rethrow(e)));
-    Try.runOrElseDo(() -> {
-    }, e -> Try.rethrow(e));
+    assertThrowsExactly(
+        NullPointerException.class, () -> Try.runOrElseDo(null, e -> Try.rethrow(e)));
+    Try.runOrElseDo(() -> {}, e -> Try.rethrow(e));
   }
 
   @Test
   void testRunOrElseThrow() {
-    assertThrowsExactly(NullPointerException.class,
-        () -> Try.runOrElseThrow(null, e -> Try.rethrow(e)));
-    Try.runOrElseThrow(() -> {
-    }, e -> Try.rethrow(e));
+    assertThrowsExactly(
+        NullPointerException.class, () -> Try.runOrElseThrow(null, e -> Try.rethrow(e)));
+    Try.runOrElseThrow(() -> {}, e -> Try.rethrow(e));
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/logger/SormLoggerTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/logger/SormLoggerTest.java
index 989d812d..910f1ad1 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/logger/SormLoggerTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/logger/SormLoggerTest.java
@@ -60,14 +60,14 @@ private static Appender addAppender(final Writer writer, final String writerName
     return appender;
   }
 
-
   @Test
   void testLogAfterQuery() {
     org.nkjmlab.sorm4j.util.logger.LoggerContext lc =
         org.nkjmlab.sorm4j.util.logger.LoggerContext.builder().enableAll().build();
 
-    Sorm sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables(
-        SormContext.builder().setLoggerContext(lc).build());
+    Sorm sorm =
+        SormTestUtils.createSormWithNewDatabaseAndCreateTables(
+            SormContext.builder().setLoggerContext(lc).build());
 
     Optional lp = lc.createLogPoint(Category.EXECUTE_QUERY, getClass());
     {
@@ -88,20 +88,26 @@ void testLogAfterQuery() {
 
     try (Connection conn = sorm.getJdbcConnection()) {
       {
-        String text = proc(stringWriter,
-            () -> lp.get().logBeforeMultiRow(conn, SormLoggerTest.class, 1, "players"));
+        String text =
+            proc(
+                stringWriter,
+                () -> lp.get().logBeforeMultiRow(conn, SormLoggerTest.class, 1, "players"));
         assertThat(text.length()).isLessThan(500);
         assertThat(text).contains("players");
       }
       {
-        String text = proc(stringWriter,
-            () -> lp.get().logBeforeSql(conn, ParameterizedSql.of("select * from players")));
+        String text =
+            proc(
+                stringWriter,
+                () -> lp.get().logBeforeSql(conn, ParameterizedSql.of("select * from players")));
         assertThat(text.length()).isLessThan(400);
         assertThat(text).contains("select * from players");
       }
       {
-        String text = proc(stringWriter,
-            () -> lp.get().logBeforeSql(conn, "select * from players where id=?", 1));
+        String text =
+            proc(
+                stringWriter,
+                () -> lp.get().logBeforeSql(conn, "select * from players where id=?", 1));
         assertThat(text.length()).isLessThan(450);
         assertThat(text).contains("select * from players where id=1");
       }
@@ -114,11 +120,8 @@ void testLogAfterQuery() {
       throw Try.rethrow(e);
     }
     appender.stop();
-
   }
 
-
-
   @Test
   void testLog4jSormLoggerOut() throws IOException {
     SormLogger logger = new Log4jSormLogger(org.apache.logging.log4j.LogManager.getLogger());
@@ -143,7 +146,6 @@ void testJulSormLoggerOut() throws IOException {
     System.setErr(syserr);
   }
 
-
   @Test
   void testLog4jSormLoggerError() {
     SormLogger logger = Log4jSormLogger.getLogger();
@@ -198,7 +200,6 @@ private void outTestHelper(SormLogger logger) throws IOException {
     }
   }
 
-
   private void outTestHelper(SormLogger logger, ByteArrayOutputStream target) throws IOException {
     {
       String text = proc(target, () -> logger.info("info test {}", 1));
@@ -253,7 +254,6 @@ private void errorTestHelper(SormLogger logger) {
       assertThat(text.length()).isLessThan(256);
       assertThat(text).contains("warn test 1");
     }
-
   }
 
   private void errorTestHelper(SormLogger logger, ByteArrayOutputStream target) {
@@ -277,10 +277,8 @@ private void errorTestHelper(SormLogger logger, ByteArrayOutputStream target) {
       assertThat(text.length()).isLessThan(256);
       assertThat(text).contains("warn test 1");
     }
-
   }
 
-
   private String proc(ByteArrayOutputStream target, Runnable run) {
     target.reset();
     run.run();
@@ -291,7 +289,5 @@ private String proc(StringWriter sw, Runnable run) {
     sw.getBuffer().delete(0, sw.getBuffer().length());
     run.run();
     return sw.toString();
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaDataTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaDataTest.java
index f5c83265..4adc2856 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaDataTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaDataTest.java
@@ -30,5 +30,4 @@ void test() {
     assertThat(md.getUserName()).isEqualTo("SA");
     assertThat(md.getJdbcDriverVersion()).isEqualTo("4.2");
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/RowMapTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/RowMapTest.java
index e1182426..3206bfae 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/RowMapTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/RowMapTest.java
@@ -13,8 +13,6 @@ class RowMapTest {
   @Test
   void testOf() {
 
-
-
     RowMap rm = RowMap.create();
     rm.put("key1", "value");
     RowMap rm1 = RowMap.create();
@@ -24,7 +22,6 @@ void testOf() {
 
     assertThat(rm.equals(rm1)).isTrue();
 
-
     assertThat(rm.containsKey("key1")).isTrue();
     assertThat(rm.containsValue("value")).isTrue();
     assertThat(rm.get("key1")).isEqualTo("value");
@@ -32,7 +29,6 @@ void testOf() {
     assertThat(rm.values()).containsExactlyInAnyOrder("value");
     assertThat(rm.entrySet().toString()).isEqualTo("[KEY1=value]");
 
-
     assertThat(rm.size()).isEqualTo(1);
     assertThat(rm.isEmpty()).isFalse();
 
@@ -58,7 +54,6 @@ void testOf() {
     rm.put("arr", arr);
     assertThat(rm.get("arr").equals(arr)).isTrue();
 
-
     LocalDate ld = LocalDate.parse("2022-11-16");
     LocalTime lt = LocalTime.parse("12:01:02");
     LocalDateTime ldt = LocalDateTime.parse("2022-11-16T12:01:02");
@@ -70,10 +65,8 @@ void testOf() {
     assertThat(rm.getLocalTime("local_time")).isEqualTo(lt);
     assertThat(rm.getLocalDate("local_date")).isEqualTo(ld);
 
-
     byte[] by = "aaa".getBytes();
     rm.put("by", by);
     assertThat(rm.getString("by").equals("aaa")).isTrue();
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/NamedParameterSqlTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/NamedParameterSqlTest.java
index 027b30a8..949fe72c 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/NamedParameterSqlTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/NamedParameterSqlTest.java
@@ -15,9 +15,9 @@ class NamedParameterSqlTest {
   private Map namedParams = Map.of("name", "foo", "id", 1, "idid", 2);
 
   private static Sorm sorm = createSormWithNewDatabaseAndCreateTables();
+
   static {
     sorm.applyHandler(conn -> conn.insert(GUEST_ALICE, GUEST_BOB, GUEST_CAROL, GUEST_DAVE));
-
   }
 
   @Test
@@ -29,9 +29,10 @@ void testCustomer() {
       sorm.readList(Guest.class, statement);
     }
     {
-      ParameterizedSql statement = NamedParameterSqlParser.parse(
-          "select * from guests where name like {:name} and address in(<:address>) and id=:id",
-          Map.of("id", 1, "address", List.of("Tokyo", "Kyoto"), "name", "'A%'"));
+      ParameterizedSql statement =
+          NamedParameterSqlParser.parse(
+              "select * from guests where name like {:name} and address in(<:address>) and id=:id",
+              Map.of("id", 1, "address", List.of("Tokyo", "Kyoto"), "name", "'A%'"));
       sorm.applyHandler(conn -> conn.readList(Customer.class, statement));
     }
   }
@@ -72,22 +73,27 @@ void testBind() {
   @Test
   void testBindList() {
 
-    ParameterizedSql sp = NamedParameterSqlParser.of("select * from where ID in(<:player_names_1>)")
-        .bind("player_names_1", List.of("foo", "bar")).parse();
+    ParameterizedSql sp =
+        NamedParameterSqlParser.of("select * from where ID in(<:player_names_1>)")
+            .bind("player_names_1", List.of("foo", "bar"))
+            .parse();
 
     assertThat(sp.getSql()).contains("?,?");
     assertThat(sp.getParameters()[0]).isEqualTo("foo");
     assertThat(sp.getParameters()[1]).isEqualTo("bar");
-
   }
 
   @Test
   void testBindListFail() {
-    assertThatThrownBy(() -> NamedParameterSqlParser
-        .of("select * from where ID in(<:names>)")
-        .bind("names", "foo").parse()).isInstanceOfSatisfying(SormException.class,
-            e -> assertThat(e.getMessage())
-                .isEqualTo(" parameter should be bind Collection or Array"));
+    assertThatThrownBy(
+            () ->
+                NamedParameterSqlParser.of("select * from where ID in(<:names>)")
+                    .bind("names", "foo")
+                    .parse())
+        .isInstanceOfSatisfying(
+            SormException.class,
+            e ->
+                assertThat(e.getMessage())
+                    .isEqualTo(" parameter should be bind Collection or Array"));
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/OrderedParameterSqlTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/OrderedParameterSqlTest.java
index 6b889d9c..cc195df2 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/OrderedParameterSqlTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/OrderedParameterSqlTest.java
@@ -9,16 +9,18 @@
 
 class OrderedParameterSqlTest {
   private static Sorm sorm = createSormWithNewDatabaseAndCreateTables();
+
   static {
     sorm.applyHandler(conn -> conn.insert(GUEST_ALICE, GUEST_BOB, GUEST_CAROL, GUEST_DAVE));
-
   }
 
   @Test
   void testParse() {
     ParameterizedSql statement =
-        OrderedParameterSqlParser.parse("select * from guests where name like {?} and address in()",
-            "'A%'", List.of(GUEST_ALICE.getAddress(), GUEST_BOB.getAddress()));
+        OrderedParameterSqlParser.parse(
+            "select * from guests where name like {?} and address in()",
+            "'A%'",
+            List.of(GUEST_ALICE.getAddress(), GUEST_BOB.getAddress()));
     assertThat(statement.getSql())
         .isEqualTo("select * from guests where name like 'A%' and address in(?,?)");
     assertThat(Arrays.asList(statement.getParameters()))
@@ -28,7 +30,8 @@ void testParse() {
   // @Test
   // void testToSqlStatementStringObjectArray() {
   // String sql = "select * from customer where id=? and address=?";
-  // ParameterizedSql statement = OrderedParameterSqlParser.from(sql).addParameter(1, "Kyoto").parse();
+  // ParameterizedSql statement = OrderedParameterSqlParser.from(sql).addParameter(1,
+  // "Kyoto").parse();
   // System.out.println(statement);
   // // assertThat(sqlSt.getParameters().length).isEqualTo(1);
   // // assertThat(sqlSt.getParameters()[0]).isEqualTo("'alice', 1");
@@ -37,7 +40,8 @@ void testParse() {
   //
   // @Test
   // void testToSqlStatementStringObject() {
-  // ParameterizedSql sqlSt = OrderedParameterSqlParser.parse("select * from a where id=? and id=?", 1,
+  // ParameterizedSql sqlSt = OrderedParameterSqlParser.parse("select * from a where id=? and id=?",
+  // 1,
   // 2);
   // assertThat(sqlSt.getParameters().length).isEqualTo(2);
   // assertThat(sqlSt.getParameters()[0]).isEqualTo(1);
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/ParameterizedSqlTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/ParameterizedSqlTest.java
index 797c6e1b..4350825f 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/ParameterizedSqlTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/sql/ParameterizedSqlTest.java
@@ -48,8 +48,6 @@ void testEmbeddedOrdered() {
     Object[] params = {1};
     assertThat(ParameterizedSqlParser.embedParameter(sql, params))
         .contains("select * from guest where id=1");
-
-
   }
 
   @Test
@@ -65,9 +63,10 @@ void testEmbeddedMap() {
   void testEmbeddedOrderFail() {
     String sql = "select * from guest where id={?}";
 
-    assertThatThrownBy(() -> ParameterizedSqlParser.embedParameter(sql)).isInstanceOfSatisfying(
-        SormException.class,
-        e -> assertThat(e.getMessage()).contains("Could not embed all parameters"));
+    assertThatThrownBy(() -> ParameterizedSqlParser.embedParameter(sql))
+        .isInstanceOfSatisfying(
+            SormException.class,
+            e -> assertThat(e.getMessage()).contains("Could not embed all parameters"));
   }
 
   @Test
@@ -75,11 +74,9 @@ void testEmbeddedMapFail() {
 
     String sql = "select * from guest where name={:name} and id={:id}";
 
-
     assertThatThrownBy(() -> ParameterizedSqlParser.embedParameter(sql, Map.of("name1", 1)))
-        .isInstanceOfSatisfying(SormException.class,
+        .isInstanceOfSatisfying(
+            SormException.class,
             e -> assertThat(e.getMessage()).contains("Could not embed all parameters"));
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableSchemaKeywordTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableSchemaKeywordTest.java
index 1ba43e9e..ddc8534b 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableSchemaKeywordTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableSchemaKeywordTest.java
@@ -20,5 +20,4 @@ void testDecimalInt() {
   void testDecimalIntInt() {
     assertThat(decimal(1, 2)).isEqualTo(" decimal(1,2) ");
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableSchemaTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableSchemaTest.java
index 57be7dce..765b714e 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableSchemaTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableSchemaTest.java
@@ -17,45 +17,66 @@ class TableSchemaTest {
   static class TempGuestTable {
 
     public static enum Column {
-      ID, NAME, TEL
+      ID,
+      NAME,
+      TEL
     }
 
     private final TableDefinition schema;
 
     public TempGuestTable() {
-      this.schema = TableDefinition.builder("temp_guests").addColumnDefinition(ID, INT)
-          .addColumnDefinition(NAME, VARCHAR).addColumnDefinition(TEL, VARCHAR)
-          .addUniqueConstraint(TEL).addIndexDefinition(TEL).setPrimaryKey(ID).build();
+      this.schema =
+          TableDefinition.builder("temp_guests")
+              .addColumnDefinition(ID, INT)
+              .addColumnDefinition(NAME, VARCHAR)
+              .addColumnDefinition(TEL, VARCHAR)
+              .addUniqueConstraint(TEL)
+              .addIndexDefinition(TEL)
+              .setPrimaryKey(ID)
+              .build();
     }
-
   }
 
   @Test
   void testSchemeBuilder() {
-    TableDefinition schema1 = TableDefinition.builder("temp_guests")
-        .addColumnDefinition(ID.name(), INT).addColumnDefinition(NAME.name(), VARCHAR)
-        .addColumnDefinition(TEL.name(), VARCHAR).addUniqueConstraint(TEL.name())
-        .addIndexDefinition(TEL.name()).setPrimaryKey(ID.name()).build();
-
-    TableDefinition schema2 = TableDefinition.builder("temp_guests").addColumnDefinition(ID, INT)
-        .addColumnDefinition(NAME, VARCHAR).addColumnDefinition(TEL, VARCHAR)
-        .addUniqueConstraint(TEL).addIndexDefinition(TEL).setPrimaryKey(ID).build();
-
-    assertThat(schema1.getTableNameAndColumnDefinitions()).isEqualTo(schema2.getTableNameAndColumnDefinitions());
-
+    TableDefinition schema1 =
+        TableDefinition.builder("temp_guests")
+            .addColumnDefinition(ID.name(), INT)
+            .addColumnDefinition(NAME.name(), VARCHAR)
+            .addColumnDefinition(TEL.name(), VARCHAR)
+            .addUniqueConstraint(TEL.name())
+            .addIndexDefinition(TEL.name())
+            .setPrimaryKey(ID.name())
+            .build();
+
+    TableDefinition schema2 =
+        TableDefinition.builder("temp_guests")
+            .addColumnDefinition(ID, INT)
+            .addColumnDefinition(NAME, VARCHAR)
+            .addColumnDefinition(TEL, VARCHAR)
+            .addUniqueConstraint(TEL)
+            .addIndexDefinition(TEL)
+            .setPrimaryKey(ID)
+            .build();
+
+    assertThat(schema1.getTableNameAndColumnDefinitions())
+        .isEqualTo(schema2.getTableNameAndColumnDefinitions());
   }
 
   @Test
   void testSchemeBuilder2() {
-    TableDefinition.builder("temp_guests").addColumnDefinition(ID.name(), INT)
-        .addUniqueConstraint(new String[0]).setPrimaryKey(new String[0]).build();
+    TableDefinition.builder("temp_guests")
+        .addColumnDefinition(ID.name(), INT)
+        .addUniqueConstraint(new String[0])
+        .setPrimaryKey(new String[0])
+        .build();
   }
 
-
   @Test
   void testGetColumnNames() {
-    assertThat(tempGuestTable.schema.getColumnNames()).containsExactlyInAnyOrder(
-        Stream.of(ID, NAME, TEL).map(e -> e.name()).toArray(String[]::new));
+    assertThat(tempGuestTable.schema.getColumnNames())
+        .containsExactlyInAnyOrder(
+            Stream.of(ID, NAME, TEL).map(e -> e.name()).toArray(String[]::new));
   }
 
   @Test
@@ -65,8 +86,9 @@ void testGetName() {
 
   @Test
   void testGetTableSchema() {
-    assertThat(tempGuestTable.schema.getTableNameAndColumnDefinitions()).isEqualToIgnoringCase(
-        "temp_guests(id int, name varchar, tel varchar, primary key(id), unique(tel))");
+    assertThat(tempGuestTable.schema.getTableNameAndColumnDefinitions())
+        .isEqualToIgnoringCase(
+            "temp_guests(id int, name varchar, tel varchar, primary key(id), unique(tel))");
   }
 
   @Test
@@ -76,7 +98,6 @@ void testGetIndexSchema() {
             "CREATE INDEX IF NOT EXISTS index_in_temp_guests_on_tel ON temp_guests(tel)");
   }
 
-
   @Test
   void testCreate() {
     tempGuestTable.schema.createTableIfNotExists(sorm);
@@ -85,6 +106,4 @@ void testCreate() {
     tempGuestTable.schema.dropTableIfExists(sorm);
     tempGuestTable.schema.createTableIfNotExists(sorm).createIndexesIfNotExists(sorm);
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableTest.java
index 29b70fcf..edf41874 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/table/TableTest.java
@@ -30,7 +30,6 @@ void setUp() {
     playersTable = createPlayersTable(sorm);
     sportsTable = createSportsTable(sorm);
     createGuestsTable(sorm);
-
   }
 
   @Test
@@ -166,9 +165,10 @@ void testDeleteListOfT() {
 
     playersTable.delete(List.of(PLAYER_ALICE));
     assertThat(
-        playersTable.getOrm().readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
-            .isEqualTo(1);
-
+            playersTable
+                .getOrm()
+                .readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
+        .isEqualTo(1);
   }
 
   @Test
@@ -178,8 +178,10 @@ void testDeleteT() {
     playersTable.merge(PLAYER_ALICE);
     playersTable.delete(PLAYER_ALICE);
     assertThat(
-        playersTable.getOrm().readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
-            .isEqualTo(0);
+            playersTable
+                .getOrm()
+                .readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
+        .isEqualTo(0);
     playersTable.insertAndGet(PLAYER_BOB);
     RowMap rm1 = RowMap.of("id", 111, "name", "name1", "address", "address1");
     RowMap rm2 = RowMap.of("id", 112, "name", "name2", "address", "address2");
@@ -187,7 +189,6 @@ void testDeleteT() {
     playersTable.insertMapIn(rm1);
     assertThat(playersTable.exists(111)).isTrue();
     playersTable.insertMapIn(List.of(rm2, rm3));
-
   }
 
   @Test
@@ -195,12 +196,16 @@ void testDeleteByPrimaryKey() {
     playersTable.insert(PLAYER_ALICE);
     playersTable.insert(PLAYER_BOB);
     assertThat(
-        playersTable.getOrm().readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
-            .isEqualTo(2);
+            playersTable
+                .getOrm()
+                .readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
+        .isEqualTo(2);
     playersTable.deleteByPrimaryKey(PLAYER_ALICE.id);
     assertThat(
-        playersTable.getOrm().readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
-            .isEqualTo(1);
+            playersTable
+                .getOrm()
+                .readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
+        .isEqualTo(1);
   }
 
   @Test
@@ -214,21 +219,23 @@ void testUpdateByPrimaryKey() {
     assertThat(playersTable.selectByPrimaryKey(PLAYER_BOB.id).getName()).isEqualTo("bbb");
   }
 
-
   @Test
   void testDeleteByPrimaryKeyIn() {
     playersTable.insert(PLAYER_ALICE);
     playersTable.insert(PLAYER_BOB);
     assertThat(
-        playersTable.getOrm().readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
-            .isEqualTo(2);
+            playersTable
+                .getOrm()
+                .readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
+        .isEqualTo(2);
     playersTable.deleteByPrimaryKeyIn(playersTable.getTableName(), PLAYER_ALICE.id);
     assertThat(
-        playersTable.getOrm().readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
-            .isEqualTo(1);
+            playersTable
+                .getOrm()
+                .readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
+        .isEqualTo(1);
   }
 
-
   @Test
   void testDeleteTArray() {
     playersTable.insert(new Player[] {PLAYER_ALICE});
@@ -236,8 +243,10 @@ void testDeleteTArray() {
     playersTable.merge(new Player[] {PLAYER_ALICE});
     playersTable.delete(new Player[] {PLAYER_ALICE});
     assertThat(
-        playersTable.getOrm().readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
-            .isEqualTo(0);
+            playersTable
+                .getOrm()
+                .readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
+        .isEqualTo(0);
     playersTable.insertAndGet(new Player[] {PLAYER_BOB});
   }
 
@@ -246,8 +255,10 @@ void testDeleteAll() {
     playersTable.insert(PLAYER_ALICE);
     playersTable.deleteAll();
     assertThat(
-        playersTable.getOrm().readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
-            .isEqualTo(0);
+            playersTable
+                .getOrm()
+                .readOne(Integer.class, selectCountFrom(playersTable.getTableName())))
+        .isEqualTo(0);
   }
 
   @Test
@@ -276,7 +287,6 @@ void testSelectListAllEqual() {
         .isEqualTo(PLAYER_ALICE.getId());
   }
 
-
   @Test
   void testJoin() {
     playersTable.insert(PLAYER_ALICE);
@@ -288,11 +298,14 @@ void testJoin() {
         .isEqualTo(PLAYER_ALICE.getId());
 
     JoinSql.builder(playersTable.getOrm().getTableMetaData(Player.class));
-    assertThat(playersTable
-        .join(sportsTable, playersTable.joinSqlBuilder().joinUsing(sportsTable, "id").build())
-        .get(0).getT1().getId()).isEqualTo(PLAYER_ALICE.getId());
-
-
+    assertThat(
+            playersTable
+                .join(
+                    sportsTable, playersTable.joinSqlBuilder().joinUsing(sportsTable, "id").build())
+                .get(0)
+                .getT1()
+                .getId())
+        .isEqualTo(PLAYER_ALICE.getId());
   }
 
   @Test
@@ -310,9 +323,9 @@ void testStream() {
 
     int ret = playersTable.streamAll().apply(stream -> stream.collect(Collectors.toList())).size();
     assertThat(ret).isEqualTo(1);
-    List ret1 = playersTable.stream(ParameterizedSql.of("select * from players"))
-        .apply(stream -> stream.collect(Collectors.toList()));
+    List ret1 =
+        playersTable.stream(ParameterizedSql.of("select * from players"))
+            .apply(stream -> stream.collect(Collectors.toList()));
     assertThat(ret1.size()).isEqualTo(1);
-
   }
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Customer.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Customer.java
index 190a5314..217cafea 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Customer.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Customer.java
@@ -10,7 +10,6 @@ public class Customer {
   public static final Customer CAROL = new Customer(3, "Carol", "Kyoto");
   public static final Customer DAVE = new Customer(4, "Dave", "Nara");
 
-
   public static final String CREATE_TABLE_SQL =
       "CREATE TABLE IF NOT EXISTS customer (id INT PRIMARY KEY, name VARCHAR, address VARCHAR)";
 
@@ -27,7 +26,6 @@ public Customer(int id, String name, String address) {
     this.address = address;
   }
 
-
   public String getAddress() {
     return address;
   }
@@ -44,6 +42,4 @@ public String toString() {
   public void setName(String name) {
     this.name = name;
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Guest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Guest.java
index 6222a360..1e9841e3 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Guest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Guest.java
@@ -26,17 +26,14 @@ public Guest(int id, String name, String address) {
     this.address = address;
   }
 
-
   public int getId() {
     return id;
   }
 
-
   public String getAddress() {
     return address;
   }
 
-
   public String getName() {
     return name;
   }
@@ -53,18 +50,15 @@ public int hashCode() {
 
   @Override
   public boolean equals(Object obj) {
-    if (this == obj)
-      return true;
-    if (!(obj instanceof Guest))
-      return false;
+    if (this == obj) return true;
+    if (!(obj instanceof Guest)) return false;
     Guest other = (Guest) obj;
-    return Objects.equals(address, other.address) && id == other.id
+    return Objects.equals(address, other.address)
+        && id == other.id
         && Objects.equals(name, other.name);
   }
 
   public void setId(int id) {
     this.id = id;
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Player.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Player.java
index 8458844f..a515073f 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Player.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Player.java
@@ -20,18 +20,15 @@ public Player(int id, String name, String address) {
     this.address = address;
   }
 
-
   public int getId() {
     return id;
   }
 
-
   // not match address field
   public String readAddress() {
     return address;
   }
 
-
   public String getName() {
     return name;
   }
@@ -52,14 +49,11 @@ public int hashCode() {
 
   @Override
   public boolean equals(Object obj) {
-    if (this == obj)
-      return true;
-    if (!(obj instanceof Player))
-      return false;
+    if (this == obj) return true;
+    if (!(obj instanceof Player)) return false;
     Player other = (Player) obj;
-    return Objects.equals(address, other.address) && id == other.id
+    return Objects.equals(address, other.address)
+        && id == other.id
         && Objects.equals(name, other.name);
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/SormTestUtils.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/SormTestUtils.java
index 2f0bf252..65132045 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/SormTestUtils.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/SormTestUtils.java
@@ -11,51 +11,36 @@
 
 public class SormTestUtils {
 
-  /**
-   * Guest("Alice", "Kyoto")
-   */
+  /** Guest("Alice", "Kyoto") */
   public static final Guest GUEST_ALICE = new Guest("Alice", "Kyoto");
-  /**
-   * Guest("Bob", "Tokyo")
-   */
+  /** Guest("Bob", "Tokyo") */
   public static final Guest GUEST_BOB = new Guest("Bob", "Tokyo");
-  /**
-   * Guest("Carol", "Osaka")
-   */
+  /** Guest("Carol", "Osaka") */
   public static final Guest GUEST_CAROL = new Guest("Carol", "Osaka");
-  /**
-   * Guest("Dave", "Nara")
-   */
+  /** Guest("Dave", "Nara") */
   public static final Guest GUEST_DAVE = new Guest("Dave", "Nara");
 
-
-  /**
-   * Player(1, "Alice", "Kyoto")
-   */
+  /** Player(1, "Alice", "Kyoto") */
   public static final Player PLAYER_ALICE = new Player(1, "Alice", "Kyoto");
-  /**
-   * Player(2, "Bob", "Tokyo")
-   */
+  /** Player(2, "Bob", "Tokyo") */
   public static final Player PLAYER_BOB = new Player(2, "Bob", "Tokyo");
-  /**
-   * Player(3, "Carol", "Osaka")
-   */
+  /** Player(3, "Carol", "Osaka") */
   public static final Player PLAYER_CAROL = new Player(3, "Carol", "Osaka");
-  /**
-   * Player(4, "Dave", "Nara")
-   */
+  /** Player(4, "Dave", "Nara") */
   public static final Player PLAYER_DAVE = new Player(4, "Dave", "Nara");
 
-
   public static final Sport TENNIS = new Sport(1, Sport.Sports.TENNIS);
   public static final Sport SOCCER = new Sport(2, Sport.Sports.SOCCER);
 
   public static TableWithDefinition createGuestsTable(Sorm sorm) {
-    TableDefinition schema = TableDefinition.builder("guests")
-        .addColumnDefinition("id", INT, AUTO_INCREMENT, PRIMARY_KEY)
-        .addColumnDefinition("name", VARCHAR).addColumnDefinition("address", VARCHAR)
-        .addIndexDefinition("name").addIndexDefinition("name").build();
-
+    TableDefinition schema =
+        TableDefinition.builder("guests")
+            .addColumnDefinition("id", INT, AUTO_INCREMENT, PRIMARY_KEY)
+            .addColumnDefinition("name", VARCHAR)
+            .addColumnDefinition("address", VARCHAR)
+            .addIndexDefinition("name")
+            .addIndexDefinition("name")
+            .build();
 
     BasicTableWithDefinition tbl = new BasicTableWithDefinition<>(sorm, Guest.class, schema);
     tbl.dropTableIfExists().createTableIfNotExists().createIndexesIfNotExists();
@@ -69,64 +54,72 @@ public static TableWithDefinition createPlayersTable(Sorm sorm) {
   public static TableWithDefinition createPlayersTable(Sorm sorm, String tableName) {
 
     TableDefinition schema =
-        TableDefinition.builder(tableName).addColumnDefinition("id", INT, PRIMARY_KEY)
-            .addColumnDefinition("name", VARCHAR).addColumnDefinition("address", VARCHAR)
-            .addIndexDefinition("name").addIndexDefinition("name").build();
-
-    TableWithDefinition tbl = new TableWithDefinition<>() {
-
-      @Override
-      public TableDefinition getTableDefinition() {
-        return schema;
-      }
-
-      @Override
-      public Class getValueType() {
-        return Player.class;
-      }
-
-      @Override
-      public Sorm getOrm() {
-        return sorm;
-      }
-
-      @Override
-      public String getTableName() {
-        return schema.getTableName();
-      }
-    };
+        TableDefinition.builder(tableName)
+            .addColumnDefinition("id", INT, PRIMARY_KEY)
+            .addColumnDefinition("name", VARCHAR)
+            .addColumnDefinition("address", VARCHAR)
+            .addIndexDefinition("name")
+            .addIndexDefinition("name")
+            .build();
+
+    TableWithDefinition tbl =
+        new TableWithDefinition<>() {
+
+          @Override
+          public TableDefinition getTableDefinition() {
+            return schema;
+          }
+
+          @Override
+          public Class getValueType() {
+            return Player.class;
+          }
+
+          @Override
+          public Sorm getOrm() {
+            return sorm;
+          }
+
+          @Override
+          public String getTableName() {
+            return schema.getTableName();
+          }
+        };
     tbl.dropTableIfExists();
     tbl.createTableIfNotExists().createIndexesIfNotExists();
     return tbl;
   }
 
   public static TableWithDefinition createSportsTable(Sorm sorm) {
-    TableDefinition schema = TableDefinition.builder("sports")
-        .addColumnDefinition("id", INT, PRIMARY_KEY).addColumnDefinition("name", VARCHAR).build();
-
-    TableWithDefinition tbl = new TableWithDefinition<>() {
-
-      @Override
-      public TableDefinition getTableDefinition() {
-        return schema;
-      }
-
-      @Override
-      public Class getValueType() {
-        return Sport.class;
-      }
-
-      @Override
-      public Sorm getOrm() {
-        return sorm;
-      }
-    };
+    TableDefinition schema =
+        TableDefinition.builder("sports")
+            .addColumnDefinition("id", INT, PRIMARY_KEY)
+            .addColumnDefinition("name", VARCHAR)
+            .build();
+
+    TableWithDefinition tbl =
+        new TableWithDefinition<>() {
+
+          @Override
+          public TableDefinition getTableDefinition() {
+            return schema;
+          }
+
+          @Override
+          public Class getValueType() {
+            return Sport.class;
+          }
+
+          @Override
+          public Sorm getOrm() {
+            return sorm;
+          }
+        };
     tbl.dropTableIfExists();
     tbl.createTableIfNotExists().createIndexesIfNotExists();
     return tbl;
   }
 
-
   public static Sorm createSormWithNewDatabaseAndCreateTables(SormContext sormContext) {
     Sorm sorm = createSormWithNewDatabase(sormContext);
     dropAndCreateSportsTable(sorm);
@@ -135,7 +128,6 @@ public static Sorm createSormWithNewDatabaseAndCreateTables(SormContext sormCont
     return sorm;
   }
 
-
   public static Sorm createSormWithNewDatabaseAndCreateTables() {
     return createSormWithNewDatabaseAndCreateTables(SormContext.builder().build());
   }
@@ -147,8 +139,10 @@ public static Sorm createSormWithNewContext() {
   private static final AtomicInteger urlSuffuix = new AtomicInteger();
 
   public static DriverManagerDataSource createNewDatabaseDataSource() {
-    final String JDBC_URL = "jdbc:h2:mem:test" + urlSuffuix.incrementAndGet()
-        + ";DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE";
+    final String JDBC_URL =
+        "jdbc:h2:mem:test"
+            + urlSuffuix.incrementAndGet()
+            + ";DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE";
     final String USER = "sa";
     final String PASSWORD = "";
     return DriverManagerDataSource.create(JDBC_URL, USER, PASSWORD);
@@ -160,7 +154,6 @@ private static Sorm createSormWithNewDatabase(SormContext sormContext) {
 
   private static void dropAndCreateSportsTable(Sorm sorm) {
     createSportsTable(sorm).dropTableIfExists().createTableIfNotExists().createIndexesIfNotExists();
-
   }
 
   private static void dropAndCreateGuestTable(Sorm sorm) {
@@ -168,10 +161,13 @@ private static void dropAndCreateGuestTable(Sorm sorm) {
   }
 
   private static void dropAndCreatePlayerTable(Sorm sorm) {
-    createPlayersTable(sorm, "players").dropTableIfExists().createTableIfNotExists()
+    createPlayersTable(sorm, "players")
+        .dropTableIfExists()
+        .createTableIfNotExists()
         .createIndexesIfNotExists();
-    createPlayersTable(sorm, "players1").dropTableIfExists().createTableIfNotExists()
+    createPlayersTable(sorm, "players1")
+        .dropTableIfExists()
+        .createTableIfNotExists()
         .createIndexesIfNotExists();
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Sport.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Sport.java
index 8604a202..744ae049 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Sport.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/Sport.java
@@ -6,7 +6,8 @@
 public class Sport {
 
   public enum Sports {
-    TENNIS, SOCCER
+    TENNIS,
+    SOCCER
   }
 
   private int id;
@@ -17,7 +18,6 @@ public Sport(int id, Sports name) {
     this.name = name;
   }
 
-
   public int getId() {
     return id;
   }
@@ -30,5 +30,4 @@ public Sports getName() {
   public String toString() {
     return "Sport [id=" + id + ", name=" + name + "]";
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/TestUtils.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/TestUtils.java
index 5cfd152e..1cd4c4e7 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/TestUtils.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/TestUtils.java
@@ -54,7 +54,5 @@ public class TestUtils {
   public static final OffsetTime[] OFFSET_TIME_ARRAY = {OffsetTime.now()};
   public static final OffsetDateTime[] OFFSET_DATE_TIME_ARRAY = {OffsetDateTime.now()};
 
-
   public static final Object[] OBJECT_ARRAY = new Object[] {new File("./")};
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/command/CommandTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/command/CommandTest.java
index 83c9144c..6cc8cf70 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/command/CommandTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/command/CommandTest.java
@@ -29,153 +29,191 @@ void setUp() {
 
   @Test
   void testAcceptPreparedStatementHandler() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
-      conn.executeQuery(con -> {
-        PreparedStatement stmt = con.prepareStatement("select * from guests where id=?");
-        stmt.setInt(1, 1);
-        return stmt;
-      }, conn.getRowMapper(Guest.class));
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
+          conn.executeQuery(
+              con -> {
+                PreparedStatement stmt = con.prepareStatement("select * from guests where id=?");
+                stmt.setInt(1, 1);
+                return stmt;
+              },
+              conn.getRowMapper(Guest.class));
+        });
   }
 
   @Test
   void testApplyPreparedStatementHandler() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
-
-      conn.executeQuery(con -> {
-        PreparedStatement stmt = con.prepareStatement("select * from guests where id=?");
-        stmt.setInt(1, 1);
-        return stmt;
-      }, conn.getResultSetTraverser(RowMap.class));
-
-      Command.create(conn, "select * from guests where id=:id", Map.of("id", 1));
-
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
+
+          conn.executeQuery(
+              con -> {
+                PreparedStatement stmt = con.prepareStatement("select * from guests where id=?");
+                stmt.setInt(1, 1);
+                return stmt;
+              },
+              conn.getResultSetTraverser(RowMap.class));
+
+          Command.create(conn, "select * from guests where id=:id", Map.of("id", 1));
+        });
   }
 
   @Test
   void testExecuteQueryFunctionHandlerOfResultSetT() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
-      Player p = Command.create(conn, "select * from players where id=?", 1)
-          .executeQuery(conn.getResultSetTraverser(Player.class)).get(0);
-      assertThat(p).isEqualTo(SormTestUtils.PLAYER_ALICE);
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
+          Player p =
+              Command.create(conn, "select * from players where id=?", 1)
+                  .executeQuery(conn.getResultSetTraverser(Player.class))
+                  .get(0);
+          assertThat(p).isEqualTo(SormTestUtils.PLAYER_ALICE);
+        });
   }
 
   @Test
   void testExecuteQueryRowMapperOfT() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
-      List p = Command.create(conn, "select * from players where id=?", 1)
-          .executeQuery(conn.getResultSetTraverser(Player.class));
-      assertThat(p.size()).isEqualTo(1);
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
+          List p =
+              Command.create(conn, "select * from players where id=?", 1)
+                  .executeQuery(conn.getResultSetTraverser(Player.class));
+          assertThat(p.size()).isEqualTo(1);
+        });
   }
 
   @Test
   void testExecuteUpdate() {
-    sorm.acceptHandler(conn -> {
-      int m = Command.create(conn, "insert into players values(?,?,?)", PLAYER_CAROL.getId(),
-          PLAYER_CAROL.getName(), PLAYER_CAROL.readAddress()).executeUpdate();
-      assertThat(m).isEqualTo(1);
-    });
+    sorm.acceptHandler(
+        conn -> {
+          int m =
+              Command.create(
+                      conn,
+                      "insert into players values(?,?,?)",
+                      PLAYER_CAROL.getId(),
+                      PLAYER_CAROL.getName(),
+                      PLAYER_CAROL.readAddress())
+                  .executeUpdate();
+          assertThat(m).isEqualTo(1);
+        });
   }
 
   @Test
   void testReadFirst() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(PLAYER_ALICE, PLAYER_BOB));
-      Player p = Command.create(conn, "select * from players").readFirst(Player.class);
-      assertThat(p).isEqualTo(SormTestUtils.PLAYER_ALICE);
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(PLAYER_ALICE, PLAYER_BOB));
+          Player p = Command.create(conn, "select * from players").readFirst(Player.class);
+          assertThat(p).isEqualTo(SormTestUtils.PLAYER_ALICE);
+        });
   }
 
-
   @Test
   void testReadList() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(PLAYER_ALICE, PLAYER_BOB));
-      Player p = Command.create(conn, "select * from players").readList(Player.class).get(0);
-      assertThat(p).isEqualTo(SormTestUtils.PLAYER_ALICE);
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(PLAYER_ALICE, PLAYER_BOB));
+          Player p = Command.create(conn, "select * from players").readList(Player.class).get(0);
+          assertThat(p).isEqualTo(SormTestUtils.PLAYER_ALICE);
+        });
   }
 
   @Test
   void testReadOne() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
-      Player p = Command.create(conn, "select * from players").readOne(Player.class);
-      assertThat(p).isEqualTo(SormTestUtils.PLAYER_ALICE);
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(SormTestUtils.PLAYER_ALICE));
+          Player p = Command.create(conn, "select * from players").readOne(Player.class);
+          assertThat(p).isEqualTo(SormTestUtils.PLAYER_ALICE);
+        });
   }
 
-
   @Test
   void testReadTupleListClassOfT1ClassOfT2() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(PLAYER_ALICE, PLAYER_BOB));
-      conn.insert(List.of(GUEST_ALICE, GUEST_BOB));
-
-      String sql = ParameterizedSqlParser.embedParameter(
-          "select {?}, {?} from players join guests on players.id=guests.id where players.id=?",
-          String.join(",", conn.getTableMetaData(Player.class).getColumnAliases()),
-          String.join(",", conn.getTableMetaData(Guest.class).getColumnAliases()));
-
-      List> ret =
-          Command.create(conn, sql, PLAYER_ALICE.getId()).readTupleList(Player.class, Guest.class);
-      assertThat(ret.get(0).getT1().getName()).isEqualTo(PLAYER_ALICE.getName());
-      assertThat(ret.get(0).getT2().getName()).isEqualTo(GUEST_ALICE.getName());
-
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(PLAYER_ALICE, PLAYER_BOB));
+          conn.insert(List.of(GUEST_ALICE, GUEST_BOB));
+
+          String sql =
+              ParameterizedSqlParser.embedParameter(
+                  "select {?}, {?} from players join guests on players.id=guests.id where players.id=?",
+                  String.join(",", conn.getTableMetaData(Player.class).getColumnAliases()),
+                  String.join(",", conn.getTableMetaData(Guest.class).getColumnAliases()));
+
+          List> ret =
+              Command.create(conn, sql, PLAYER_ALICE.getId())
+                  .readTupleList(Player.class, Guest.class);
+          assertThat(ret.get(0).getT1().getName()).isEqualTo(PLAYER_ALICE.getName());
+          assertThat(ret.get(0).getT2().getName()).isEqualTo(GUEST_ALICE.getName());
+        });
   }
 
   @Test
   void testReadTupleListClassOfT1ClassOfT2ClassOfT3() {
-    sorm.acceptHandler(conn -> {
-      conn.insert(List.of(PLAYER_ALICE, PLAYER_BOB));
-      conn.insert(List.of(GUEST_ALICE, GUEST_BOB));
-      conn.insert(List.of(SOCCER, TENNIS));
-
-      String sql = ParameterizedSqlParser.embedParameter(
-          "select {?}, {?}, {?} from players join guests on players.id=guests.id "
-              + " join sports on players.id=sports.id " + " where players.id=?",
-          String.join(",", conn.getTableMetaData(Player.class).getColumnAliases()),
-          String.join(",", conn.getTableMetaData(Guest.class).getColumnAliases()),
-          String.join(",", conn.getTableMetaData(Sport.class).getColumnAliases()));
-
-      List> ret = Command.create(conn, sql, PLAYER_ALICE.getId())
-          .readTupleList(Player.class, Guest.class, Sport.class);
-      assertThat(ret.get(0).getT1().getName()).isEqualTo(PLAYER_ALICE.getName());
-      assertThat(ret.get(0).getT2().getName()).isEqualTo(GUEST_ALICE.getName());
-      assertThat(ret.get(0).getT3().getName()).isEqualTo(TENNIS.getName());
-
-    });
+    sorm.acceptHandler(
+        conn -> {
+          conn.insert(List.of(PLAYER_ALICE, PLAYER_BOB));
+          conn.insert(List.of(GUEST_ALICE, GUEST_BOB));
+          conn.insert(List.of(SOCCER, TENNIS));
+
+          String sql =
+              ParameterizedSqlParser.embedParameter(
+                  "select {?}, {?}, {?} from players join guests on players.id=guests.id "
+                      + " join sports on players.id=sports.id "
+                      + " where players.id=?",
+                  String.join(",", conn.getTableMetaData(Player.class).getColumnAliases()),
+                  String.join(",", conn.getTableMetaData(Guest.class).getColumnAliases()),
+                  String.join(",", conn.getTableMetaData(Sport.class).getColumnAliases()));
+
+          List> ret =
+              Command.create(conn, sql, PLAYER_ALICE.getId())
+                  .readTupleList(Player.class, Guest.class, Sport.class);
+          assertThat(ret.get(0).getT1().getName()).isEqualTo(PLAYER_ALICE.getName());
+          assertThat(ret.get(0).getT2().getName()).isEqualTo(GUEST_ALICE.getName());
+          assertThat(ret.get(0).getT3().getName()).isEqualTo(TENNIS.getName());
+        });
   }
 
   @Test
   void testOrderedRequest() {
     AtomicInteger id = new AtomicInteger(10);
-    int row = sorm.applyHandler(conn -> Command.create(conn, "insert into players values(?,?,?)")
-        .addParameter(id.incrementAndGet(), "Frank", "Tokyo").executeUpdate());
+    int row =
+        sorm.applyHandler(
+            conn ->
+                Command.create(conn, "insert into players values(?,?,?)")
+                    .addParameter(id.incrementAndGet(), "Frank", "Tokyo")
+                    .executeUpdate());
     assertThat(row).isEqualTo(1);
 
-    List ret = sorm.applyHandler(conn -> Command
-        .create(conn, "select * from players where id=? and name=?").addParameter(id.get(), "Frank")
-        .executeQuery(conn.getResultSetTraverser(Player.class)));
+    List ret =
+        sorm.applyHandler(
+            conn ->
+                Command.create(conn, "select * from players where id=? and name=?")
+                    .addParameter(id.get(), "Frank")
+                    .executeQuery(conn.getResultSetTraverser(Player.class)));
 
     assertThat(ret.size()).isEqualTo(1);
 
-    row = sorm.applyHandler(conn -> Command.create(conn, "insert into players values(?,?,?)")
-        .addParameter(id.incrementAndGet()).addParameter("Frank").addParameter("Tokyo")
-        .executeUpdate());
+    row =
+        sorm.applyHandler(
+            conn ->
+                Command.create(conn, "insert into players values(?,?,?)")
+                    .addParameter(id.incrementAndGet())
+                    .addParameter("Frank")
+                    .addParameter("Tokyo")
+                    .executeUpdate());
     assertThat(row).isEqualTo(1);
 
-
-    ret = sorm.applyHandler(conn -> Command.create(conn, "select * from players where id=?")
-        .addParameter(id.get()).executeQuery(conn.getRowMapper(Player.class)));
+    ret =
+        sorm.applyHandler(
+            conn ->
+                Command.create(conn, "select * from players where id=?")
+                    .addParameter(id.get())
+                    .executeQuery(conn.getRowMapper(Player.class)));
 
     assertThat(ret.size()).isEqualTo(1);
   }
@@ -183,16 +221,19 @@ void testOrderedRequest() {
   @Test
   void testCommand() {
 
-    sorm.applyHandler(conn -> Command
-        .create(conn, ParameterizedSqlParser.parse("select * from players where id=?", 1))
-        .readList(Player.class));
-
-    sorm.applyHandler(conn -> Command
-        .create(conn,
-            ParameterizedSqlParser.parse("select * from players where id=:id", Map.of("id", 1)))
-        .readList(Player.class));
+    sorm.applyHandler(
+        conn ->
+            Command.create(
+                    conn, ParameterizedSqlParser.parse("select * from players where id=?", 1))
+                .readList(Player.class));
+
+    sorm.applyHandler(
+        conn ->
+            Command.create(
+                    conn,
+                    ParameterizedSqlParser.parse(
+                        "select * from players where id=:id", Map.of("id", 1)))
+                .readList(Player.class));
     sorm.applyHandler(conn -> conn.getJdbcTableMetaData("players"));
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/BasicH2TableTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/BasicH2TableTest.java
index 3c5deca3..8eb150fd 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/BasicH2TableTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/BasicH2TableTest.java
@@ -85,11 +85,11 @@ void test3() {
   public static class Item {
     @CsvColumn("parsedatetime(delivery_date, 'y/MM/d')")
     public LocalDate deliveryDate;
+
     @CsvColumn("`price/prices`")
     public int price;
   }
 
-
   @OrmRecord
   public static class OrmRecordExample {
     private final int id;
@@ -118,12 +118,9 @@ public JsonByte getJsonCol() {
     public String toString() {
       return "OrmRecordExample [id=" + id + ", name=" + name + ", jsonCol=" + jsonCol + "]";
     }
-
-
   }
 
   public static File getTempDirectory() {
     return new File(System.getProperty("java.io.tmpdir"));
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/datasource/H2LocalDataSourceFactoryTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/datasource/H2LocalDataSourceFactoryTest.java
index a8a5f34f..144a3e97 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/datasource/H2LocalDataSourceFactoryTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/datasource/H2LocalDataSourceFactoryTest.java
@@ -13,10 +13,12 @@ class H2LocalDataSourceFactoryTest {
 
   @Test
   void test() throws StreamReadException, DatabindException, IOException, SQLException {
-    H2LocalDataSourceFactory factory = new ObjectMapper()
-        .readValue(H2LocalDataSourceFactoryTest.class.getResourceAsStream("h2.json.sample"),
-            H2LocalDataSourceFactory.Builder.class)
-        .build();
+    H2LocalDataSourceFactory factory =
+        new ObjectMapper()
+            .readValue(
+                H2LocalDataSourceFactoryTest.class.getResourceAsStream("h2.json.sample"),
+                H2LocalDataSourceFactory.Builder.class)
+            .build();
     factory.getDatabaseFile().delete();
     factory.makeFileDatabaseIfNotExists();
     factory.makeFileDatabaseIfNotExists();
@@ -37,8 +39,11 @@ void test() throws StreamReadException, DatabindException, IOException, SQLExcep
         .contains("jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
 
     H2LocalDataSourceFactory.builder();
-    H2LocalDataSourceFactory.builder(factory.getDatabaseDirectory(), factory.getDatabaseName(),
-        factory.getUsername(), factory.getPassword());
+    H2LocalDataSourceFactory.builder(
+        factory.getDatabaseDirectory(),
+        factory.getDatabaseName(),
+        factory.getUsername(),
+        factory.getPassword());
 
     H2LocalDataSourceFactory.createTemporalInMemoryDataSource();
 
@@ -51,11 +56,9 @@ void test() throws StreamReadException, DatabindException, IOException, SQLExcep
     factory.createMixedModeDataSource("DB_CLOSE_DELAY=-1").getConnection();
     // factory.createServerModeDataSource("DB_CLOSE_DELAY=-1").getConnection();
 
-
   }
 
   private String userHomeDir() {
     return SystemPropertyUtils.getUserHomeDirectory().getPath().replace("\\", "/");
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProcessTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProcessTest.java
index 0c9ed88e..54f5d25b 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProcessTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2TcpServerProcessTest.java
@@ -11,17 +11,16 @@ class H2TcpServerProcessTest {
   @Test
   void test() throws StreamReadException, DatabindException, IOException {
 
-    H2TcpServerProperties prop = new ObjectMapper()
-        .readValue(H2TcpServerProcessTest.class.getResourceAsStream("h2.tcpsrv.json.sample"),
-            H2TcpServerProperties.Builder.class)
-        .build();
-
+    H2TcpServerProperties prop =
+        new ObjectMapper()
+            .readValue(
+                H2TcpServerProcessTest.class.getResourceAsStream("h2.tcpsrv.json.sample"),
+                H2TcpServerProperties.Builder.class)
+            .build();
 
     H2TcpServerProcess server = new H2TcpServerProcess(prop);
     server.awaitShutdown();
     server.awaitStart();
     server.awaitShutdown();
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebBrowsingServiceTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebBrowsingServiceTest.java
index e4c2d941..3c22a9ba 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebBrowsingServiceTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebBrowsingServiceTest.java
@@ -19,6 +19,4 @@ void test() throws StreamReadException, DatabindException, IOException, SQLExcep
     // server.open(ds.getConnection());
     server.getWebServer().stop();
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java
index 57ea6574..3c8d3157 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java
@@ -10,15 +10,15 @@ class H2WebConsoleServerProcessTest {
 
   @Test
   void testAwaitStart() throws StreamReadException, DatabindException, IOException {
-    H2WebConsoleServerProperties prop = new ObjectMapper()
-        .readValue(H2TcpServerProcessTest.class.getResourceAsStream("h2.webcon.json.sample"),
-            H2WebConsoleServerProperties.Builder.class)
-        .build();
-
+    H2WebConsoleServerProperties prop =
+        new ObjectMapper()
+            .readValue(
+                H2TcpServerProcessTest.class.getResourceAsStream("h2.webcon.json.sample"),
+                H2WebConsoleServerProperties.Builder.class)
+            .build();
 
     H2WebConsoleServerProcess server = new H2WebConsoleServerProcess(prop);
     server.awaitStart();
     ProcessUtils.stopProcessBindingPortIfExists(prop.port);
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/ProcessUtils.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/ProcessUtils.java
index 76a3e59f..b16b833f 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/ProcessUtils.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/ProcessUtils.java
@@ -22,7 +22,6 @@ public static boolean isJapaneseOs() {
     return Locale.getDefault() == Locale.JAPANESE || Locale.getDefault() == Locale.JAPAN;
   }
 
-
   /**
    * Reads read standard output after process finish.
    *
@@ -32,8 +31,8 @@ public static boolean isJapaneseOs() {
   private static String readStandardOutputAfterProcessFinish(Process process) {
     try {
       byte[] b = process.getInputStream().readAllBytes();
-      return new String(b,
-          isWindowsOs() && isJapaneseOs() ? "MS932" : StandardCharsets.UTF_8.toString());
+      return new String(
+          b, isWindowsOs() && isJapaneseOs() ? "MS932" : StandardCharsets.UTF_8.toString());
     } catch (IOException e) {
       throw Try.rethrow(e);
     }
@@ -41,8 +40,10 @@ private static String readStandardOutputAfterProcessFinish(Process process) {
 
   public static Optional getProcessIdBidingPort(int port) {
     try {
-      List command = isWindowsOs() ? List.of("cmd", "/c", "netstat", "-ano")
-          : List.of("lsof", "-nPi", ":" + port);
+      List command =
+          isWindowsOs()
+              ? List.of("cmd", "/c", "netstat", "-ano")
+              : List.of("lsof", "-nPi", ":" + port);
 
       ProcessBuilder pb = new ProcessBuilder(command);
       pb.redirectErrorStream(true);
@@ -50,18 +51,24 @@ public static Optional getProcessIdBidingPort(int port) {
       String lines = readStandardOutputAfterProcessFinish(proc);
       if (isWindowsOs()) {
         return Arrays.stream(lines.split(System.lineSeparator()))
-            .filter(l -> l.contains(":" + port + " ")).findAny().map(l -> {
-              String[] t = l.split("\\s+");
-              return t[t.length - 1];
-            });
+            .filter(l -> l.contains(":" + port + " "))
+            .findAny()
+            .map(
+                l -> {
+                  String[] t = l.split("\\s+");
+                  return t[t.length - 1];
+                });
       } else {
         log.debug("comannd {} result ={}", command, lines);
         return Arrays.stream(lines.split(System.lineSeparator()))
-            .filter(l -> l.contains(String.valueOf(port))).findAny().map(l -> {
-              String[] t = l.split("\\s+");
-              log.debug("{}", Arrays.toString(t));
-              return t[1];
-            });
+            .filter(l -> l.contains(String.valueOf(port)))
+            .findAny()
+            .map(
+                l -> {
+                  String[] t = l.split("\\s+");
+                  log.debug("{}", Arrays.toString(t));
+                  return t[1];
+                });
       }
     } catch (Exception e) {
       throw Try.rethrow(e);
@@ -79,44 +86,53 @@ public static boolean stopProcessBindingPortIfExists(int port) {
   }
 
   public static boolean stopProcessBindingPortIfExists(int port, long timeout, TimeUnit unit) {
-    return getProcessIdBidingPort(port).map(pid -> {
-      try {
-        log.info("process [{}] is binding port [{}]. try killing by ProcessHandle.destory()", pid,
-            port);
-        ProcessHandle proc = ProcessHandle.of(Long.valueOf(pid)).orElseThrow();
-        proc.destroy();
+    return getProcessIdBidingPort(port)
+        .map(
+            pid -> {
+              try {
+                log.info(
+                    "process [{}] is binding port [{}]. try killing by ProcessHandle.destory()",
+                    pid,
+                    port);
+                ProcessHandle proc = ProcessHandle.of(Long.valueOf(pid)).orElseThrow();
+                proc.destroy();
 
-        long start = System.currentTimeMillis();
+                long start = System.currentTimeMillis();
 
-        while (proc.isAlive()) {
-          long durationInMillis = System.currentTimeMillis() - start;
-          if (durationInMillis > TimeUnit.MICROSECONDS.convert(timeout, unit)) {
-            log.error("Process [{}] is active yet.");
-            return false;
-          }
-          TimeUnit.SECONDS.sleep(1);
-        }
-        return true;
-      } catch (InterruptedException e) {
-        throw Try.rethrow(e);
-      }
-    }).orElse(false);
+                while (proc.isAlive()) {
+                  long durationInMillis = System.currentTimeMillis() - start;
+                  if (durationInMillis > TimeUnit.MICROSECONDS.convert(timeout, unit)) {
+                    log.error("Process [{}] is active yet.");
+                    return false;
+                  }
+                  TimeUnit.SECONDS.sleep(1);
+                }
+                return true;
+              } catch (InterruptedException e) {
+                throw Try.rethrow(e);
+              }
+            })
+        .orElse(false);
   }
 
   public static boolean killForceProcessBindingPortIfExists(int port) {
-    return getProcessIdBidingPort(port).map(pid -> {
-      try {
-        List command = isWindowsOs() ? List.of("taskkill", "/F", "/T", "/PID", pid)
-            : List.of("kill", "-9", pid);
-        log.info("process [{}] is binding port [{}]. try killing {}", pid, port, command);
-        ProcessBuilder pb = new ProcessBuilder(command);
-        pb.start().waitFor();
-      } catch (InterruptedException | IOException e) {
-        throw Try.rethrow(e);
-      }
-      // log.info("Success to stop the process [{}] biding port :[{}].", pid, port);
-      return true;
-    }).orElse(false);
+    return getProcessIdBidingPort(port)
+        .map(
+            pid -> {
+              try {
+                List command =
+                    isWindowsOs()
+                        ? List.of("taskkill", "/F", "/T", "/PID", pid)
+                        : List.of("kill", "-9", pid);
+                log.info("process [{}] is binding port [{}]. try killing {}", pid, port, command);
+                ProcessBuilder pb = new ProcessBuilder(command);
+                pb.start().waitFor();
+              } catch (InterruptedException | IOException e) {
+                throw Try.rethrow(e);
+              }
+              // log.info("Success to stop the process [{}] biding port :[{}].", pid, port);
+              return true;
+            })
+        .orElse(false);
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvReadSqlTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvReadSqlTest.java
index 38c082b5..9032e1bf 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvReadSqlTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/sql/H2CsvReadSqlTest.java
@@ -13,19 +13,29 @@ class H2CsvReadSqlTest {
   void test() throws URISyntaxException {
     File file = Paths.get(H2CsvReadSqlTest.class.getResource("test.tsv").toURI()).toFile();
 
-    assertThat(H2CsvReadSql.builder(file).setCsvColumns("col-1", "col-2")
-        .setTableColumns("col_1", "col_2").setCharset("UTF_16").setFieldSeparator('\t')
-        .mapCsvColumnToTableColumn("`col-1`", "col_1").mapCsvColumnToTableColumn("`col-2`", "col_2")
-        .build().getCsvReadAndSelectSql()).isEqualTo(
-            "select `col-1` as col_1,`col-2` as col_2 from csvread('" + file.getAbsolutePath()
+    assertThat(
+            H2CsvReadSql.builder(file)
+                .setCsvColumns("col-1", "col-2")
+                .setTableColumns("col_1", "col_2")
+                .setCharset("UTF_16")
+                .setFieldSeparator('\t')
+                .mapCsvColumnToTableColumn("`col-1`", "col_1")
+                .mapCsvColumnToTableColumn("`col-2`", "col_2")
+                .build()
+                .getCsvReadAndSelectSql())
+        .isEqualTo(
+            "select `col-1` as col_1,`col-2` as col_2 from csvread('"
+                + file.getAbsolutePath()
                 + "','COL-1'||char(9)||'COL-2','charset=UTF-16'||' fieldSeparator='||char(9))");
 
-    assertThat(H2CsvReadSql.builder(file, OrmRecordExample.class).build()
-        .getCsvReadAndInsertSql("test_table"))
-            .isEqualTo("insert into test_table(ID,NAME) select ID,NAME from csvread('"
-                + file.getAbsolutePath() + "',null,'charset=UTF-8'||' fieldSeparator='||char(44))");
-
-
+    assertThat(
+            H2CsvReadSql.builder(file, OrmRecordExample.class)
+                .build()
+                .getCsvReadAndInsertSql("test_table"))
+        .isEqualTo(
+            "insert into test_table(ID,NAME) select ID,NAME from csvread('"
+                + file.getAbsolutePath()
+                + "',null,'charset=UTF-8'||' fieldSeparator='||char(44))");
   }
 
   @OrmRecord
@@ -46,6 +56,4 @@ public String getName() {
       return name;
     }
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/jackson/JacksonSormContextTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/jackson/JacksonSormContextTest.java
index df3ae72b..efec3ca5 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/jackson/JacksonSormContextTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/jackson/JacksonSormContextTest.java
@@ -16,8 +16,10 @@ class JacksonSormContextTest {
 
   @Test
   void testBuilder() {
-    Sorm sorm = Sorm.create(SormTestUtils.createNewDatabaseDataSource(),
-        JacksonSormContext.builder(new ObjectMapper()).build());
+    Sorm sorm =
+        Sorm.create(
+            SormTestUtils.createNewDatabaseDataSource(),
+            JacksonSormContext.builder(new ObjectMapper()).build());
 
     BasicH2Table table = new BasicH2Table<>(sorm, JacksonRecord.class);
     table.createTableIfNotExists();
@@ -25,30 +27,31 @@ void testBuilder() {
     assertThat(table.selectAll().get(0).jsonCol.toString()).contains("Alice");
     assertThat(table.selectAll().get(0).jsonCol.toString()).contains(Integer.toString(20));
 
-
-    assertThat(table.getOrm()
-        .readFirst(SimpleOrmJsonContainer.class, "select * from jackson_records").toString())
-            .contains("Alice");
+    assertThat(
+            table
+                .getOrm()
+                .readFirst(SimpleOrmJsonContainer.class, "select * from jackson_records")
+                .toString())
+        .contains("Alice");
   }
 
   @Test
   void testBuilder1() {
-    Sorm sorm = Sorm.create(SormTestUtils.createNewDatabaseDataSource(),
-        JacksonSormContext.builder(new ObjectMapper()).build());
+    Sorm sorm =
+        Sorm.create(
+            SormTestUtils.createNewDatabaseDataSource(),
+            JacksonSormContext.builder(new ObjectMapper()).build());
 
     BasicH2Table table = new BasicH2Table<>(sorm, HasJsonColumn.class);
     assertThat(table.getTableDefinition().getCreateTableIfNotExistsStatement())
         .isEqualTo("create table if not exists HAS_JSON_COLUMNS(ID integer, JSON_COL json)");
 
-
     table.createTableIfNotExists();
     table.insert(new HasJsonColumn(1, new SimpleOrmJsonContainer("Alice", 20)));
 
-
     assertThat(table.selectAll().get(0).id).isEqualTo(1);
     assertThat(table.selectAll().get(0).jsonCol.name).isEqualTo("Alice");
     assertThat(table.selectAll().get(0).jsonCol.age).isEqualTo(20);
-
   }
 
   @OrmRecord
@@ -56,18 +59,14 @@ public static class JacksonRecord {
 
     public final JsonByte jsonCol;
 
-
     public JacksonRecord(JsonByte jsonCol) {
       this.jsonCol = jsonCol;
     }
 
-
     @Override
     public String toString() {
       return "JacksonRecord [jsonCol=" + jsonCol + "]";
     }
-
-
   }
 
   @OrmJsonColumnContainer
@@ -87,13 +86,11 @@ public String toString() {
     }
   }
 
-
   // @SuppressWarnings("exports")
   @OrmRecord
   public static class HasJsonColumn {
     public int id;
-    @OrmJsonColumnContainer
-    public SimpleOrmJsonContainer jsonCol;
+    @OrmJsonColumnContainer public SimpleOrmJsonContainer jsonCol;
 
     public HasJsonColumn() {}
 
@@ -101,7 +98,5 @@ public HasJsonColumn(int id, SimpleOrmJsonContainer jsonCol) {
       this.id = id;
       this.jsonCol = jsonCol;
     }
-
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/jts/GeometryTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/jts/GeometryTest.java
index fcc783d5..8c9db7f5 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/jts/GeometryTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/jts/GeometryTest.java
@@ -29,15 +29,14 @@ void stringTest() {
     assertThat(g.hashCode() == g1.hashCode()).isTrue();
     assertThat(g.toString()).isEqualTo("POINT (30 10)");
 
-
-
     table.insert(new GeometryStringRecord(g));
 
-    GeometryString ret = table.getOrm().readFirst(GeometryString.class,
-        "select geo_str from geometry_string_records");
+    GeometryString ret =
+        table
+            .getOrm()
+            .readFirst(GeometryString.class, "select geo_str from geometry_string_records");
 
     assertThat(ret).isEqualTo(g);
-
   }
 
   @Test
@@ -59,15 +58,11 @@ void jtsTest() {
     assertThat(g.hashCode() == g1.hashCode()).isTrue();
     assertThat(g.toString()).isEqualTo("POINT (100 200)");
 
-
     table.insert(new GeometryJtsRecord(g));
 
-
     GeometryJts ret =
         table.getOrm().readFirst(GeometryJts.class, "select geo_jts from geometry_jts_records");
     assertThat(ret).isEqualTo(g);
-
-
   }
 
   @OrmRecord
@@ -85,7 +80,6 @@ public String toString() {
     }
   }
 
-
   @OrmRecord
   public static class GeometryJtsRecord {
 
@@ -100,5 +94,4 @@ public String toString() {
       return "GeometryJtsRecord [geoJts=" + geoJts + "]";
     }
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/sql/SelectSqlTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/sql/SelectSqlTest.java
index fba22c53..5f83f096 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/sql/SelectSqlTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/sql/SelectSqlTest.java
@@ -50,17 +50,16 @@ void test() {
     assertThat(where(and("id=?", "name=?", "address=?")))
         .isEqualTo(" where (id=? and name=? and address=?) ");
     assertThat(op(op("A", "/", "B"), "+", op("C", "/", "D"))).isEqualTo("((A / B) + (C / D))");
-
   }
 
-
   @Test
   void testBuild1() {
     Sorm sorm = createSormWithNewDatabaseAndCreateTables();
-    sorm.acceptHandler(con -> {
-      String sql = SelectSql.builder().from(con.getTableName(Guest.class)).build();
-      assertThat(sql).contains("select * from GUESTS");
-    });
+    sorm.acceptHandler(
+        con -> {
+          String sql = SelectSql.builder().from(con.getTableName(Guest.class)).build();
+          assertThat(sql).contains("select * from GUESTS");
+        });
 
     SelectSql.Builder builder = SelectSql.builder();
     builder.distinct();
@@ -69,23 +68,33 @@ void testBuild1() {
     builder.where(or(and("ID>100", "COUNTRY IN (?)"), "YEAR>2001"));
 
     String sql = builder.from("GUESTS").orderBy("age", "desc").limit(10).build();
-    assertThat(sql).isEqualTo(
-        "select distinct avg(AGE) as AVERAGE_AGE, TEAM from GUESTS where ((ID>100 and COUNTRY IN (?)) or YEAR>2001) group by TEAM order by age desc limit 10");
+    assertThat(sql)
+        .isEqualTo(
+            "select distinct avg(AGE) as AVERAGE_AGE, TEAM from GUESTS where ((ID>100 and COUNTRY IN (?)) or YEAR>2001) group by TEAM order by age desc limit 10");
 
     builder.toPrettyString();
   }
 
   @Test
   void testBuild2() {
-    SelectSql.Condition where = or(and("ID=A", "NAME=B"), and("YEAR=C", "DATE=D"),
-        or(cond("ID", "=", quote("test")), cond("NAME='Hello'")));
+    SelectSql.Condition where =
+        or(
+            and("ID=A", "NAME=B"),
+            and("YEAR=C", "DATE=D"),
+            or(cond("ID", "=", quote("test")), cond("NAME='Hello'")));
     SelectSql.Condition having = and("aveage_age>0", "a>0");
 
-    String sql = SelectSql.builder().select(as("AVG(age)", "aveage_age"), "ID").from("GUESTS")
-        .where(where).having(having).orderBy("age", "desc").limit(10, 30).build();
-    assertThat(sql).isEqualTo(
-        "select AVG(age) as aveage_age, ID from GUESTS where ((ID=A and NAME=B) or (YEAR=C and DATE=D) or (ID = 'test' or NAME='Hello')) having (aveage_age>0 and a>0) order by age desc limit 10 offset 30");
+    String sql =
+        SelectSql.builder()
+            .select(as("AVG(age)", "aveage_age"), "ID")
+            .from("GUESTS")
+            .where(where)
+            .having(having)
+            .orderBy("age", "desc")
+            .limit(10, 30)
+            .build();
+    assertThat(sql)
+        .isEqualTo(
+            "select AVG(age) as aveage_age, ID from GUESTS where ((ID=A and NAME=B) or (YEAR=C and DATE=D) or (ID = 'test' or NAME='Hello')) having (aveage_age>0 and a>0) order by age desc limit 10 offset 30");
   }
-
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/sql/SqlKeywordTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/sql/SqlKeywordTest.java
index acf7b924..7ce1f5bc 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/sql/SqlKeywordTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/sql/SqlKeywordTest.java
@@ -5,18 +5,71 @@
 import java.util.List;
 import org.junit.jupiter.api.Test;
 
-
 class SqlKeywordTest {
 
   @Test
   void test() {
-    List l = List.of(ALL, AND, ANY, AS, AUTHORIZATION, CASE, CHECK, COLLATE, COLUMN,
-        CONSTRAINT, CREATE, CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER,
-        DEFAULT, DISTINCT, ELSE, END, EXCEPT, FETCH, FOR, FOREIGN, FROM, FULL, GRANT, GROUP, HAVING,
-        IN, INNER, INTERSECT, INTO, IS, JOIN, LEFT, LIKE, NOT, NULL, ON, OR, ORDER, OUTER, PRIMARY,
-        REFERENCES, RIGHT, SELECT, SESSION_USER, SOME, TABLE, TABLESAMPLE, THEN, TO, UNION, UNIQUE,
-        USER, WHEN, WHERE, WITH);
+    List l =
+        List.of(
+            ALL,
+            AND,
+            ANY,
+            AS,
+            AUTHORIZATION,
+            CASE,
+            CHECK,
+            COLLATE,
+            COLUMN,
+            CONSTRAINT,
+            CREATE,
+            CROSS,
+            CURRENT_DATE,
+            CURRENT_TIME,
+            CURRENT_TIMESTAMP,
+            CURRENT_USER,
+            DEFAULT,
+            DISTINCT,
+            ELSE,
+            END,
+            EXCEPT,
+            FETCH,
+            FOR,
+            FOREIGN,
+            FROM,
+            FULL,
+            GRANT,
+            GROUP,
+            HAVING,
+            IN,
+            INNER,
+            INTERSECT,
+            INTO,
+            IS,
+            JOIN,
+            LEFT,
+            LIKE,
+            NOT,
+            NULL,
+            ON,
+            OR,
+            ORDER,
+            OUTER,
+            PRIMARY,
+            REFERENCES,
+            RIGHT,
+            SELECT,
+            SESSION_USER,
+            SOME,
+            TABLE,
+            TABLESAMPLE,
+            THEN,
+            TO,
+            UNION,
+            UNIQUE,
+            USER,
+            WHEN,
+            WHERE,
+            WITH);
     assertThat(l);
   }
-
 }
diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/table_def/TableDefinitionTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/table_def/TableDefinitionTest.java
index ab20bb32..3d9f37df 100644
--- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/table_def/TableDefinitionTest.java
+++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/table_def/TableDefinitionTest.java
@@ -32,8 +32,6 @@
 
 class TableDefinitionTest {
 
-
-
   @Test
   void testEnum() {
     Sorm sorm = SormTestUtils.createSormWithNewContext();
@@ -49,29 +47,32 @@ void test() throws URISyntaxException {
     Sorm sorm = SormTestUtils.createSormWithNewContext();
 
     TableDefinition def = TableDefinition.builder(TableDefExample.class).build();
-    assertThat(def.toString()).isEqualTo(
-        "TableDefinition [tableName=TABLE_DEF_EXAMPLES, tableNameAndColumnDefinitions=TABLE_DEF_EXAMPLES(ID bigint primary key auto_increment, BOOLEAN_COL boolean, BYTE_COL tinyint, CHAR_COL character, SHORT_COL smallint, INT_COL integer default 0, FLOAT_COL float, DOUBLE_COL double check (double_col>0), BIG_DECIMAL numeric, PHONE_NUMBER varchar not null, LOCAL_DATE_COL date, LOCAL_TIME_COL time, LOCAL_DATE_TIME timestamp, OFFSET_TIME time with time zone, OFFSET_DATE_TIME timestamp with time zone, BLOB blob, CLOB clob, INPUT_STREAM longvarbinary, READER longvarchar, STR_ARRAY varchar array, unique(boolean_col, byte_col), unique(boolean_col, char_col), unique(PHONE_NUMBER), check(int_col>=0)), columnNames=[ID, BOOLEAN_COL, BYTE_COL, CHAR_COL, SHORT_COL, INT_COL, FLOAT_COL, DOUBLE_COL, BIG_DECIMAL, PHONE_NUMBER, LOCAL_DATE_COL, LOCAL_TIME_COL, LOCAL_DATE_TIME, OFFSET_TIME, OFFSET_DATE_TIME, BLOB, CLOB, INPUT_STREAM, READER, STR_ARRAY], createTableStatement=create table if not exists TABLE_DEF_EXAMPLES(ID bigint primary key auto_increment, BOOLEAN_COL boolean, BYTE_COL tinyint, CHAR_COL character, SHORT_COL smallint, INT_COL integer default 0, FLOAT_COL float, DOUBLE_COL double check (double_col>0), BIG_DECIMAL numeric, PHONE_NUMBER varchar not null, LOCAL_DATE_COL date, LOCAL_TIME_COL time, LOCAL_DATE_TIME timestamp, OFFSET_TIME time with time zone, OFFSET_DATE_TIME timestamp with time zone, BLOB blob, CLOB clob, INPUT_STREAM longvarbinary, READER longvarchar, STR_ARRAY varchar array, unique(boolean_col, byte_col), unique(boolean_col, char_col), unique(PHONE_NUMBER), check(int_col>=0)), dropTableStatement=drop table if exists TABLE_DEF_EXAMPLES, createIndexStatements=[create index if not exists index_in_TABLE_DEF_EXAMPLES_on_boolean_col_byte_col on TABLE_DEF_EXAMPLES(boolean_col, byte_col), create index if not exists index_in_TABLE_DEF_EXAMPLES_on_boolean_col_char_col on TABLE_DEF_EXAMPLES(boolean_col, char_col), create index if not exists index_in_TABLE_DEF_EXAMPLES_on_PHONE_NUMBER on TABLE_DEF_EXAMPLES(PHONE_NUMBER)]]");
+    assertThat(def.toString())
+        .isEqualTo(
+            "TableDefinition [tableName=TABLE_DEF_EXAMPLES, tableNameAndColumnDefinitions=TABLE_DEF_EXAMPLES(ID bigint primary key auto_increment, BOOLEAN_COL boolean, BYTE_COL tinyint, CHAR_COL character, SHORT_COL smallint, INT_COL integer default 0, FLOAT_COL float, DOUBLE_COL double check (double_col>0), BIG_DECIMAL numeric, PHONE_NUMBER varchar not null, LOCAL_DATE_COL date, LOCAL_TIME_COL time, LOCAL_DATE_TIME timestamp, OFFSET_TIME time with time zone, OFFSET_DATE_TIME timestamp with time zone, BLOB blob, CLOB clob, INPUT_STREAM longvarbinary, READER longvarchar, STR_ARRAY varchar array, unique(boolean_col, byte_col), unique(boolean_col, char_col), unique(PHONE_NUMBER), check(int_col>=0)), columnNames=[ID, BOOLEAN_COL, BYTE_COL, CHAR_COL, SHORT_COL, INT_COL, FLOAT_COL, DOUBLE_COL, BIG_DECIMAL, PHONE_NUMBER, LOCAL_DATE_COL, LOCAL_TIME_COL, LOCAL_DATE_TIME, OFFSET_TIME, OFFSET_DATE_TIME, BLOB, CLOB, INPUT_STREAM, READER, STR_ARRAY], createTableStatement=create table if not exists TABLE_DEF_EXAMPLES(ID bigint primary key auto_increment, BOOLEAN_COL boolean, BYTE_COL tinyint, CHAR_COL character, SHORT_COL smallint, INT_COL integer default 0, FLOAT_COL float, DOUBLE_COL double check (double_col>0), BIG_DECIMAL numeric, PHONE_NUMBER varchar not null, LOCAL_DATE_COL date, LOCAL_TIME_COL time, LOCAL_DATE_TIME timestamp, OFFSET_TIME time with time zone, OFFSET_DATE_TIME timestamp with time zone, BLOB blob, CLOB clob, INPUT_STREAM longvarbinary, READER longvarchar, STR_ARRAY varchar array, unique(boolean_col, byte_col), unique(boolean_col, char_col), unique(PHONE_NUMBER), check(int_col>=0)), dropTableStatement=drop table if exists TABLE_DEF_EXAMPLES, createIndexStatements=[create index if not exists index_in_TABLE_DEF_EXAMPLES_on_boolean_col_byte_col on TABLE_DEF_EXAMPLES(boolean_col, byte_col), create index if not exists index_in_TABLE_DEF_EXAMPLES_on_boolean_col_char_col on TABLE_DEF_EXAMPLES(boolean_col, char_col), create index if not exists index_in_TABLE_DEF_EXAMPLES_on_PHONE_NUMBER on TABLE_DEF_EXAMPLES(PHONE_NUMBER)]]");
 
-    assertThat(def.getTableNameAndColumnDefinitions()).isEqualTo(
-        "TABLE_DEF_EXAMPLES(ID bigint primary key auto_increment, BOOLEAN_COL boolean, BYTE_COL tinyint, CHAR_COL character, SHORT_COL smallint, INT_COL integer default 0, FLOAT_COL float, DOUBLE_COL double check (double_col>0), BIG_DECIMAL numeric, PHONE_NUMBER varchar not null, LOCAL_DATE_COL date, LOCAL_TIME_COL time, LOCAL_DATE_TIME timestamp, OFFSET_TIME time with time zone, OFFSET_DATE_TIME timestamp with time zone, BLOB blob, CLOB clob, INPUT_STREAM longvarbinary, READER longvarchar, STR_ARRAY varchar array, unique(boolean_col, byte_col), unique(boolean_col, char_col), unique(PHONE_NUMBER), check(int_col>=0))");
+    assertThat(def.getTableNameAndColumnDefinitions())
+        .isEqualTo(
+            "TABLE_DEF_EXAMPLES(ID bigint primary key auto_increment, BOOLEAN_COL boolean, BYTE_COL tinyint, CHAR_COL character, SHORT_COL smallint, INT_COL integer default 0, FLOAT_COL float, DOUBLE_COL double check (double_col>0), BIG_DECIMAL numeric, PHONE_NUMBER varchar not null, LOCAL_DATE_COL date, LOCAL_TIME_COL time, LOCAL_DATE_TIME timestamp, OFFSET_TIME time with time zone, OFFSET_DATE_TIME timestamp with time zone, BLOB blob, CLOB clob, INPUT_STREAM longvarbinary, READER longvarchar, STR_ARRAY varchar array, unique(boolean_col, byte_col), unique(boolean_col, char_col), unique(PHONE_NUMBER), check(int_col>=0))");
     sorm.executeUpdate(def.getCreateTableIfNotExistsStatement());
 
-
-
-    String selectSql = H2CsvReadSql
-        .builder(Paths.get(TableDefinitionTest.class.getResource("test.csv").toURI()).toFile())
-        .build().getCsvReadAndSelectSql();
+    String selectSql =
+        H2CsvReadSql.builder(
+                Paths.get(TableDefinitionTest.class.getResource("test.csv").toURI()).toFile())
+            .build()
+            .getCsvReadAndSelectSql();
 
     List ret = sorm.readList(TableDefExample.class, selectSql);
     sorm.insert(ret);
 
-
     assertThat(sorm.selectAll(TableDefExample.class).get(0).phoneNumber).isEqualTo("000-000-0000");
     System.out.println(sorm.selectAll(TableDefExample.class));
   }
 
   public static enum EnumExample {
-    A, B, C
+    A,
+    B,
+    C
   }
 
   @OrmRecord
@@ -87,8 +88,6 @@ public SimpleEnum(long id, EnumExample en) {
     }
   }
 
-
-
   @OrmRecord
   @IndexColumns({"boolean_col", "byte_col"})
   @IndexColumns({"boolean_col", "char_col"})
@@ -117,13 +116,27 @@ public static class TableDefExample {
     public final java.io.Reader reader;
     public final String[] strArray;
 
-
-    public TableDefExample(@PrimaryKey @AutoIncrement Long id, Boolean booleanCol, Byte byteCol,
-        Character charCol, Short shortCol, @Default("0") Integer intCol, Float floatCol,
-        @Check("double_col>0") Double doubleCol, BigDecimal bigDecimal,
-        @Index @Unique @NotNull String phoneNumber, LocalDate localDateCol, LocalTime localTimeCol,
-        LocalDateTime localDateTimeCol, OffsetTime offsetTime, OffsetDateTime offsetDateTime,
-        Blob blob, Clob clob, InputStream inputStream, Reader reader, String[] strArray) {
+    public TableDefExample(
+        @PrimaryKey @AutoIncrement Long id,
+        Boolean booleanCol,
+        Byte byteCol,
+        Character charCol,
+        Short shortCol,
+        @Default("0") Integer intCol,
+        Float floatCol,
+        @Check("double_col>0") Double doubleCol,
+        BigDecimal bigDecimal,
+        @Index @Unique @NotNull String phoneNumber,
+        LocalDate localDateCol,
+        LocalTime localTimeCol,
+        LocalDateTime localDateTimeCol,
+        OffsetTime offsetTime,
+        OffsetDateTime offsetDateTime,
+        Blob blob,
+        Clob clob,
+        InputStream inputStream,
+        Reader reader,
+        String[] strArray) {
       this.id = id;
       this.booleanCol = booleanCol;
       this.byteCol = byteCol;
@@ -146,20 +159,47 @@ public TableDefExample(@PrimaryKey @AutoIncrement Long id, Boolean booleanCol, B
       this.strArray = strArray;
     }
 
-
-
     @Override
     public String toString() {
-      return "TableDefExample [id=" + id + ", dateCol=" + localDateCol + ", timeCol=" + localTimeCol
-          + ", intCol=" + intCol + ", doubleCol=" + doubleCol + ", phoneNumber=" + phoneNumber
-          + ", booleanCol=" + booleanCol + ", byteCol=" + byteCol + ", charCol=" + charCol
-          + ", shortCol=" + shortCol + ", floatCol=" + floatCol + ", offsetTime=" + offsetTime
-          + ", offsetDateTime=" + offsetDateTime + ", localDateTime=" + localDateTime
-          + ", bigDecimal=" + bigDecimal + ", blob=" + blob + ", clob=" + clob + ", inputStream="
-          + inputStream + ", reader=" + reader + "]";
+      return "TableDefExample [id="
+          + id
+          + ", dateCol="
+          + localDateCol
+          + ", timeCol="
+          + localTimeCol
+          + ", intCol="
+          + intCol
+          + ", doubleCol="
+          + doubleCol
+          + ", phoneNumber="
+          + phoneNumber
+          + ", booleanCol="
+          + booleanCol
+          + ", byteCol="
+          + byteCol
+          + ", charCol="
+          + charCol
+          + ", shortCol="
+          + shortCol
+          + ", floatCol="
+          + floatCol
+          + ", offsetTime="
+          + offsetTime
+          + ", offsetDateTime="
+          + offsetDateTime
+          + ", localDateTime="
+          + localDateTime
+          + ", bigDecimal="
+          + bigDecimal
+          + ", blob="
+          + blob
+          + ", clob="
+          + clob
+          + ", inputStream="
+          + inputStream
+          + ", reader="
+          + reader
+          + "]";
     }
-
-
   }
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple.java
index 2acbb7be..c39f37dd 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple.java
@@ -46,25 +46,19 @@ public int hashCode() {
 
   @Override
   public boolean equals(Object obj) {
-    if (this == obj)
-      return true;
-    if (obj == null)
-      return false;
-    if (getClass() != obj.getClass())
-      return false;
+    if (this == obj) return true;
+    if (obj == null) return false;
+    if (getClass() != obj.getClass()) return false;
 
     final Simple other = (Simple) obj;
 
     // do not compare ids -- will be tested in the autogeneratedkeys tests
     // if (id != other.id) return false;
 
-    if (longCol != other.longCol)
-      return false;
+    if (longCol != other.longCol) return false;
     if (stringCol == null) {
-      if (other.stringCol != null)
-        return false;
-    } else if (!stringCol.equals(other.stringCol))
-      return false;
+      if (other.stringCol != null) return false;
+    } else if (!stringCol.equals(other.stringCol)) return false;
 
     return true;
   }
@@ -73,7 +67,4 @@ public boolean equals(Object obj) {
   public String toString() {
     return "id=" + id + " longCol=" + longCol + " stringCol=" + stringCol;
   }
-
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple01.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple01.java
index fe12d226..9a66e79b 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple01.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple01.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -14,8 +13,4 @@ public class Simple01 {
   // field name annotation
   @OrmColumn("LONG_COL")
   public long intCol;
-
-
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple02.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple02.java
index fafb84da..34585a4b 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple02.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple02.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -12,7 +11,4 @@ public class Simple02 {
   private long id;
   private String stringCol;
   private long longCol;
-
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple03.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple03.java
index 6f09ab7b..dd99a711 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple03.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple03.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -28,7 +27,4 @@ public String getStringCol() {
   public void setStringCol(String stringCol) {
     this.stringCol = stringCol;
   }
-
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple04.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple04.java
index 273235f1..b588a3ba 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple04.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple04.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -6,12 +5,13 @@
 import org.nkjmlab.sorm4j.annotation.OrmTable;
 
 @OrmTable("SIMPLE")
-
 public class Simple04 {
 
   private long id;
+
   @SuppressWarnings("unused")
   private String stringCol;
+
   private long longCol;
 
   public long getId() {
@@ -40,6 +40,4 @@ public long getLongCol() {
   public void setLongCol(boolean intCol) {
     this.longCol = 9999;
   }
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple05.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple05.java
index f4104b61..414b7004 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple05.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple05.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -33,6 +32,4 @@ public long getLongCol() {
   public void setLongCol(long intCol) {
     this.longCol = intCol;
   }
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple06.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple06.java
index 138c9b04..f2ef2252 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple06.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple06.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -10,6 +9,7 @@ public class Simple06 {
 
   private long id;
   private String stringCol;
+
   @SuppressWarnings("unused")
   private long longCol;
 
@@ -28,6 +28,4 @@ public String getStringCol() {
   public void setStringCol(String stringCol) {
     this.stringCol = stringCol;
   }
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple07.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple07.java
index 88931463..4eb4cdcf 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple07.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple07.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -24,7 +23,9 @@ public String getHelloWorld() {
     return "hello world";
   }
 
-  public void setHelloWorld(String stringCol) { /* do nothing */ }
+  public void setHelloWorld(String stringCol) {
+    /* do nothing */
+  }
 
   public long getLongCol() {
     return longCol;
@@ -39,7 +40,7 @@ public String getFoo() {
     return "foo";
   }
 
-  public void setFoo(String foo) { /* do nothing */ }
-
+  public void setFoo(String foo) {
+    /* do nothing */
+  }
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple08.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple08.java
index 6b254981..3887d4dd 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple08.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple08.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -26,7 +25,9 @@ public String getHelloWorld() {
     return "hello world";
   }
 
-  public void setHelloWorld(String stringCol) { /* do nothing */ }
+  public void setHelloWorld(String stringCol) {
+    /* do nothing */
+  }
 
   // conflicting annotations -- will blow
   public long getIntCol() {
@@ -45,6 +46,4 @@ public String getStringCol(String str) {
   public void setStringCol(String stringCol) {
     this.stringCol = stringCol;
   }
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple09.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple09.java
index 9e688e3b..e5de43be 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple09.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple09.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.common;
@@ -23,7 +22,9 @@ public void setId(long id) {
   // getter returns void -- will blow
   public void getStringCol() {}
 
-  public void setStringCol(String stringCol) { /* this.stringCol = stringCol; */ }
+  public void setStringCol(String stringCol) {
+    /* this.stringCol = stringCol; */
+  }
 
   public long getIntCol() {
     return intCol;
@@ -32,6 +33,4 @@ public long getIntCol() {
   public void setIntCol(long intCol) {
     this.intCol = intCol;
   }
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple10.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple10.java
index c036e8e1..0e261206 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple10.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple10.java
@@ -31,6 +31,4 @@ public long getLongCol() {
   public void setLongCol(long longCol) {
     this.longCol = longCol;
   }
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple11.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple11.java
index f9a38b38..e7096122 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple11.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple11.java
@@ -9,7 +9,4 @@ public class Simple11 {
   private long id;
   private java.sql.Date stringCol = new java.sql.Date(System.currentTimeMillis());
   private long longCol;
-
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple12.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple12.java
index b729dcc0..29053c2e 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple12.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/Simple12.java
@@ -11,7 +11,4 @@ public class Simple12 {
 
   // no plain constructor -- fail
   public Simple12(long id) {}
-
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/SimpleNoTable.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/SimpleNoTable.java
index 34911ca6..78134345 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/SimpleNoTable.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/common/SimpleNoTable.java
@@ -1,4 +1,3 @@
-
 // $Id: Simple.java 7 2007-08-17 19:32:18Z jcamaia $
 
 package repackage.net.sf.persist.tests.common;
@@ -35,14 +34,8 @@ public void setLongCol(long intCol) {
     this.longCol = intCol;
   }
 
-
-
   @Override
   public String toString() {
     return "id=" + id + " longCol=" + longCol + " stringCol=" + stringCol;
   }
-
-
-
 }
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BeanMap.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BeanMap.java
index 706f90dd..23360f34 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BeanMap.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BeanMap.java
@@ -3,9 +3,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-/**
- * Holds all data necessary to build a bean during runtime and metadata to test it
- */
+/** Holds all data necessary to build a bean during runtime and metadata to test it */
 public class BeanMap {
 
   private final String className;
@@ -31,11 +29,8 @@ public BeanMap addField(FieldMap fieldMap) {
 
   public FieldMap getField(String fieldName) {
     for (FieldMap fieldMap : fields) {
-      if (fieldMap.getFieldName().equals(fieldName))
-        return fieldMap;
+      if (fieldMap.getFieldName().equals(fieldName)) return fieldMap;
     }
     return null;
   }
-
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BeanTest.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BeanTest.java
index fd68e93b..ec5518be 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BeanTest.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BeanTest.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.engine.framework;
@@ -11,32 +10,27 @@
 import org.nkjmlab.sorm4j.result.RowMap;
 import org.slf4j.Logger;
 
-
 public class BeanTest {
 
   private static final Logger log = org.slf4j.LoggerFactory.getLogger(BeanTest.class);
 
-
-  public static void test(Class caller, OrmConnection ormConn, BeanMap beanMap,
-      Consumer tester) {
+  public static void test(
+      Class caller, OrmConnection ormConn, BeanMap beanMap, Consumer tester) {
     ormConn.deleteAllIn(dbName(beanMap.getClassName()));
     Object obj =
         DynamicBean.createInstance(DynamicBean.getBeanClass(caller, beanMap), beanMap, false);
     tester.accept(obj);
   }
 
-
-  public static void testNull(Class caller, OrmConnection ormConn, BeanMap beanMap,
-      Consumer tester) {
+  public static void testNull(
+      Class caller, OrmConnection ormConn, BeanMap beanMap, Consumer tester) {
     ormConn.deleteAllIn(dbName(beanMap.getClassName()));
     Object objNull =
         DynamicBean.createInstance(DynamicBean.getBeanClass(caller, beanMap), beanMap, true);
     tester.accept(objNull);
   }
 
-  /**
-   * tests insertion of a bean
-   */
+  /** tests insertion of a bean */
   public static void testInsert(OrmConnection persist, Object obj, BeanMap beanMap) {
     Class cls = obj.getClass();
     String tableName = dbName(obj.getClass().getSimpleName());
@@ -55,12 +49,17 @@ public static void testInsert(OrmConnection persist, Object obj, BeanMap beanMap
 
     // check if the bean read is the same as inserted
     if (!obj.equals(read.get(0))) {
-      throw new AssertionError("Expected [" + DynamicBean.toString(obj) + "] but got ["
-          + DynamicBean.toString(read.get(0)) + "] as result of [" + sql + "]");
+      throw new AssertionError(
+          "Expected ["
+              + DynamicBean.toString(obj)
+              + "] but got ["
+              + DynamicBean.toString(read.get(0))
+              + "] as result of ["
+              + sql
+              + "]");
     }
   }
 
-
   /**
    * For each field and each field type, execute a query in the format select * from tableName where
    * columnName=?
@@ -93,14 +92,30 @@ public static void testSelectByFields(OrmConnection persist, Object obj, BeanMap
           if (ret == null) {
             List all = persist.selectAll(obj.getClass());
             log.error("{}, {}", fieldValueConverted, all);
-            throw new AssertionError("Expected not null value but got null as result of [" + sql
-                + "] with parameter [" + fieldValue + "] , converted = [" + fieldValueConverted
-                + "] type [" + (fieldValue == null ? "null" : fieldValue.getClass())
-                + "] converted [" + fieldType + "]" + System.lineSeparator() + all);
+            throw new AssertionError(
+                "Expected not null value but got null as result of ["
+                    + sql
+                    + "] with parameter ["
+                    + fieldValue
+                    + "] , converted = ["
+                    + fieldValueConverted
+                    + "] type ["
+                    + (fieldValue == null ? "null" : fieldValue.getClass())
+                    + "] converted ["
+                    + fieldType
+                    + "]"
+                    + System.lineSeparator()
+                    + all);
           }
           if (!obj.equals(ret)) {
-            throw new AssertionError("Expected [" + DynamicBean.toString(obj) + "] but got ["
-                + DynamicBean.toString(ret) + "] as result of [" + sql + "]");
+            throw new AssertionError(
+                "Expected ["
+                    + DynamicBean.toString(obj)
+                    + "] but got ["
+                    + DynamicBean.toString(ret)
+                    + "] as result of ["
+                    + sql
+                    + "]");
           }
         }
       }
@@ -132,8 +147,14 @@ public static void testSelectByFieldsNull(OrmConnection persist, Object obj, Bea
               "Expected not null value but got null as result of [" + sql + "]");
         }
         if (!obj.equals(ret)) {
-          throw new AssertionError("Expected [" + DynamicBean.toString(obj) + "] but got ["
-              + DynamicBean.toString(ret) + "] as result of [" + sql + "]");
+          throw new AssertionError(
+              "Expected ["
+                  + DynamicBean.toString(obj)
+                  + "] but got ["
+                  + DynamicBean.toString(ret)
+                  + "] as result of ["
+                  + sql
+                  + "]");
         }
       }
     }
@@ -143,8 +164,8 @@ public static void testSelectByFieldsNull(OrmConnection persist, Object obj, Bea
    * for each field, and for each field type perform a query in the form select columnName from
    * tableName
    */
-  public static void testSelectFields(OrmConnection persist, Object obj, BeanMap beanMap,
-      boolean useNulls) {
+  public static void testSelectFields(
+      OrmConnection persist, Object obj, BeanMap beanMap, boolean useNulls) {
     String tableName = dbName(obj.getClass().getSimpleName());
 
     // for each field in the bean
@@ -179,17 +200,26 @@ public static void testSelectFields(OrmConnection persist, Object obj, BeanMap b
           // (eg char[]-String, double-BigDecimal, etc)
           Object retConverted = DynamicBean.convertToType(fieldValue.getClass(), ret);
           if (!DynamicBean.compareValues(fieldValue, retConverted)) {
-            Object[] params = {fieldValue, fieldValue.getClass(), retConverted, retConverted.getClass(), ret, ret.getClass(), sql};
-            throw new AssertionError(ParameterizedStringFormatter.LENGTH_256.format("Expected [{}]({}) but actual [{}]({}) converted from [{}]({}) as result of [{}]", params));
+            Object[] params = {
+              fieldValue,
+              fieldValue.getClass(),
+              retConverted,
+              retConverted.getClass(),
+              ret,
+              ret.getClass(),
+              sql
+            };
+            throw new AssertionError(
+                ParameterizedStringFormatter.LENGTH_256.format(
+                    "Expected [{}]({}) but actual [{}]({}) converted from [{}]({}) as result of [{}]",
+                    params));
           }
         }
       }
     }
   }
 
-  /**
-   * perform [select * from tableName] and get the results as a map
-   */
+  /** perform [select * from tableName] and get the results as a map */
   public static void testSelectMap(OrmConnection persist, Object obj, BeanMap beanMap) {
     String tableName = dbName(obj.getClass().getSimpleName());
 
@@ -226,24 +256,28 @@ public static void testSelectMap(OrmConnection persist, Object obj, BeanMap bean
         // (eg char[]-String, double-BigDecimal, etc)
         if (!DynamicBean.compareValues(fieldValue, mapValueU)
             && !DynamicBean.compareValues(fieldValue, mapValueL)) {
-          throw new AssertionError("Map entry [" + columnName + "]=[" + mapValueU
-              + "] does not match field [" + fieldMap.getFieldName() + "]=[" + fieldValue
-              + "] as result of sql [" + sql + "]");
+          throw new AssertionError(
+              "Map entry ["
+                  + columnName
+                  + "]=["
+                  + mapValueU
+                  + "] does not match field ["
+                  + fieldMap.getFieldName()
+                  + "]=["
+                  + fieldValue
+                  + "] as result of sql ["
+                  + sql
+                  + "]");
         }
       }
     }
   }
 
-
-
   // ---------- helpers ----------
 
-  /**
-   * Returned the database table/column name related with a given bean/field name
-   */
+  /** Returned the database table/column name related with a given bean/field name */
   private static String dbName(String s) {
     String name = s.replaceAll("([A-Z])", "_$1").toLowerCase();
     return (name.charAt(0) == '_' ? name.substring(1) : name).toLowerCase();
   }
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BytesBlob.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BytesBlob.java
index 044279c9..729d0d40 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BytesBlob.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/BytesBlob.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.engine.framework;
@@ -29,8 +28,7 @@ public InputStream getBinaryStream() throws SQLException {
   @Override
   public byte[] getBytes(long pos, int length) throws SQLException {
     byte[] ret = new byte[length];
-    for (int i = (int) pos - 1; i < pos + length - 1; i++)
-      ret[i] = b[i + (int) pos - 1];
+    for (int i = (int) pos - 1; i < pos + length - 1; i++) ret[i] = b[i + (int) pos - 1];
     return ret;
   }
 
@@ -78,5 +76,4 @@ public void free() throws SQLException {
   public InputStream getBinaryStream(long pos, long length) throws SQLException {
     throw new RuntimeException("getBinaryStream(long, long) not implemented");
   }
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/DbEngineTestUtils.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/DbEngineTestUtils.java
index dc9aea1f..ac690cca 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/DbEngineTestUtils.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/DbEngineTestUtils.java
@@ -18,26 +18,28 @@ public class DbEngineTestUtils {
   public static void executeSql(DataSource dataSource, Class clazz, String fileName) {
     try (Connection conn = dataSource.getConnection()) {
       Statement st = conn.createStatement();
-      String[] sqls = String
-          .join(System.lineSeparator(),
-              Files.readAllLines(new File(clazz.getResource(fileName).toURI()).toPath()))
-          .split(";");
-      Arrays.asList(sqls).forEach(sql -> {
-        try {
-          sql = sql.trim();
-          if (sql.length() < 4) {
-            return;
-          }
-          st.execute(sql);
-        } catch (SQLException e) {
-          System.err.println(sql);
-          System.err.println(e.getMessage());
-        }
-      });
+      String[] sqls =
+          String.join(
+                  System.lineSeparator(),
+                  Files.readAllLines(new File(clazz.getResource(fileName).toURI()).toPath()))
+              .split(";");
+      Arrays.asList(sqls)
+          .forEach(
+              sql -> {
+                try {
+                  sql = sql.trim();
+                  if (sql.length() < 4) {
+                    return;
+                  }
+                  st.execute(sql);
+                } catch (SQLException e) {
+                  System.err.println(sql);
+                  System.err.println(e.getMessage());
+                }
+              });
     } catch (SQLException | URISyntaxException | IOException e) {
       System.err.println(e.getMessage());
     }
-
   }
 
   public static DataSource getDataSource(Class clazz, String defaultJdbcUrl) {
@@ -52,5 +54,4 @@ public static DataSource getDataSource(Class clazz, String defaultJdbcUrl) {
       return JdbcConnectionPool.create(defaultJdbcUrl, "sorm", "sorm");
     }
   }
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/DynamicBean.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/DynamicBean.java
index b8638fdb..7c5fefe4 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/DynamicBean.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/DynamicBean.java
@@ -27,9 +27,7 @@
 import javassist.CtMethod;
 import javassist.CtNewMethod;
 
-/**
- * Set of helpers to build and manipulate beans at runtime.
- */
+/** Set of helpers to build and manipulate beans at runtime. */
 public class DynamicBean {
 
   private static final String DYNAMICBEAN_CLASS = DynamicBean.class.getName();
@@ -37,10 +35,14 @@ public class DynamicBean {
   private static Map> beanClasses = new HashMap<>();
 
   public static Class getBeanClass(Class caller, BeanMap beanMap) {
-    String className = DynamicBean.class.getPackageName() + "." + caller.getSimpleName() + "."
-        + beanMap.getClassName();
-    return DynamicBean.beanClasses.computeIfAbsent(className,
-        k -> createBeanClass(className, beanMap));
+    String className =
+        DynamicBean.class.getPackageName()
+            + "."
+            + caller.getSimpleName()
+            + "."
+            + beanMap.getClassName();
+    return DynamicBean.beanClasses.computeIfAbsent(
+        className, k -> createBeanClass(className, beanMap));
   }
 
   public static Class createBeanClass(String className, BeanMap beanMap) {
@@ -62,8 +64,18 @@ public static Class createBeanClass(String className, BeanMap beanMap) {
             "public " + fieldTypeName + " get" + fieldNameU + "() { return " + fieldName + "; }";
         cc.addMethod(CtNewMethod.make(getterCode, cc));
 
-        String setterCode = "public void set" + fieldNameU + "(" + fieldTypeName + " " + fieldName
-            + ") { this." + fieldName + "=" + fieldName + "; }";
+        String setterCode =
+            "public void set"
+                + fieldNameU
+                + "("
+                + fieldTypeName
+                + " "
+                + fieldName
+                + ") { this."
+                + fieldName
+                + "="
+                + fieldName
+                + "; }";
         cc.addMethod(CtNewMethod.make(setterCode, cc));
       }
 
@@ -74,8 +86,10 @@ public static Class createBeanClass(String className, BeanMap beanMap) {
         cc.addMethod(cm);
       }
       {
-        String equalsCode = "public boolean equals(Object obj) { return " + DYNAMICBEAN_CLASS
-            + " .compareBeans(this,obj); }";
+        String equalsCode =
+            "public boolean equals(Object obj) { return "
+                + DYNAMICBEAN_CLASS
+                + " .compareBeans(this,obj); }";
         CtMethod cm = CtNewMethod.make(equalsCode, cc);
         cc.addMethod(cm);
       }
@@ -109,26 +123,21 @@ private static void setRandomValue(Object obj, Field field, FieldMap fieldMap, b
 
     Object value = null;
 
-    if (fieldType == Boolean.class)
-      value = useNull ? null : Boolean.valueOf(randomBoolean());
-    else if (fieldType == boolean.class)
-      value = useNull ? false : randomBoolean();
+    if (fieldType == Boolean.class) value = useNull ? null : Boolean.valueOf(randomBoolean());
+    else if (fieldType == boolean.class) value = useNull ? false : randomBoolean();
     else if (fieldType == Byte.class)
       value = useNull ? null : Byte.valueOf(randomByte((byte) min, (byte) max));
     else if (fieldType == byte.class)
       value = useNull ? (byte) 0 : randomByte((byte) min, (byte) max);
-    else if (fieldType == Byte[].class)
-      value = useNull ? null : randomByteObjArray(size);
-    else if (fieldType == byte[].class)
-      value = useNull ? null : randomByteArray(size);
+    else if (fieldType == Byte[].class) value = useNull ? null : randomByteObjArray(size);
+    else if (fieldType == byte[].class) value = useNull ? null : randomByteArray(size);
     else if (fieldType == Short.class)
       value = useNull ? null : Short.valueOf(randomShort((short) min, (short) max));
     else if (fieldType == short.class)
       value = useNull ? (short) 0 : randomShort((short) min, (short) max);
     else if (fieldType == Integer.class)
       value = useNull ? null : Integer.valueOf(randomInt((int) min, (int) max));
-    else if (fieldType == int.class)
-      value = useNull ? (int) 0 : randomInt((int) min, (int) max);
+    else if (fieldType == int.class) value = useNull ? (int) 0 : randomInt((int) min, (int) max);
     else if (fieldType == Long.class)
       value = useNull ? null : Long.valueOf(randomLong((long) min, (long) max));
     else if (fieldType == long.class)
@@ -139,18 +148,12 @@ else if (fieldType == float.class)
       value = useNull ? (float) 0 : randomFloat((float) min, (float) max);
     else if (fieldType == Double.class)
       value = useNull ? null : Double.valueOf(randomDouble(min, max));
-    else if (fieldType == double.class)
-      value = useNull ? (double) 0 : randomDouble(min, max);
-    else if (fieldType == Character.class)
-      value = useNull ? null : Character.valueOf(randomChar());
-    else if (fieldType == char.class)
-      value = useNull ? ' ' : randomChar();
-    else if (fieldType == Character[].class)
-      value = useNull ? null : randomCharObjArray(size);
-    else if (fieldType == char[].class)
-      value = useNull ? null : randomCharArray(size);
-    else if (fieldType == String.class)
-      value = useNull ? null : randomString(size);
+    else if (fieldType == double.class) value = useNull ? (double) 0 : randomDouble(min, max);
+    else if (fieldType == Character.class) value = useNull ? null : Character.valueOf(randomChar());
+    else if (fieldType == char.class) value = useNull ? ' ' : randomChar();
+    else if (fieldType == Character[].class) value = useNull ? null : randomCharObjArray(size);
+    else if (fieldType == char[].class) value = useNull ? null : randomCharArray(size);
+    else if (fieldType == String.class) value = useNull ? null : randomString(size);
     else if (fieldType == BigDecimal.class)
       value = useNull ? null : new BigDecimal(randomLong((long) min, (long) max));
     else if (fieldType == java.io.Reader.class)
@@ -179,8 +182,7 @@ else if (fieldType == java.time.LocalDateTime.class)
       value =
           useNull ? null : OffsetDateTime.now().truncatedTo(ChronoUnit.SECONDS).toLocalDateTime();
     else {
-      if (useNull)
-        value = null;
+      if (useNull) value = null;
       else {
         Map m = new HashMap<>();
         m.put(randomString(3), randomString(32));
@@ -198,7 +200,6 @@ else if (fieldType == java.time.LocalDateTime.class)
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
-
   }
 
   public static Object getFieldValue(Object obj, String fieldName) {
@@ -212,8 +213,7 @@ public static Object getFieldValue(Object obj, String fieldName) {
   }
 
   public static String toString(Object obj) {
-    if (obj == null)
-      return "null";
+    if (obj == null) return "null";
     StringBuffer sb = new StringBuffer();
     sb.append("{ ");
     for (Field field : obj.getClass().getDeclaredFields()) {
@@ -221,8 +221,7 @@ public static String toString(Object obj) {
 
       Object value = getFieldValue(obj, fieldName);
       String s = value == null ? "null" : value.toString();
-      if (s.length() > 32)
-        s = s.substring(0, 32) + "...";
+      if (s.length() > 32) s = s.substring(0, 32) + "...";
 
       sb.append(fieldName + "=" + s + ", ");
     }
@@ -238,35 +237,37 @@ public static String toString(Object obj) {
    */
   public static boolean isNull(Class cls, Object obj) {
 
-    if (obj == null)
-      return true;
+    if (obj == null) return true;
 
     if (cls == boolean.class || cls == Boolean.class)
       return ((Boolean) obj).booleanValue() == false;
-    else if (cls == byte.class || cls == Byte.class || cls == short.class || cls == Short.class
-        || cls == int.class || cls == Integer.class || cls == long.class || cls == Long.class
-        || cls == float.class || cls == Float.class || cls == double.class || cls == Double.class
+    else if (cls == byte.class
+        || cls == Byte.class
+        || cls == short.class
+        || cls == Short.class
+        || cls == int.class
+        || cls == Integer.class
+        || cls == long.class
+        || cls == Long.class
+        || cls == float.class
+        || cls == Float.class
+        || cls == double.class
+        || cls == Double.class
         || cls == BigDecimal.class) {
 
       // first cast to Number
       Number n = (Number) obj;
       return n.longValue() == 0;
-    } else
-      return false;
+    } else return false;
   }
 
   public static boolean compareBeans(Object o1, Object o2) {
 
-    if (o1 == null && o2 == null)
-      return true;
-    if (o1 == o2)
-      return true;
-    if (o1 == null && o2 != null)
-      return false;
-    if (o1 != null && o2 == null)
-      return false;
-    if (o1.getClass() != o2.getClass())
-      return false;
+    if (o1 == null && o2 == null) return true;
+    if (o1 == o2) return true;
+    if (o1 == null && o2 != null) return false;
+    if (o1 != null && o2 == null) return false;
+    if (o1.getClass() != o2.getClass()) return false;
 
     try {
 
@@ -274,8 +275,7 @@ public static boolean compareBeans(Object o1, Object o2) {
         field.setAccessible(true);
         Object v1 = field.get(o1);
         Object v2 = field.get(o2);
-        if (!compareValues(v1, v2))
-          return false;
+        if (!compareValues(v1, v2)) return false;
       }
 
     } catch (Exception e) {
@@ -285,17 +285,12 @@ public static boolean compareBeans(Object o1, Object o2) {
     return true;
   }
 
-
   public static boolean compareBeansFromDifferentClasses(Object o1, Object o2) {
 
-    if (o1 == null && o2 == null)
-      return true;
-    if (o1 == o2)
-      return true;
-    if (o1 == null && o2 != null)
-      return false;
-    if (o1 != null && o2 == null)
-      return false;
+    if (o1 == null && o2 == null) return true;
+    if (o1 == o2) return true;
+    if (o1 == null && o2 != null) return false;
+    if (o1 != null && o2 == null) return false;
 
     try {
 
@@ -312,8 +307,7 @@ public static boolean compareBeansFromDifferentClasses(Object o1, Object o2) {
         f2.setAccessible(true);
         Object v2 = f2.get(o2);
 
-        if (!compareValues(v1, v2))
-          return false;
+        if (!compareValues(v1, v2)) return false;
       }
 
     } catch (Exception e) {
@@ -323,121 +317,89 @@ public static boolean compareBeansFromDifferentClasses(Object o1, Object o2) {
     return true;
   }
 
-
-
-  /**
-   * Compare values trying to convert types if they are found to be compatible
-   */
+  /** Compare values trying to convert types if they are found to be compatible */
   public static boolean compareValues(Object v1, Object v2) {
 
-    if (v1 == null && v2 == null)
-      return true;
-    if (v1 == v2)
-      return true;
-    if (v1 == null && v2 != null)
-      return false;
-    if (v1 != null && v2 == null)
-      return false;
+    if (v1 == null && v2 == null) return true;
+    if (v1 == v2) return true;
+    if (v1 == null && v2 != null) return false;
+    if (v1 != null && v2 == null) return false;
 
     // try to convert v2 into v1 type
     v2 = convertToType(v1.getClass(), v2);
 
-    if (v1.getClass() != v2.getClass())
-      return false;
+    if (v1.getClass() != v2.getClass()) return false;
 
     Class type = v1.getClass();
 
     try {
 
       if (type == Boolean.class || type == boolean.class) {
-        if (!((Boolean) v1).equals((Boolean) v2))
-          return false;
+        if (!((Boolean) v1).equals((Boolean) v2)) return false;
       } else if (type == Byte.class || type == byte.class) {
-        if (!((Byte) v1).equals((Byte) v2))
-          return false;
+        if (!((Byte) v1).equals((Byte) v2)) return false;
       } else if (type == Byte[].class) {
-        if (!Arrays.equals((Byte[]) v1, (Byte[]) v2))
-          return false;
+        if (!Arrays.equals((Byte[]) v1, (Byte[]) v2)) return false;
       } else if (type == byte[].class) {
-        if (!Arrays.equals((byte[]) v1, (byte[]) v2))
-          return false;
+        if (!Arrays.equals((byte[]) v1, (byte[]) v2)) return false;
       } else if (type == Short.class || type == short.class) {
-        if (!((Short) v1).equals((Short) v2))
-          return false;
+        if (!((Short) v1).equals((Short) v2)) return false;
       } else if (type == Integer.class || type == int.class) {
-        if (!((Integer) v1).equals((Integer) v2))
-          return false;
+        if (!((Integer) v1).equals((Integer) v2)) return false;
       } else if (type == Long.class || type == long.class) {
-        if (!((Long) v1).equals((Long) v2))
-          return false;
+        if (!((Long) v1).equals((Long) v2)) return false;
       } else if (type == Float.class || type == float.class) {
         Float v1f = (Float) v1;
         Float v2f = (Float) v2;
-        if (Float.floatToIntBits(v1f) != Float.floatToIntBits(v2f))
-          return false;
+        if (Float.floatToIntBits(v1f) != Float.floatToIntBits(v2f)) return false;
       } else if (type == Double.class || type == double.class) {
         Double v1d = (Double) v1;
         Double v2d = (Double) v2;
-        if (Double.doubleToLongBits(v1d) != Double.doubleToLongBits(v2d))
-          return false;
+        if (Double.doubleToLongBits(v1d) != Double.doubleToLongBits(v2d)) return false;
       } else if (type == Character.class || type == char.class) {
-        if (!((Character) v1).equals((Character) v2))
-          return false;
+        if (!((Character) v1).equals((Character) v2)) return false;
       } else if (type == Character[].class) {
-        if (!Arrays.equals((Character[]) v1, (Character[]) v2))
-          return false;
+        if (!Arrays.equals((Character[]) v1, (Character[]) v2)) return false;
       } else if (type == char[].class) {
-        if (!Arrays.equals((char[]) v1, (char[]) v2))
-          return false;
+        if (!Arrays.equals((char[]) v1, (char[]) v2)) return false;
       } else if (type == String.class) {
-        if (!((String) v1).equals((String) v2))
-          return false;
+        if (!((String) v1).equals((String) v2)) return false;
       } else if (type == BigDecimal.class) {
-        if (!((BigDecimal) v1).equals((BigDecimal) v2))
-          return false;
+        if (!((BigDecimal) v1).equals((BigDecimal) v2)) return false;
       } else if (type == Reader.class) {
         Reader r1 = (Reader) v1;
         Reader r2 = (Reader) v2;
-        if (!compareReaders(r1, r2))
-          return false;
+        if (!compareReaders(r1, r2)) return false;
       } else if (v1 == InputStream.class) {
         InputStream i1 = (InputStream) v1;
         InputStream i2 = (InputStream) v2;
-        if (!compareInputStreams(i1, i2))
-          return false;
+        if (!compareInputStreams(i1, i2)) return false;
       } else if (v1 instanceof Clob) {
         Clob c1 = (Clob) v1;
         Clob c2 = (Clob) v2;
-        if (!compareReaders(c1.getCharacterStream(), c2.getCharacterStream()))
-          return false;
+        if (!compareReaders(c1.getCharacterStream(), c2.getCharacterStream())) return false;
       } else if (v1 instanceof Blob) {
         Blob b1 = (Blob) v1;
         Blob b2 = (Blob) v2;
-        if (!compareInputStreams(b1.getBinaryStream(), b2.getBinaryStream()))
-          return false;
+        if (!compareInputStreams(b1.getBinaryStream(), b2.getBinaryStream())) return false;
       } else if (type == java.util.Date.class) {
         java.util.Date d1 = (java.util.Date) v1;
         java.util.Date d2 = (java.util.Date) v2;
-        if (!d1.toString().substring(0, 19).equals(d2.toString().substring(0, 19)))
-          return false;
+        if (!d1.toString().substring(0, 19).equals(d2.toString().substring(0, 19))) return false;
       } else if (type == java.sql.Date.class) {
         java.sql.Date d1 = (java.sql.Date) v1;
         java.sql.Date d2 = (java.sql.Date) v2;
-        if (!d1.toString().equals(d2.toString()))
-          return false;
+        if (!d1.toString().equals(d2.toString())) return false;
       } else if (type == java.sql.Time.class) {
         java.sql.Time d1 = (java.sql.Time) v1;
         java.sql.Time d2 = (java.sql.Time) v2;
-        if (!d1.toString().equals(d2.toString()))
-          return false;
+        if (!d1.toString().equals(d2.toString())) return false;
       } else if (type == java.sql.Timestamp.class) {
         java.sql.Timestamp d1 = (java.sql.Timestamp) v1;
         java.sql.Timestamp d2 = (java.sql.Timestamp) v2;
         // quick fix for smalldatetimes is to compare up to 15, instead of 19
-        if (!d1.toString().substring(0, 15).equals(d2.toString().substring(0, 15)))
-          return false;
-      } else if (!v1.equals(v2))
-        return false;
+        if (!d1.toString().substring(0, 15).equals(d2.toString().substring(0, 15))) return false;
+      } else if (!v1.equals(v2)) return false;
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
@@ -454,8 +416,7 @@ public static boolean compareValues(Object v1, Object v2) {
    */
   public static Object convertToType(Class cls, Object value) {
 
-    if (cls == value.getClass())
-      return value;
+    if (cls == value.getClass()) return value;
 
     if (cls == OffsetDateTime.class) {
       if (value instanceof Instant) {
@@ -473,12 +434,11 @@ public static Object convertToType(Class cls, Object value) {
       if (value instanceof Timestamp) {
         return ((Timestamp) value).toLocalDateTime();
       } else if (value instanceof java.util.Date) {
-        return LocalDateTime.ofInstant(((java.util.Date) value).toInstant(),
-            ZoneId.systemDefault());
+        return LocalDateTime.ofInstant(
+            ((java.util.Date) value).toInstant(), ZoneId.systemDefault());
       }
     }
 
-
     // if cls implements Clob or Blob, upcast
     for (Class iface : cls.getInterfaces()) {
       if (iface == Clob.class) {
@@ -492,8 +452,13 @@ public static Object convertToType(Class cls, Object value) {
 
     Class clsValue = value.getClass();
 
-    if (cls == String.class || cls == char.class || cls == Character.class || cls == char[].class
-        || cls == Character[].class || cls == Reader.class || cls == Clob.class) {
+    if (cls == String.class
+        || cls == char.class
+        || cls == Character.class
+        || cls == char[].class
+        || cls == Character[].class
+        || cls == Reader.class
+        || cls == Clob.class) {
 
       // first convert it to string
 
@@ -508,8 +473,7 @@ public static Object convertToType(Class cls, Object value) {
       } else if (clsValue == Character[].class) {
         Character[] a = (Character[]) value;
         char[] ac = new char[a.length];
-        for (int i = 0; i < a.length; i++)
-          ac[i] = a[i];
+        for (int i = 0; i < a.length; i++) ac[i] = a[i];
         s = String.copyValueOf(ac);
       } else if (value instanceof Reader) {
         Reader r2 = (Reader) value;
@@ -530,30 +494,25 @@ public static Object convertToType(Class cls, Object value) {
       if (cls == String.class) {
         return s;
       } else if (cls == char.class) {
-        if (s.length() == 1)
-          return s.charAt(0);
-        else
-          return value;
+        if (s.length() == 1) return s.charAt(0);
+        else return value;
       } else if (cls == Character.class) {
-        if (s.length() == 1)
-          return Character.valueOf(s.charAt(0));
-        else
-          return value;
+        if (s.length() == 1) return Character.valueOf(s.charAt(0));
+        else return value;
       } else if (cls == char[].class) {
         return s.toCharArray();
       } else if (cls == Character[].class) {
         Character[] ret = new Character[s.length()];
-        for (int i = 0; i < s.length(); i++)
-          ret[i] = Character.valueOf(s.charAt(i));
+        for (int i = 0; i < s.length(); i++) ret[i] = Character.valueOf(s.charAt(i));
         return ret;
       } else if (cls == Reader.class) {
         return new StringReader(s);
       } else if (cls == Clob.class) {
         return new StringClob(s);
       }
-    }
-
-    else if (cls == byte[].class || cls == Byte[].class || cls == InputStream.class
+    } else if (cls == byte[].class
+        || cls == Byte[].class
+        || cls == InputStream.class
         || cls == Blob.class) {
 
       // first convert to byte[]
@@ -564,8 +523,7 @@ else if (cls == byte[].class || cls == Byte[].class || cls == InputStream.class
       } else if (clsValue == Byte[].class) {
         Byte[] ba = (Byte[]) value;
         a = new byte[ba.length];
-        for (int i = 0; i < ba.length; i++)
-          a[i] = ba[i];
+        for (int i = 0; i < ba.length; i++) a[i] = ba[i];
       } else if (value instanceof InputStream) {
         InputStream is = (InputStream) value;
         a = readInputStream(is);
@@ -576,8 +534,7 @@ else if (cls == byte[].class || cls == Byte[].class || cls == InputStream.class
         } catch (SQLException e) {
           throw new RuntimeException(e);
         }
-      } else
-        return value;
+      } else return value;
 
       // now convert to target class
 
@@ -585,17 +542,14 @@ else if (cls == byte[].class || cls == Byte[].class || cls == InputStream.class
         return a;
       } else if (cls == Byte[].class) {
         Byte[] ba = new Byte[a.length];
-        for (int i = 0; i < a.length; i++)
-          ba[i] = a[i];
+        for (int i = 0; i < a.length; i++) ba[i] = a[i];
         return ba;
       } else if (cls == InputStream.class) {
         return new ByteArrayInputStream(a);
       } else if (cls == Blob.class) {
         return new BytesBlob(a);
       }
-    }
-
-    else if (clsValue == java.util.Date.class) {
+    } else if (clsValue == java.util.Date.class) {
       java.util.Date d = (java.util.Date) value;
       if (cls == java.sql.Date.class) {
         return new java.sql.Date(d.getTime());
@@ -605,11 +559,8 @@ else if (clsValue == java.util.Date.class) {
       }
       if (cls == java.sql.Timestamp.class) {
         return new java.sql.Timestamp(d.getTime());
-      } else
-        return value;
-    }
-
-    else if (cls == java.util.Date.class) {
+      } else return value;
+    } else if (cls == java.util.Date.class) {
       if (clsValue == java.sql.Date.class) {
         return new java.util.Date(((java.sql.Date) value).getTime());
       }
@@ -618,57 +569,43 @@ else if (cls == java.util.Date.class) {
       }
       if (clsValue == java.sql.Timestamp.class) {
         return new java.util.Date(((java.util.Date) value).getTime());
-      } else
-        return value;
-    }
-
-    else if (clsValue == boolean.class || clsValue == Boolean.class) {
+      } else return value;
+    } else if (clsValue == boolean.class || clsValue == Boolean.class) {
       Boolean b = (Boolean) value;
-      if (cls == boolean.class)
-        return b.booleanValue();
-      else if (cls == Boolean.class)
-        return b;
-      else
-        return value;
-    }
-
-    else if (clsValue == byte.class || clsValue == Byte.class || clsValue == short.class
-        || clsValue == Short.class || clsValue == int.class || clsValue == Integer.class
-        || clsValue == long.class || clsValue == Long.class || clsValue == float.class
-        || clsValue == Float.class || clsValue == double.class || clsValue == Double.class
+      if (cls == boolean.class) return b.booleanValue();
+      else if (cls == Boolean.class) return b;
+      else return value;
+    } else if (clsValue == byte.class
+        || clsValue == Byte.class
+        || clsValue == short.class
+        || clsValue == Short.class
+        || clsValue == int.class
+        || clsValue == Integer.class
+        || clsValue == long.class
+        || clsValue == Long.class
+        || clsValue == float.class
+        || clsValue == Float.class
+        || clsValue == double.class
+        || clsValue == Double.class
         || clsValue == BigDecimal.class) {
 
       // first cast to Number
       Number n = (Number) value;
 
-      if (cls == byte.class)
-        return n.byteValue();
-      else if (cls == Byte.class)
-        return Byte.valueOf(n.byteValue());
-      else if (cls == short.class)
-        return n.shortValue();
-      else if (cls == Short.class)
-        return Short.valueOf(n.shortValue());
-      else if (cls == int.class)
-        return n.intValue();
-      else if (cls == Integer.class)
-        return Integer.valueOf(n.intValue());
-      else if (cls == long.class)
-        return n.longValue();
-      else if (cls == Long.class)
-        return Long.valueOf(n.longValue());
-      else if (cls == float.class)
-        return n.floatValue();
-      else if (cls == Float.class)
-        return Float.valueOf(n.floatValue());
-      else if (cls == double.class)
-        return n.doubleValue();
-      else if (cls == Double.class)
-        return Double.valueOf(n.doubleValue());
-      else if (cls == BigDecimal.class)
-        return BigDecimal.valueOf(n.doubleValue());
-      else
-        return value;
+      if (cls == byte.class) return n.byteValue();
+      else if (cls == Byte.class) return Byte.valueOf(n.byteValue());
+      else if (cls == short.class) return n.shortValue();
+      else if (cls == Short.class) return Short.valueOf(n.shortValue());
+      else if (cls == int.class) return n.intValue();
+      else if (cls == Integer.class) return Integer.valueOf(n.intValue());
+      else if (cls == long.class) return n.longValue();
+      else if (cls == Long.class) return Long.valueOf(n.longValue());
+      else if (cls == float.class) return n.floatValue();
+      else if (cls == Float.class) return Float.valueOf(n.floatValue());
+      else if (cls == double.class) return n.doubleValue();
+      else if (cls == Double.class) return Double.valueOf(n.doubleValue());
+      else if (cls == BigDecimal.class) return BigDecimal.valueOf(n.doubleValue());
+      else return value;
     }
 
     return value;
@@ -679,11 +616,9 @@ public static byte[] readInputStream(InputStream is) {
     try {
       byte[] buf = new byte[65535];
       int n = is.read(buf);
-      if (n < 0)
-        n = 0;
+      if (n < 0) n = 0;
       byte[] ret = new byte[n];
-      for (int i = 0; i < n; i++)
-        ret[i] = buf[i];
+      for (int i = 0; i < n; i++) ret[i] = buf[i];
       return ret;
     } catch (IOException e) {
       throw new RuntimeException(e);
@@ -740,15 +675,13 @@ public static byte randomByte(byte min, byte max) {
 
   public static byte[] randomByteArray(int size) {
     byte[] a = new byte[size];
-    for (int i = 0; i < size; i++)
-      a[i] = randomByte(Byte.MIN_VALUE, Byte.MAX_VALUE);
+    for (int i = 0; i < size; i++) a[i] = randomByte(Byte.MIN_VALUE, Byte.MAX_VALUE);
     return a;
   }
 
   public static Byte[] randomByteObjArray(int size) {
     Byte[] a = new Byte[size];
-    for (int i = 0; i < size; i++)
-      a[i] = Byte.valueOf(randomByte(Byte.MIN_VALUE, Byte.MAX_VALUE));
+    for (int i = 0; i < size; i++) a[i] = Byte.valueOf(randomByte(Byte.MIN_VALUE, Byte.MAX_VALUE));
     return a;
   }
 
@@ -825,6 +758,4 @@ public static String randomString(int size) {
   public static long randomTimestamp() {
     return (long) (Math.random() * System.currentTimeMillis());
   }
-
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/FieldMap.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/FieldMap.java
index 9f49b8e7..8e2065e8 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/FieldMap.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/FieldMap.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.engine.framework;
@@ -6,9 +5,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-/**
- * Holds data related to a field from a bean, including metadata to test it
- */
+/** Holds data related to a field from a bean, including metadata to test it */
 public class FieldMap {
 
   private final String fieldName;
@@ -27,15 +24,12 @@ public class FieldMap {
    */
   private boolean supportsCompareMapValue = true;
 
-  /**
-   * Used for string types
-   */
+  /** Used for string types */
   private int size = 250;
 
-  /**
-   * Used for numeric types
-   */
+  /** Used for numeric types */
   private double min = -1;
+
   private double max = -1;
 
   private List> types = new ArrayList<>();
@@ -54,8 +48,7 @@ public List> getTypes() {
 
   public FieldMap setTypes(Class... types) {
     this.types = new ArrayList<>();
-    for (Class type : types)
-      this.types.add(type);
+    for (Class type : types) this.types.add(type);
     return this;
   }
 
@@ -99,5 +92,4 @@ public FieldMap setSupportsCompareMapValue(boolean supportsCompareMapValue) {
     this.supportsCompareMapValue = supportsCompareMapValue;
     return this;
   }
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/StringClob.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/StringClob.java
index 4bd7efc5..71eb438e 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/StringClob.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/framework/StringClob.java
@@ -1,4 +1,3 @@
-
 // $Id$
 
 package repackage.net.sf.persist.tests.engine.framework;
@@ -93,5 +92,4 @@ public void free() throws SQLException {
   public Reader getCharacterStream(long pos, long length) throws SQLException {
     throw new RuntimeException("getCharacterStream(long, long) not implemented");
   }
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/h2/TestH2.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/h2/TestH2.java
index d3c6b806..a42b1505 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/h2/TestH2.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/h2/TestH2.java
@@ -1,4 +1,3 @@
-
 package repackage.net.sf.persist.tests.engine.h2;
 
 import java.io.File;
@@ -21,10 +20,8 @@
 import repackage.net.sf.persist.tests.engine.framework.BeanTest;
 import repackage.net.sf.persist.tests.engine.framework.FieldMap;
 
-
 public class TestH2 {
 
-
   private static final JdbcConnectionPool dataSource =
       JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;", "sa", "");
   // private static final JdbcConnectionPool connectionPool =
@@ -34,16 +31,16 @@ public class TestH2 {
   static void beforAll() {
     try (Connection conn = dataSource.getConnection()) {
       Statement st = conn.createStatement();
-      String sql = String.join(System.lineSeparator(),
-          Files.readAllLines(new File(TestH2.class.getResource("h2.sql").toURI()).toPath()));
+      String sql =
+          String.join(
+              System.lineSeparator(),
+              Files.readAllLines(new File(TestH2.class.getResource("h2.sql").toURI()).toPath()));
       st.executeUpdate(sql);
     } catch (SQLException | URISyntaxException | IOException e) {
       e.printStackTrace();
     }
   }
 
-
-
   @BeforeEach
   void beforeEach() throws SQLException {}
 
@@ -55,24 +52,32 @@ public void testBinaryTypes() throws SQLException {
       Class[] binaryTypes = new Class[] {Blob.class};
       Class[] otherTypes = new Class[] {Object.class};
 
-      BeanMap beanMap = new BeanMap("BinaryTypes")
-          // .addField(new FieldMap("binaryCol").setTypes(binaryTypes).setSize(255))
-          .addField(new FieldMap("blobCol").setTypes(binaryTypes).setSize(255))
-          .addField(new FieldMap("otherCol").setTypes(otherTypes).setSize(255));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanMap beanMap =
+          new BeanMap("BinaryTypes")
+              // .addField(new FieldMap("binaryCol").setTypes(binaryTypes).setSize(255))
+              .addField(new FieldMap("blobCol").setTypes(binaryTypes).setSize(255))
+              .addField(new FieldMap("otherCol").setTypes(otherTypes).setSize(255));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -81,29 +86,42 @@ public void testDatetimeTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
         OrmConnection ormConn = OrmConnection.of(conn, SormContext.builder().build())) {
 
-      BeanMap beanMap = new BeanMap("DatetimeTypes")
-          .addField(new FieldMap("timeCol").setTypes(java.sql.Time.class))
-          .addField(new FieldMap("timezCol").setTypes(java.time.OffsetTime.class))
-          .addField(new FieldMap("dateCol").setTypes(java.sql.Date.class))
-          .addField(new FieldMap("timestampCol").setTypes(java.time.LocalDateTime.class,
-              java.sql.Timestamp.class, java.util.Date.class))
-          .addField(new FieldMap("timestampzCol").setTypes(java.time.OffsetDateTime.class,
-              java.time.Instant.class));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
+      BeanMap beanMap =
+          new BeanMap("DatetimeTypes")
+              .addField(new FieldMap("timeCol").setTypes(java.sql.Time.class))
+              .addField(new FieldMap("timezCol").setTypes(java.time.OffsetTime.class))
+              .addField(new FieldMap("dateCol").setTypes(java.sql.Date.class))
+              .addField(
+                  new FieldMap("timestampCol")
+                      .setTypes(
+                          java.time.LocalDateTime.class,
+                          java.sql.Timestamp.class,
+                          java.util.Date.class))
+              .addField(
+                  new FieldMap("timestampzCol")
+                      .setTypes(java.time.OffsetDateTime.class, java.time.Instant.class));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
-
   }
 
   @Test
@@ -121,7 +139,8 @@ public void testNumericTypes() throws SQLException {
           new Class[] {Float.class, float.class, Double.class, double.class, BigDecimal.class};
 
       BeanMap beanMap =
-          new BeanMap("NumericTypes").addField(new FieldMap("intCol").setTypes(integerTypes))
+          new BeanMap("NumericTypes")
+              .addField(new FieldMap("intCol").setTypes(integerTypes))
               .addField(new FieldMap("booleanCol").setTypes(booleanTypes))
               .addField(new FieldMap("tinyintCol").setTypes(byteTypes))
               .addField(new FieldMap("smallintCol").setTypes(shortTypes))
@@ -130,21 +149,27 @@ public void testNumericTypes() throws SQLException {
               .addField(new FieldMap("doubleCol").setTypes(doubleTypes).setBoundaries(0, 9999))
               .addField(new FieldMap("realCol").setTypes(floatTypes).setBoundaries(0, 9999));
 
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
-
   }
 
   @Test
@@ -157,26 +182,33 @@ public void testStringTypes() throws SQLException {
       Class[] clobTypes = new Class[] {Clob.class};
 
       // uuid not being tested
-      BeanMap beanMap = new BeanMap("StringTypes")
-          // .addField(new FieldMap("charCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("varcharCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("varcharIgnorecaseCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("clobCol").setTypes(clobTypes).setSize(8192));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanMap beanMap =
+          new BeanMap("StringTypes")
+              // .addField(new FieldMap("charCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("varcharCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("varcharIgnorecaseCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("clobCol").setTypes(clobTypes).setSize(8192));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/mysql/TestMysql.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/mysql/TestMysql.java
index 281598cb..2184227e 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/mysql/TestMysql.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/mysql/TestMysql.java
@@ -1,5 +1,3 @@
-
-
 package repackage.net.sf.persist.tests.engine.mysql;
 
 import java.math.BigDecimal;
@@ -16,15 +14,15 @@
 import repackage.net.sf.persist.tests.engine.framework.DbEngineTestUtils;
 import repackage.net.sf.persist.tests.engine.framework.FieldMap;
 
-
 public class TestMysql {
 
   private static DataSource dataSource;
 
   @BeforeAll
   static void beforAll() {
-    dataSource = DbEngineTestUtils.getDataSource(TestMysql.class,
-        "jdbc:h2:mem:mysql;MODE=MySQL;DATABASE_TO_LOWER=TRUE");
+    dataSource =
+        DbEngineTestUtils.getDataSource(
+            TestMysql.class, "jdbc:h2:mem:mysql;MODE=MySQL;DATABASE_TO_LOWER=TRUE");
     DbEngineTestUtils.executeSql(dataSource, TestMysql.class, "schema.sql");
   }
 
@@ -32,37 +30,43 @@ public static void main(String[] args) {
     beforAll();
   }
 
-
   @Test
   public void testBinaryTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
         OrmConnection ormConn = OrmConnection.of(conn, SormContext.builder().build())) {
 
-
       Class[] binaryTypes = new Class[] {byte[].class, Blob.class};
       Class[] blobTypes = new Class[] {Blob.class};
 
-      BeanMap beanMap = new BeanMap("BinaryTypes")
-          .addField(new FieldMap("binaryCol").setTypes(binaryTypes).setSize(255))
-          .addField(new FieldMap("varbinaryCol").setTypes(binaryTypes).setSize(255))
-          .addField(new FieldMap("tinyblobCol").setTypes(binaryTypes).setSize(255))
-          .addField(new FieldMap("blobCol").setTypes(blobTypes).setSize(255))
-          .addField(new FieldMap("mediumblobCol").setTypes(binaryTypes).setSize(255))
-          .addField(new FieldMap("longblobCol").setTypes(binaryTypes).setSize(16384));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanMap beanMap =
+          new BeanMap("BinaryTypes")
+              .addField(new FieldMap("binaryCol").setTypes(binaryTypes).setSize(255))
+              .addField(new FieldMap("varbinaryCol").setTypes(binaryTypes).setSize(255))
+              .addField(new FieldMap("tinyblobCol").setTypes(binaryTypes).setSize(255))
+              .addField(new FieldMap("blobCol").setTypes(blobTypes).setSize(255))
+              .addField(new FieldMap("mediumblobCol").setTypes(binaryTypes).setSize(255))
+              .addField(new FieldMap("longblobCol").setTypes(binaryTypes).setSize(16384));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -71,27 +75,39 @@ public void testDatetimeTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
         OrmConnection ormConn = OrmConnection.of(conn, SormContext.builder().build())) {
 
-      BeanMap beanMap = new BeanMap("DatetimeTypes")
-          .addField(new FieldMap("dateCol").setTypes(java.sql.Date.class))
-          .addField(new FieldMap("timeCol").setTypes(java.sql.Time.class))
-          .addField(
-              new FieldMap("datetimeCol").setTypes(java.sql.Timestamp.class, java.util.Date.class))
-          .addField(new FieldMap("year4Col").setTypes(Short.class, short.class)
-              .setBoundaries(1901, 1999).setSupportsCompareMapValue(false));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        // BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanMap beanMap =
+          new BeanMap("DatetimeTypes")
+              .addField(new FieldMap("dateCol").setTypes(java.sql.Date.class))
+              .addField(new FieldMap("timeCol").setTypes(java.sql.Time.class))
+              .addField(
+                  new FieldMap("datetimeCol")
+                      .setTypes(java.sql.Timestamp.class, java.util.Date.class))
+              .addField(
+                  new FieldMap("year4Col")
+                      .setTypes(Short.class, short.class)
+                      .setBoundaries(1901, 1999)
+                      .setSupportsCompareMapValue(false));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            // BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -110,7 +126,8 @@ public void testNumericTypes() throws SQLException {
           new Class[] {Float.class, float.class, Double.class, double.class, BigDecimal.class};
 
       BeanMap beanMap =
-          new BeanMap("NumericTypes").addField(new FieldMap("bitCol").setTypes(booleanTypes))
+          new BeanMap("NumericTypes")
+              .addField(new FieldMap("bitCol").setTypes(booleanTypes))
               .addField(new FieldMap("booleanCol").setTypes(booleanTypes))
               .addField(new FieldMap("tinyintCol").setTypes(byteTypes))
               .addField(new FieldMap("smallintCol").setTypes(shortTypes))
@@ -121,19 +138,26 @@ public void testNumericTypes() throws SQLException {
               .addField(new FieldMap("doubleCol").setTypes(doubleTypes).setBoundaries(0, 9999))
               .addField(new FieldMap("decimalCol").setTypes(integerTypes));
 
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -148,31 +172,37 @@ public void testStringTypes() throws SQLException {
       // new Class[] {String.class, char[].class, Character[].class, Reader.class, Clob.class};
       Class[] clobTypes = new Class[] {String.class};
 
-      BeanMap beanMap = new BeanMap("StringTypes")
-          .addField(new FieldMap("charCol").setTypes(characterTypes).setSize(1))
-          .addField(new FieldMap("varcharCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("tinytextCol").setTypes(clobTypes).setSize(255))
-          .addField(new FieldMap("mediumtextCol").setTypes(clobTypes).setSize(1024))
-          .addField(new FieldMap("longtextCol").setTypes(clobTypes).setSize(16384))
-          .addField(new FieldMap("textCol").setTypes(clobTypes).setSize(16384))
-          .addField(new FieldMap("enumCol").setTypes(characterTypes).setSize(1));
+      BeanMap beanMap =
+          new BeanMap("StringTypes")
+              .addField(new FieldMap("charCol").setTypes(characterTypes).setSize(1))
+              .addField(new FieldMap("varcharCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("tinytextCol").setTypes(clobTypes).setSize(255))
+              .addField(new FieldMap("mediumtextCol").setTypes(clobTypes).setSize(1024))
+              .addField(new FieldMap("longtextCol").setTypes(clobTypes).setSize(16384))
+              .addField(new FieldMap("textCol").setTypes(clobTypes).setSize(16384))
+              .addField(new FieldMap("enumCol").setTypes(characterTypes).setSize(1));
       // .addField(new FieldMap("setCol").setTypes(characterTypes).setSize(1));
 
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
-
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/oracle/TestOracle.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/oracle/TestOracle.java
index 1752918f..b4d25d21 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/oracle/TestOracle.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/oracle/TestOracle.java
@@ -13,12 +13,10 @@
 import repackage.net.sf.persist.tests.engine.framework.DbEngineTestUtils;
 import repackage.net.sf.persist.tests.engine.framework.FieldMap;
 
-
 public class TestOracle {
 
   private static DataSource dataSource;
 
-
   @BeforeAll
   static void beforAll() {
     dataSource =
@@ -30,7 +28,6 @@ public static void main(String[] args) {
     beforAll();
   }
 
-
   @Test
   public void testBinaryTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
@@ -43,26 +40,40 @@ public void testBinaryTypes() throws SQLException {
       // statement
       // oracle doesn't support queries by long_raw or blob columns
       // only blobs support InputStream types
-      BeanMap beanMap = new BeanMap("BinaryTypes")
-          .addField(new FieldMap("rawCol").setTypes(binaryTypes).setSize(1024))
-          .addField(new FieldMap("longRawCol").setTypes(binaryTypes).setSize(1024)
-              .setSupportsQueryByValue(false))
-          .addField(new FieldMap("blobCol").setTypes(blobTypes).setSize(1024)
-              .setSupportsQueryByValue(false));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanMap beanMap =
+          new BeanMap("BinaryTypes")
+              .addField(new FieldMap("rawCol").setTypes(binaryTypes).setSize(1024))
+              .addField(
+                  new FieldMap("longRawCol")
+                      .setTypes(binaryTypes)
+                      .setSize(1024)
+                      .setSupportsQueryByValue(false))
+              .addField(
+                  new FieldMap("blobCol")
+                      .setTypes(blobTypes)
+                      .setSize(1024)
+                      .setSupportsQueryByValue(false));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -71,27 +82,36 @@ public void testDatetimeTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
         OrmConnection ormConn = OrmConnection.of(conn, SormContext.builder().build())) {
 
-      BeanMap beanMap = new BeanMap("DatetimeTypes")
-          // .addField(new FieldMap("dateCol").setTypes(java.sql.Date.class)) // oracle is picky
-          // about
-          // Date when used in
-          // queries
-          .addField(new FieldMap("timestampCol").setTypes(java.sql.Timestamp.class,
-              java.util.Date.class));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanMap beanMap =
+          new BeanMap("DatetimeTypes")
+              // .addField(new FieldMap("dateCol").setTypes(java.sql.Date.class)) // oracle is picky
+              // about
+              // Date when used in
+              // queries
+              .addField(
+                  new FieldMap("timestampCol")
+                      .setTypes(java.sql.Timestamp.class, java.util.Date.class));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -108,19 +128,26 @@ public void testNumericTypes() throws SQLException {
       BeanMap beanMap =
           new BeanMap("NumericTypes").addField(new FieldMap("numberCol").setTypes(longTypes));
 
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -134,28 +161,35 @@ public void testStringTypes() throws SQLException {
       // Class[] clobTypes = new Class[] {String.class, char[].class, Character[].class};
 
       // oracle doesn't support queries by clob, long or nclob
-      BeanMap beanMap = new BeanMap("StringTypes")
-          .addField(new FieldMap("char1Col").setTypes(characterTypes).setSize(1))
-          .addField(new FieldMap("nchar1Col").setTypes(characterTypes).setSize(1))
-          .addField(new FieldMap("charCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("ncharCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("nvarchar2Col").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("varchar2Col").setTypes(stringTypes).setSize(255));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanMap beanMap =
+          new BeanMap("StringTypes")
+              .addField(new FieldMap("char1Col").setTypes(characterTypes).setSize(1))
+              .addField(new FieldMap("nchar1Col").setTypes(characterTypes).setSize(1))
+              .addField(new FieldMap("charCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("ncharCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("nvarchar2Col").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("varchar2Col").setTypes(stringTypes).setSize(255));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/package-info.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/package-info.java
index 561ee36f..6ba8d9b8 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/package-info.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/package-info.java
@@ -1,7 +1,2 @@
-
-/**
- *
- * @see {@link https://github.com/r5v9/persist/tree/master/src/tests/net/sf/persist/tests}
- */
+/** @see {@link https://github.com/r5v9/persist/tree/master/src/tests/net/sf/persist/tests} */
 package repackage.net.sf.persist.tests.engine;
-
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/postgresql/TestPostgreSQL.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/postgresql/TestPostgreSQL.java
index 563fe403..3ebb682c 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/postgresql/TestPostgreSQL.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/postgresql/TestPostgreSQL.java
@@ -1,6 +1,5 @@
 package repackage.net.sf.persist.tests.engine.postgresql;
 
-
 import java.math.BigDecimal;
 import java.sql.Blob;
 import java.sql.Clob;
@@ -21,13 +20,12 @@ public class TestPostgreSQL {
 
   @BeforeAll
   static void beforAll() {
-    dataSource = DbEngineTestUtils.getDataSource(TestPostgreSQL.class,
-        "jdbc:h2:mem:postgre;MODE=PostgreSQL");
+    dataSource =
+        DbEngineTestUtils.getDataSource(
+            TestPostgreSQL.class, "jdbc:h2:mem:postgre;MODE=PostgreSQL");
     DbEngineTestUtils.executeSql(dataSource, TestPostgreSQL.class, "schema.sql");
   }
 
-
-
   @Test
   public void testBinaryTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
@@ -42,23 +40,36 @@ public void testBinaryTypes() throws SQLException {
       // for Blob columns therefore we won't test comparing the blobCol value returned from a map
       // with it
 
-      BeanMap beanMap = new BeanMap("BinaryTypes")
-          .addField(new FieldMap("byteaCol").setTypes(binaryTypes).setSize(16384))
-          .addField(new FieldMap("blobCol").setTypes(blobTypes).setSize(8192)
-              .setSupportsQueryByValue(false).setSupportsCompareMapValue(false));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
+      BeanMap beanMap =
+          new BeanMap("BinaryTypes")
+              .addField(new FieldMap("byteaCol").setTypes(binaryTypes).setSize(16384))
+              .addField(
+                  new FieldMap("blobCol")
+                      .setTypes(blobTypes)
+                      .setSize(8192)
+                      .setSupportsQueryByValue(false)
+                      .setSupportsCompareMapValue(false));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
 
       ormConn.commit();
     }
@@ -69,24 +80,33 @@ public void testDatetimeTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
         OrmConnection ormConn = OrmConnection.of(conn, SormContext.builder().build())) {
 
-      BeanMap beanMap = new BeanMap("DatetimeTypes")
-          .addField(new FieldMap("timeCol").setTypes(java.sql.Time.class))
-          .addField(new FieldMap("dateCol").setTypes(java.sql.Date.class))
-          .addField(new FieldMap("timestampCol").setTypes(java.sql.Timestamp.class,
-              java.util.Date.class));
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanMap beanMap =
+          new BeanMap("DatetimeTypes")
+              .addField(new FieldMap("timeCol").setTypes(java.sql.Time.class))
+              .addField(new FieldMap("dateCol").setTypes(java.sql.Date.class))
+              .addField(
+                  new FieldMap("timestampCol")
+                      .setTypes(java.sql.Timestamp.class, java.util.Date.class));
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -104,7 +124,8 @@ public void testNumericTypes() throws SQLException {
           new Class[] {Float.class, float.class, Double.class, double.class, BigDecimal.class};
 
       BeanMap beanMap =
-          new BeanMap("NumericTypes").addField(new FieldMap("smallintCol").setTypes(shortTypes))
+          new BeanMap("NumericTypes")
+              .addField(new FieldMap("smallintCol").setTypes(shortTypes))
               .addField(new FieldMap("integerCol").setTypes(integerTypes))
               .addField(new FieldMap("bigintCol").setTypes(longTypes))
               .addField(new FieldMap("decimalCol").setTypes(longTypes))
@@ -114,19 +135,26 @@ public void testNumericTypes() throws SQLException {
                   new FieldMap("doublePrecisionCol").setTypes(doubleTypes).setBoundaries(0, 9999))
               .addField(new FieldMap("booleanCol").setTypes(booleanTypes));
 
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
-
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
@@ -144,30 +172,40 @@ public void testStringTypes() throws SQLException {
       // postgres has a serious bug on returning java.sql.Types.BIGINT type on the ResultSetMetadata
       // for Clob columns therefore we won't test comparing the clobCol value returned from a map
       // with it
-      BeanMap beanMap = new BeanMap("StringTypes")
-          .addField(new FieldMap("char1Col").setTypes(characterTypes).setSize(1))
-          // .addField(new FieldMap("charCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("varcharCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("textCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("clobCol").setTypes(clobTypes).setSize(8192)
-              .setSupportsQueryByValue(false).setSupportsCompareMapValue(false));
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
+      BeanMap beanMap =
+          new BeanMap("StringTypes")
+              .addField(new FieldMap("char1Col").setTypes(characterTypes).setSize(1))
+              // .addField(new FieldMap("charCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("varcharCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("textCol").setTypes(stringTypes).setSize(255))
+              .addField(
+                  new FieldMap("clobCol")
+                      .setTypes(clobTypes)
+                      .setSize(8192)
+                      .setSupportsQueryByValue(false)
+                      .setSupportsCompareMapValue(false));
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
 
       ormConn.commit();
-
     }
   }
-
-
 }
diff --git a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/sqlserver/TestSqlserver.java b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/sqlserver/TestSqlserver.java
index c28a7c52..b7433d28 100644
--- a/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/sqlserver/TestSqlserver.java
+++ b/sorm4j/src/test/java/repackage/net/sf/persist/tests/engine/sqlserver/TestSqlserver.java
@@ -1,6 +1,5 @@
 package repackage.net.sf.persist.tests.engine.sqlserver;
 
-
 import java.math.BigDecimal;
 import java.sql.Connection;
 import java.sql.SQLException;
@@ -24,40 +23,48 @@ public static void main(String[] args) {
 
   @BeforeAll
   static void beforAll() {
-    dataSource = DbEngineTestUtils.getDataSource(TestSqlserver.class,
-        "jdbc:h2:mem:sqlserver;MODE=MSSQLServer");
+    dataSource =
+        DbEngineTestUtils.getDataSource(
+            TestSqlserver.class, "jdbc:h2:mem:sqlserver;MODE=MSSQLServer");
     DbEngineTestUtils.executeSql(dataSource, TestSqlserver.class, "schema.sql");
     conf = SormContext.builder().build();
-
   }
 
-
   @Test
   public void testStringTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
-        OrmConnection ormConn = OrmConnection.of(conn, conf);) {
+        OrmConnection ormConn = OrmConnection.of(conn, conf); ) {
       ormConn.setAutoCommit(false);
       Class[] characterTypes = new Class[] {String.class};
       Class[] stringTypes = new Class[] {String.class};
 
-      BeanMap beanMap = new BeanMap("StringTypes")
-          .addField(new FieldMap("charCol").setTypes(characterTypes).setSize(1))
-          .addField(new FieldMap("varcharCol").setTypes(stringTypes).setSize(255))
-          .addField(new FieldMap("ncharCol").setTypes(characterTypes).setSize(1))
-          .addField(new FieldMap("nvarcharCol").setTypes(stringTypes).setSize(255));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
+      BeanMap beanMap =
+          new BeanMap("StringTypes")
+              .addField(new FieldMap("charCol").setTypes(characterTypes).setSize(1))
+              .addField(new FieldMap("varcharCol").setTypes(stringTypes).setSize(255))
+              .addField(new FieldMap("ncharCol").setTypes(characterTypes).setSize(1))
+              .addField(new FieldMap("nvarcharCol").setTypes(stringTypes).setSize(255));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
 
       ormConn.commit();
     }
@@ -66,7 +73,7 @@ public void testStringTypes() throws SQLException {
   @Test
   public void testNumericTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
-        OrmConnection ormConn = OrmConnection.of(conn, conf);) {
+        OrmConnection ormConn = OrmConnection.of(conn, conf); ) {
 
       Class[] integerTypes = new Class[] {Integer.class, int.class};
       Class[] booleanTypes = new Class[] {Boolean.class, boolean.class};
@@ -78,7 +85,8 @@ public void testNumericTypes() throws SQLException {
           new Class[] {float.class, Double.class, double.class, BigDecimal.class};
 
       BeanMap beanMap =
-          new BeanMap("NumericTypes").addField(new FieldMap("bitCol").setTypes(booleanTypes))
+          new BeanMap("NumericTypes")
+              .addField(new FieldMap("bitCol").setTypes(booleanTypes))
               .addField(new FieldMap("tinyintCol").setTypes(byteTypes))
               .addField(new FieldMap("smallintCol").setTypes(shortTypes))
               .addField(new FieldMap("intCol").setTypes(integerTypes))
@@ -89,12 +97,16 @@ public void testNumericTypes() throws SQLException {
               .addField(new FieldMap("numericCol").setTypes(integerTypes))
               .addField(new FieldMap("floatCol").setTypes(floatTypes).setBoundaries(0, 9999))
               .addField(new FieldMap("realCol").setTypes(floatTypes).setBoundaries(0, 9999));
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
       // BeanTest.testNull(getClass(), ormConn, beanMap,objNull->{
       // BeanTest.testInsert(ormConn, objNull, beanMap);
       // BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
@@ -108,58 +120,76 @@ public void testNumericTypes() throws SQLException {
   @Test
   public void testDatetimeTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
-        OrmConnection ormConn = OrmConnection.of(conn, conf);) {
-
-      BeanMap beanMap = new BeanMap("DatetimeTypes")
-          .addField(new FieldMap("datetimeCol").setTypes(java.sql.Timestamp.class));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        // BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
+        OrmConnection ormConn = OrmConnection.of(conn, conf); ) {
 
+      BeanMap beanMap =
+          new BeanMap("DatetimeTypes")
+              .addField(new FieldMap("datetimeCol").setTypes(java.sql.Timestamp.class));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            // BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
     }
   }
 
   @Test
   public void testBinaryTypes() throws SQLException {
     try (Connection conn = dataSource.getConnection();
-        OrmConnection ormConn = OrmConnection.of(conn, conf);) {
+        OrmConnection ormConn = OrmConnection.of(conn, conf); ) {
 
       ormConn.setAutoCommit(false);
 
       Class[] binaryTypes = new Class[] {byte[].class};
 
-      BeanMap beanMap = new BeanMap("BinaryTypes")
-          .addField(new FieldMap("binaryCol").setTypes(binaryTypes).setSize(255))
-          .addField(new FieldMap("varbinaryCol").setTypes(binaryTypes).setSize(255))
-          .addField(new FieldMap("imageCol").setTypes(binaryTypes).setSize(16384)
-              .setSupportsQueryByValue(false));
-
-      BeanTest.test(getClass(), ormConn, beanMap, obj -> {
-        BeanTest.testInsert(ormConn, obj, beanMap);
-        BeanTest.testSelectByFields(ormConn, obj, beanMap);
-        BeanTest.testSelectFields(ormConn, obj, beanMap, false);
-        BeanTest.testSelectMap(ormConn, obj, beanMap);
-      });
-      BeanTest.testNull(getClass(), ormConn, beanMap, objNull -> {
-        BeanTest.testInsert(ormConn, objNull, beanMap);
-        BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
-        BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
-        BeanTest.testSelectMap(ormConn, objNull, beanMap);
-      });
+      BeanMap beanMap =
+          new BeanMap("BinaryTypes")
+              .addField(new FieldMap("binaryCol").setTypes(binaryTypes).setSize(255))
+              .addField(new FieldMap("varbinaryCol").setTypes(binaryTypes).setSize(255))
+              .addField(
+                  new FieldMap("imageCol")
+                      .setTypes(binaryTypes)
+                      .setSize(16384)
+                      .setSupportsQueryByValue(false));
+
+      BeanTest.test(
+          getClass(),
+          ormConn,
+          beanMap,
+          obj -> {
+            BeanTest.testInsert(ormConn, obj, beanMap);
+            BeanTest.testSelectByFields(ormConn, obj, beanMap);
+            BeanTest.testSelectFields(ormConn, obj, beanMap, false);
+            BeanTest.testSelectMap(ormConn, obj, beanMap);
+          });
+      BeanTest.testNull(
+          getClass(),
+          ormConn,
+          beanMap,
+          objNull -> {
+            BeanTest.testInsert(ormConn, objNull, beanMap);
+            BeanTest.testSelectByFieldsNull(ormConn, objNull, beanMap);
+            BeanTest.testSelectFields(ormConn, objNull, beanMap, true);
+            BeanTest.testSelectMap(ormConn, objNull, beanMap);
+          });
 
       ormConn.commit();
     }
   }
-
-
 }

From 156e90f3f3e8e5650d304d2579ec72711caf04b0 Mon Sep 17 00:00:00 2001
From: Yuu NAKAJIMA 
Date: Tue, 28 Nov 2023 10:40:12 +0900
Subject: [PATCH 3/4] Splits getJdbcConnection and openJdbcConnection
 explicitly.

---
 sorm4j/pom.xml                                | 26 +++++++++----------
 .../src/main/java/org/nkjmlab/sorm4j/Orm.java | 19 --------------
 .../org/nkjmlab/sorm4j/OrmConnection.java     |  7 +++++
 .../main/java/org/nkjmlab/sorm4j/Sorm.java    | 12 ++++++---
 .../sorm4j/internal/OrmConnectionImpl.java    | 10 +++----
 .../org/nkjmlab/sorm4j/internal/SormImpl.java |  7 ++---
 .../TableMappedOrmConnectionImpl.java         |  2 +-
 .../org/nkjmlab/sorm4j/table/BasicTable.java  | 22 ++++++++--------
 .../java/org/nkjmlab/sorm4j/table/Table.java  | 13 +++-------
 .../nkjmlab/sorm4j/table/TableMappedOrm.java  | 11 --------
 .../table/TableMappedOrmConnection.java       | 21 ++++++++++++---
 .../nkjmlab/sorm4j/util/h2/BasicH2Table.java  | 10 +++----
 .../table_def/BasicTableWithDefinition.java   | 12 ++++-----
 .../util/table_def/TableDefinition.java       |  9 ++++---
 .../DefaultSqlParametersSetterTest.java       |  4 +--
 .../sorm4j/internal/SormContextImplTest.java  |  2 +-
 .../nkjmlab/sorm4j/internal/SormImplTest.java |  4 +--
 .../internal/util/logger/SormLoggerTest.java  |  2 +-
 .../result/JdbcDatabaseMetaDataTest.java      |  6 ++---
 .../sorm4j/test/common/SormTestUtils.java     | 12 ++++++---
 .../sorm4j/util/h2/BasicH2TableTest.java      |  2 +-
 21 files changed, 105 insertions(+), 108 deletions(-)

diff --git a/sorm4j/pom.xml b/sorm4j/pom.xml
index b0ca66b1..85920021 100644
--- a/sorm4j/pom.xml
+++ b/sorm4j/pom.xml
@@ -4,7 +4,7 @@
 	4.0.0
 	org.nkjmlab
 	sorm4j
-	2.0.0
+	2.0.1
 	sorm4j
 	Simple micro Object-Relation Mapper for Java
 	https://github.com/yuu-nkjm/sorm4j
@@ -53,14 +53,14 @@
 		
 			org.apache.logging.log4j
 			log4j-api
-			2.20.0
+			2.22.0
 			true
 		
 		
 		
 			org.slf4j
 			slf4j-api
-			2.0.7
+			2.0.9
 			true
 		
 		
@@ -82,7 +82,7 @@
 		
 			com.h2database
 			h2
-			2.1.214
+			2.2.224
 			true
 		
 		
@@ -112,14 +112,14 @@
 		
 			org.apache.logging.log4j
 			log4j-iostreams
-			2.20.0
+			2.22.0
 			test
 		
 		
 		
 			org.mockito
 			mockito-core
-			5.3.1
+			5.7.0
 			test
 		
 		
@@ -149,7 +149,7 @@
 		
 			org.postgresql
 			postgresql
-			42.6.0
+			42.7.0
 			test
 		
 		
 		
 			com.oracle.database.jdbc
 			ojdbc10
-			19.18.0.0
+			19.21.0.0
 			test
 		
 	
diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/Orm.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/Orm.java
index 00f31692..af39ec3f 100644
--- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/Orm.java
+++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/Orm.java
@@ -38,25 +38,6 @@ public interface Orm {
   @Experimental
   SormContext getContext();
 
-  /**
-   * Gets JDBC {@link Connection}.
-   *
-   * @return
-   */
-  Connection getJdbcConnection();
-
-  /**
-   * Create a {@link OrmConnection} wrapping a JDBC Connection.
-   *
-   * 

You should always use try-with-resources block to ensure the database connection is - * released. - * - * @return - */ - default OrmConnection getOrmConnection() { - return OrmConnection.of(getJdbcConnection(), getContext()); - } - /** * Deletes objects from the table corresponding to the class of the given objects. * diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmConnection.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmConnection.java index c981f3ce..f877bc54 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmConnection.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/OrmConnection.java @@ -37,6 +37,13 @@ static OrmConnection of(Connection connection, SormContext sormContext) { return new OrmConnectionImpl(connection, SormContextImpl.class.cast(sormContext)); } + /** + * Gets JDBC {@link Connection}. + * + * @return + */ + Connection getJdbcConnection(); + /** * Closes the {@link java.sql.Connection Connection} associated with this instance. * diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/Sorm.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/Sorm.java index ca4a346c..38b36d5e 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/Sorm.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/Sorm.java @@ -24,9 +24,8 @@ public interface Sorm extends Orm { * *

For example, * - *

-   *  *   
-   *  *  *  *    * DataSource dataSource = org.h2.jdbcx.JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;","sa","");
+   * 

+   *  DataSource dataSource = org.h2.jdbcx.JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;","sa","");
    * Sorm.create(dataSource);
    * 
* @@ -150,6 +149,13 @@ static SormContext getDefaultContext() { */ DataSource getDataSource(); + /** + * Opens JDBC {@link Connection}. + * + * @return + */ + Connection openJdbcConnection(); + /** * Open {@link OrmConnection}. You should always use try-with-resources block to * ensure the database connection is released. diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmConnectionImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmConnectionImpl.java index 0a2397b5..078102b1 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmConnectionImpl.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/OrmConnectionImpl.java @@ -329,11 +329,6 @@ public SormContext getContext() { return sormContext; } - @Override - public Connection getJdbcConnection() { - return connection; - } - @Override public JdbcDatabaseMetaData getJdbcDatabaseMetaData() { try { @@ -1181,4 +1176,9 @@ public TableMappedOrmConnection mapToTable(Class type) { public TableMappedOrmConnection mapToTable(Class type, String tableName) { return new TableMappedOrmConnectionImpl<>(this, type, tableName); } + + @Override + public Connection getJdbcConnection() { // TODO Auto-generated method stub + return connection; + } } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormImpl.java index 5fbef20b..11475161 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormImpl.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/SormImpl.java @@ -56,7 +56,7 @@ public SormImpl(DataSource connectionSource, SormContextImpl context) { @Override public OrmTransaction open(int isolationLevel) { - return new OrmTransactionImpl(getJdbcConnection(), sormContext, isolationLevel); + return new OrmTransactionImpl(openJdbcConnection(), sormContext, isolationLevel); } @Override @@ -97,7 +97,7 @@ public SormContext getContext() { @Override public OrmConnectionImpl open() { - return new OrmConnectionImpl(getJdbcConnection(), sormContext); + return new OrmConnectionImpl(openJdbcConnection(), sormContext); } @Override @@ -105,8 +105,9 @@ public DataSource getDataSource() { return this.dataSource; } + @Override - public Connection getJdbcConnection() { + public Connection openJdbcConnection() { try { return dataSource.getConnection(); } catch (SQLException e) { diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/TableMappedOrmConnectionImpl.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/TableMappedOrmConnectionImpl.java index 14fbe46e..8a45ddb9 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/TableMappedOrmConnectionImpl.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/internal/TableMappedOrmConnectionImpl.java @@ -5,9 +5,9 @@ public class TableMappedOrmConnectionImpl implements TableMappedOrmConnection { - private final String tableName; private final OrmConnection ormConn; private final Class valueType; + private final String tableName; public TableMappedOrmConnectionImpl(OrmConnection ormConn, Class valueType, String tableName) { this.ormConn = ormConn; diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java index 48138a79..03021e1b 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/BasicTable.java @@ -1,16 +1,16 @@ package org.nkjmlab.sorm4j.table; -import org.nkjmlab.sorm4j.Sorm; +import org.nkjmlab.sorm4j.Orm; import org.nkjmlab.sorm4j.util.sql.SqlKeyword; public class BasicTable implements Table, SqlKeyword { - private final Sorm sorm; + private final Orm orm; private final Class valueType; private final String tableName; - public BasicTable(Sorm sorm, Class valueType, String tableName) { - this.sorm = sorm; + public BasicTable(Orm orm, Class valueType, String tableName) { + this.orm = orm; this.valueType = valueType; this.tableName = tableName; } @@ -18,11 +18,11 @@ public BasicTable(Sorm sorm, Class valueType, String tableName) { /** * This table instance is bind to the table name is mapped to the given {@link valueType}. * - * @param sorm + * @param orm * @param valueType */ - public BasicTable(Sorm sorm, Class valueType) { - this(sorm, valueType, sorm.getTableName(valueType)); + public BasicTable(Orm orm, Class valueType) { + this(orm, valueType, orm.getTableName(valueType)); } @Override @@ -31,12 +31,12 @@ public Class getValueType() { } @Override - public Sorm getOrm() { - return sorm; + public String getTableName() { + return tableName; } @Override - public String getTableName() { - return tableName; + public Orm getOrm() { + return orm; } } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/Table.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/Table.java index 33a79a58..261abac9 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/Table.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/Table.java @@ -1,20 +1,13 @@ package org.nkjmlab.sorm4j.table; -import org.nkjmlab.sorm4j.Sorm; +import org.nkjmlab.sorm4j.Orm; import org.nkjmlab.sorm4j.annotation.Experimental; @Experimental public interface Table extends TableMappedOrm { - /** - * Gets Sorm objects - * - * @return - */ - @Override - Sorm getOrm(); - static Table create(Sorm sorm, Class objectClass) { - return new BasicTable<>(sorm, objectClass); + static Table create(Orm orm, Class objectClass) { + return new BasicTable<>(orm, objectClass); } } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrm.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrm.java index a2cdfe47..603509c6 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrm.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrm.java @@ -24,17 +24,6 @@ @Experimental public interface TableMappedOrm { - /** - * Create a {@link TableMappedOrmConnection} wrapping a JDBC Connection. - * - *

You should always use try-with-resources block to ensure the database connection is - * released. - * - * @return - */ - default TableMappedOrmConnection getTableMappedOrmConnection() { - return TableMappedOrmConnection.of(getOrm().getOrmConnection(), getValueType()); - } /** * Gets {@link Orm} object * diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrmConnection.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrmConnection.java index be26182b..4a998c9e 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrmConnection.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/table/TableMappedOrmConnection.java @@ -12,15 +12,13 @@ public interface TableMappedOrmConnection extends TableMappedOrm { * * @return */ + @Override OrmConnection getOrm(); /** - * Create a {@link TableMappedOrmConnection} wrapping the given JDBC Connection and the given + * Gets a {@link TableMappedOrmConnection} wrapping the given JDBC Connection and the given * context. * - *

You should always use try-with-resources block to ensure the database connection is - * released. - * * @param * @param connection * @param valueType @@ -29,4 +27,19 @@ public interface TableMappedOrmConnection extends TableMappedOrm { static TableMappedOrmConnection of(OrmConnection connection, Class valueType) { return new TableMappedOrmConnectionImpl(connection, valueType); } + + /** + * Gets a {@link TableMappedOrmConnection} wrapping the given JDBC Connection and the given + * context. + * + * @param + * @param connection + * @param valueType + * @param tableName + * @return + */ + static TableMappedOrmConnection of( + OrmConnection connection, Class valueType, String tableName) { + return new TableMappedOrmConnectionImpl(connection, valueType, tableName); + } } diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/BasicH2Table.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/BasicH2Table.java index a4f91aaf..f71839ba 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/BasicH2Table.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/BasicH2Table.java @@ -1,6 +1,6 @@ package org.nkjmlab.sorm4j.util.h2; -import org.nkjmlab.sorm4j.Sorm; +import org.nkjmlab.sorm4j.Orm; import org.nkjmlab.sorm4j.annotation.Experimental; import org.nkjmlab.sorm4j.util.table_def.BasicTableWithDefinition; import org.nkjmlab.sorm4j.util.table_def.TableDefinition; @@ -15,8 +15,8 @@ public class BasicH2Table extends BasicTableWithDefinition implements H2Ta * @param valueType * @param tableDifinition */ - public BasicH2Table(Sorm sorm, Class valueType, TableDefinition tableDifinition) { - super(sorm, valueType, tableDifinition); + public BasicH2Table(Orm orm, Class valueType, TableDefinition tableDifinition) { + super(orm, valueType, tableDifinition); } /** @@ -25,8 +25,8 @@ public BasicH2Table(Sorm sorm, Class valueType, TableDefinition tableDifiniti * @param sorm * @param valueType */ - public BasicH2Table(Sorm sorm, Class valueType) { - this(sorm, valueType, TableDefinition.builder(valueType).build()); + public BasicH2Table(Orm orm, Class valueType) { + this(orm, valueType, TableDefinition.builder(valueType).build()); } @Experimental diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/BasicTableWithDefinition.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/BasicTableWithDefinition.java index 7c2142f0..1d6f0d0b 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/BasicTableWithDefinition.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/BasicTableWithDefinition.java @@ -1,6 +1,6 @@ package org.nkjmlab.sorm4j.util.table_def; -import org.nkjmlab.sorm4j.Sorm; +import org.nkjmlab.sorm4j.Orm; import org.nkjmlab.sorm4j.annotation.Experimental; import org.nkjmlab.sorm4j.table.BasicTable; @@ -12,17 +12,17 @@ public class BasicTableWithDefinition extends BasicTable implements TableW /** * This table instance is bind to the table name defined in the given {@link TableDefinition}. * - * @param sorm + * @param orm * @param valueType * @param tableDefinition */ - public BasicTableWithDefinition(Sorm sorm, Class valueType, TableDefinition tableDefinition) { - super(sorm, valueType, tableDefinition.getTableName()); + public BasicTableWithDefinition(Orm orm, Class valueType, TableDefinition tableDefinition) { + super(orm, valueType, tableDefinition.getTableName()); this.tableDefinition = tableDefinition; } - public BasicTableWithDefinition(Sorm sorm, Class valueType) { - this(sorm, valueType, TableDefinition.builder(valueType).build()); + public BasicTableWithDefinition(Orm orm, Class valueType) { + this(orm, valueType, TableDefinition.builder(valueType).build()); } @Override diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableDefinition.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableDefinition.java index 217d3c31..ad53c04f 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableDefinition.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/table_def/TableDefinition.java @@ -1,7 +1,8 @@ package org.nkjmlab.sorm4j.util.table_def; -import static java.lang.String.*; -import static org.nkjmlab.sorm4j.internal.util.StringCache.*; +import static java.lang.String.join; +import static org.nkjmlab.sorm4j.internal.util.StringCache.toUpperSnakeCase; + import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -17,8 +18,8 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; + import org.nkjmlab.sorm4j.Orm; -import org.nkjmlab.sorm4j.Sorm; import org.nkjmlab.sorm4j.annotation.Experimental; import org.nkjmlab.sorm4j.annotation.OrmTable; import org.nkjmlab.sorm4j.common.TableMetaData; @@ -202,7 +203,7 @@ public TableDefinition dropTableIfExists(Orm orm) { return this; } - public void dropTableIfExistsCascade(Sorm orm) { + public void dropTableIfExistsCascade(Orm orm) { orm.executeUpdate(getDropTableIfExistsStatement() + " cascade"); } diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetterTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetterTest.java index 0d198a9f..0b8490c4 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetterTest.java +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/context/DefaultSqlParametersSetterTest.java @@ -20,7 +20,7 @@ class DefaultSqlParametersSetterTest { @Test void testArray() { Sorm sorm = createSormWithNewDatabaseAndCreateTables(); - try (Connection conn = sorm.getJdbcConnection(); + try (Connection conn = sorm.openJdbcConnection(); PreparedStatement pstmt = conn.prepareStatement("select * from guests where id=?")) { assertThat(toSqlArray("boolean", conn, TestUtils.PRIMITIVE_BOOLEAN_ARRAY).getBaseType()) @@ -132,7 +132,7 @@ void testSetParameters() { sorm.readFirst(RowMap.class, "select * from TA where arry=?", (Object) new Double[] {0.1d}); DefaultSqlParametersSetter setter = new DefaultSqlParametersSetter(); - try (Connection conn = sorm.getJdbcConnection(); + try (Connection conn = sorm.openJdbcConnection(); PreparedStatement pstmt = conn.prepareStatement("select * from guests where id=?")) { setter.setParameters(pstmt, (Object[]) null); diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormContextImplTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormContextImplTest.java index a5f1e0fa..509630bb 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormContextImplTest.java +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormContextImplTest.java @@ -46,7 +46,7 @@ void testBuild() { Sorm sorm = SormTestUtils.createSormWithNewDatabaseAndCreateTables(context); - try (Connection conn = sorm.getJdbcConnection()) { + try (Connection conn = sorm.openJdbcConnection()) { assertThatThrownBy(() -> SormImpl.DEFAULT_CONTEXT.getTableName(conn, Temporary.class)) .isInstanceOfSatisfying( SormException.class, e -> assertThat(e.getMessage()).contains("TEMPORARIES")); diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormImplTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormImplTest.java index bc074bc3..39dcb5b9 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormImplTest.java +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/SormImplTest.java @@ -68,7 +68,7 @@ void readMapOne() { sorm.insert(SormTestUtils.GUEST_ALICE); Table.create(sorm, Guest.class); - try (Connection conn = sorm.getJdbcConnection()) { + try (Connection conn = sorm.openJdbcConnection()) { assertThat(SormImpl.DEFAULT_CONTEXT.getTableMapping(conn, "guests", Guest.class).toString()) .contains("CsvColumn"); } catch (SQLException e) { @@ -100,7 +100,7 @@ void testException() throws SQLException { Sorm sorm = Sorm.create(dsMock); try { - sorm.getJdbcConnection(); + sorm.openJdbcConnection(); failBecauseExceptionWasNotThrown(Exception.class); } catch (Exception e) { } diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/logger/SormLoggerTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/logger/SormLoggerTest.java index 910f1ad1..83265ffd 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/logger/SormLoggerTest.java +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/internal/util/logger/SormLoggerTest.java @@ -86,7 +86,7 @@ void testLogAfterQuery() { assertThat(text).contains("Affect [1] rows"); } - try (Connection conn = sorm.getJdbcConnection()) { + try (Connection conn = sorm.openJdbcConnection()) { { String text = proc( diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaDataTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaDataTest.java index 4adc2856..b2bcb431 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaDataTest.java +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/result/JdbcDatabaseMetaDataTest.java @@ -13,14 +13,14 @@ class JdbcDatabaseMetaDataTest { void test() { TableWithDefinition playersTable = SormTestUtils.createPlayersTable(SormTestUtils.createSormWithNewContext()); - String version = "2.1.214 (2022-06-13)"; + String version = "2."; JdbcDatabaseMetaData md = playersTable.getOrm().getJdbcDatabaseMetaData(); assertThat(md.getDatabaseProductName()).isEqualTo("H2"); - assertThat(md.getDatabaseProductVersion()).isEqualTo(version); + assertThat(md.getDatabaseProductVersion()).contains(version); assertThat(md.getDefaultTransactionIsolation()) .isEqualTo(Connection.TRANSACTION_READ_COMMITTED); assertThat(md.getDriverName()).isEqualTo("H2 JDBC Driver"); - assertThat(md.getDriverVersion()).isEqualTo(version); + assertThat(md.getDriverVersion()).contains(version); assertThat(md.getJdbcTablesMetaData().get("PLAYERS").get("TABLE_NAME")).isEqualTo("PLAYERS"); assertThat(md.getMaxConnections()).isEqualTo(0); assertThat(md.getSearchStringEscape()).isEqualTo("\\"); diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/SormTestUtils.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/SormTestUtils.java index 65132045..8a12af22 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/SormTestUtils.java +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/test/common/SormTestUtils.java @@ -1,7 +1,13 @@ package org.nkjmlab.sorm4j.test.common; -import static org.nkjmlab.sorm4j.util.sql.SqlKeyword.*; +import static org.nkjmlab.sorm4j.util.sql.SqlKeyword.AUTO_INCREMENT; +import static org.nkjmlab.sorm4j.util.sql.SqlKeyword.INT; +import static org.nkjmlab.sorm4j.util.sql.SqlKeyword.PRIMARY_KEY; +import static org.nkjmlab.sorm4j.util.sql.SqlKeyword.VARCHAR; + import java.util.concurrent.atomic.AtomicInteger; + +import org.nkjmlab.sorm4j.Orm; import org.nkjmlab.sorm4j.Sorm; import org.nkjmlab.sorm4j.common.DriverManagerDataSource; import org.nkjmlab.sorm4j.context.SormContext; @@ -76,7 +82,7 @@ public Class getValueType() { } @Override - public Sorm getOrm() { + public Orm getOrm() { return sorm; } @@ -111,7 +117,7 @@ public Class getValueType() { } @Override - public Sorm getOrm() { + public Orm getOrm() { return sorm; } }; diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/BasicH2TableTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/BasicH2TableTest.java index 8eb150fd..03bd43a8 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/BasicH2TableTest.java +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/BasicH2TableTest.java @@ -29,7 +29,7 @@ void test2() throws InterruptedException { table.dropTableIfExists(); table.createTableIfNotExists(); - try (Connection con = sorm.getJdbcConnection()) { + try (Connection con = sorm.openJdbcConnection()) { PreparedStatement ps = con.prepareStatement("insert into ORM_RECORD_EXAMPLES VALUES(?,?,? format json)"); ps.setInt(1, 3); From 9d60b39f0ff5a66ac06f7ffd0d262d5b23679b4c Mon Sep 17 00:00:00 2001 From: Yuu NAKAJIMA Date: Tue, 28 Nov 2023 11:22:46 +0900 Subject: [PATCH 4/4] Follow the changes of h2 database --- .../sorm4j/util/h2/server/H2WebConsoleServerProperties.java | 5 +++-- .../sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java | 3 +++ .../org/nkjmlab/sorm4j/util/h2/server/h2.tcpsrv.json.sample | 2 +- .../org/nkjmlab/sorm4j/util/h2/server/h2.webcon.json.sample | 3 +-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProperties.java b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProperties.java index f3b38af6..0c32835f 100644 --- a/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProperties.java +++ b/sorm4j/src/main/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProperties.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import org.nkjmlab.sorm4j.annotation.Experimental; /** @@ -31,8 +32,8 @@ public H2WebConsoleServerProperties build() { new ArrayList<>(List.of(javaCommand, "-cp", getH2ClassPath(), "org.h2.tools.Server")); args.addAll(List.of("-web", "-webPort", port + "")); args.addAll(Arrays.asList(options)); - args.add("-webAdminPassword"); - args.add(password); + // args.add("-webAdminPassword"); + // args.add(password); return new H2WebConsoleServerProperties( serverType, port, password, args.toArray(String[]::new)); } diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java index 3c8d3157..ee96c4c4 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/H2WebConsoleServerProcessTest.java @@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; class H2WebConsoleServerProcessTest { + static final org.apache.logging.log4j.Logger log = + org.apache.logging.log4j.LogManager.getLogger(); @Test void testAwaitStart() throws StreamReadException, DatabindException, IOException { @@ -19,6 +21,7 @@ void testAwaitStart() throws StreamReadException, DatabindException, IOException H2WebConsoleServerProcess server = new H2WebConsoleServerProcess(prop); server.awaitStart(); + log.debug("started"); ProcessUtils.stopProcessBindingPortIfExists(prop.port); } } diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/h2.tcpsrv.json.sample b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/h2.tcpsrv.json.sample index b8bf3aab..6c2dc507 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/h2.tcpsrv.json.sample +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/h2.tcpsrv.json.sample @@ -1,5 +1,5 @@ { "password": "password", "port": 65432, - "h2ClassPath": "~/tmp/h2/h2-2.1.214.jar" + "h2ClassPath": "~/.m2/repository/com/h2database/h2/2.2.224/h2-2.2.224.jar" } diff --git a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/h2.webcon.json.sample b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/h2.webcon.json.sample index 556a87bd..2ea663c1 100644 --- a/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/h2.webcon.json.sample +++ b/sorm4j/src/test/java/org/nkjmlab/sorm4j/util/h2/server/h2.webcon.json.sample @@ -1,5 +1,4 @@ { - "password": "password", "port": 65431, - "h2ClassPath": "~/tmp/h2/h2-2.1.214.jar" + "h2ClassPath": "~/.m2/repository/com/h2database/h2/2.2.224/h2-2.2.224.jar" }