From eef962fb011a5d8d0912568f8eac1ebe5dac9887 Mon Sep 17 00:00:00 2001 From: haiyangl Date: Sat, 15 Jun 2024 12:39:20 -0700 Subject: [PATCH] 3.5.17 --- .classpath | 3 +- CHANGES.md | 4 ++ README.md | 6 +- .../abacus-jdbc-0.0.1-SNAPSHOT.pom | 6 +- pom.xml | 10 ++-- .../landawn/abacus/jdbc/AbstractQuery.java | 10 ++-- .../abacus/jdbc/CodeGenerationUtil.java | 2 +- .../java/com/landawn/abacus/jdbc/Jdbc.java | 12 ++-- .../com/landawn/abacus/jdbc/JdbcUtil.java | 56 +++++++++---------- .../com/landawn/abacus/jdbc/JdbcUtils.java | 48 ++++++++-------- src/test/java/com/landawn/abacus/Maven.java | 2 +- 11 files changed, 82 insertions(+), 77 deletions(-) diff --git a/.classpath b/.classpath index 290f5a32..df1d069d 100644 --- a/.classpath +++ b/.classpath @@ -1,5 +1,6 @@ + @@ -14,9 +15,9 @@ - + diff --git a/CHANGES.md b/CHANGES.md index 9479db84..cf9fb040 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +### 3.5.17 + +* Improvements and bug fix. + ### 3.5.16 * Improvements and bug fix. diff --git a/README.md b/README.md index 1e423845..d22b5b15 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # abacus-jdbc [![Maven Central](https://img.shields.io/maven-central/v/com.landawn/abacus-jdbc.svg)](https://maven-badges.herokuapp.com/maven-central/com.landawn/abacus-jdbc/) -[![Javadocs](https://img.shields.io/badge/javadoc-3.5.16-brightgreen.svg)](https://www.javadoc.io/doc/com.landawn/abacus-jdbc/3.5.16/index.html) +[![Javadocs](https://img.shields.io/badge/javadoc-3.5.17-brightgreen.svg)](https://www.javadoc.io/doc/com.landawn/abacus-jdbc/3.5.17/index.html) Hope it will bring you the programming experiences: coding with SQL/DB is just like coding with Collections. @@ -141,7 +141,7 @@ The biggest difference between this library and other data(database) access fram com.landawn abacus-jdbc - 3.5.16 + 3.5.17 ``` @@ -149,7 +149,7 @@ The biggest difference between this library and other data(database) access fram ```gradle // JDK 17 or above: -compile 'com.landawn:abacus-jdbc:3.5.16' +compile 'com.landawn:abacus-jdbc:3.5.17' ``` ## User Guide: diff --git a/maven/0.0.1-SNAPSHOT/abacus-jdbc-0.0.1-SNAPSHOT.pom b/maven/0.0.1-SNAPSHOT/abacus-jdbc-0.0.1-SNAPSHOT.pom index bd62f63e..2ee25318 100644 --- a/maven/0.0.1-SNAPSHOT/abacus-jdbc-0.0.1-SNAPSHOT.pom +++ b/maven/0.0.1-SNAPSHOT/abacus-jdbc-0.0.1-SNAPSHOT.pom @@ -77,19 +77,19 @@ com.landawn abacus-common - 3.11.7 + 3.12.0 com.landawn abacus-query - 1.3.21 + 1.3.22 com.landawn abacus-cache - 0.9.8 + 1.1 diff --git a/pom.xml b/pom.xml index a85db613..aefc1865 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.landawn abacus-jdbc - 3.5.17 + 3.5.18 jar abacus-jdbc @@ -25,28 +25,28 @@ org.projectlombok lombok - 1.18.30 + 1.18.32 provided com.landawn abacus-common - 3.11.7 + 3.12.0 provided com.landawn abacus-query - 1.3.21 + 1.3.22 provided com.landawn abacus-cache - 0.9.8 + 1.1 provided diff --git a/src/main/java/com/landawn/abacus/jdbc/AbstractQuery.java b/src/main/java/com/landawn/abacus/jdbc/AbstractQuery.java index 9de868ef..38f97e26 100644 --- a/src/main/java/com/landawn/abacus/jdbc/AbstractQuery.java +++ b/src/main/java/com/landawn/abacus/jdbc/AbstractQuery.java @@ -3492,13 +3492,13 @@ public Optional queryForUniqueNonNull(final Type targetType) /** * - * @param - * @param targetType * @param rs + * @param targetType + * @param * @return * @throws SQLException */ - private static T getRow(final Class targetType, ResultSet rs) throws SQLException { + private static T getRow(ResultSet rs, final Class targetType) throws SQLException { final List columnLabels = JdbcUtil.getColumnLabelList(rs); return Jdbc.BiRowMapper.to(targetType).apply(rs, columnLabels); @@ -3972,7 +3972,7 @@ public T findOnlyOneOrNull(final Class targetType) throws Dupli try (ResultSet rs = executeQuery()) { if (rs.next()) { - final T result = Objects.requireNonNull(getRow(targetType, rs)); + final T result = Objects.requireNonNull(getRow(rs, targetType)); if (rs.next()) { throw new DuplicatedResultException("More than one record found by the query"); @@ -4145,7 +4145,7 @@ public T findFirstOrNull(final Class targetType) throws SQLExce try (ResultSet rs = executeQuery()) { if (rs.next()) { - return Objects.requireNonNull(getRow(targetType, rs)); + return Objects.requireNonNull(getRow(rs, targetType)); } return null; diff --git a/src/main/java/com/landawn/abacus/jdbc/CodeGenerationUtil.java b/src/main/java/com/landawn/abacus/jdbc/CodeGenerationUtil.java index 1ce73ca3..8d3e9217 100644 --- a/src/main/java/com/landawn/abacus/jdbc/CodeGenerationUtil.java +++ b/src/main/java/com/landawn/abacus/jdbc/CodeGenerationUtil.java @@ -454,7 +454,7 @@ static String generateEntityClass(final String entityName, final ResultSet rs, f IOUtil.createIfNotExists(file); - IOUtil.write(file, result); + IOUtil.write(result, file); } return result; diff --git a/src/main/java/com/landawn/abacus/jdbc/Jdbc.java b/src/main/java/com/landawn/abacus/jdbc/Jdbc.java index dff8a0c2..2772b7b8 100644 --- a/src/main/java/com/landawn/abacus/jdbc/Jdbc.java +++ b/src/main/java/com/landawn/abacus/jdbc/Jdbc.java @@ -664,7 +664,7 @@ static ResultExtractor> toMergedList(final Class target * @param targetClass * @param idPropNameForMerge * @return - * @see DataSet#toMergedEntities(Class, Collection, Collection) + * @see DataSet#toMergedEntities(Collection, Collection, Class) */ static ResultExtractor> toMergedList(final Class targetClass, final String idPropNameForMerge) { N.checkArgNotNull(targetClass, "targetClass"); @@ -672,7 +672,7 @@ static ResultExtractor> toMergedList(final Class target return rs -> { final RowExtractor rowExtractor = RowExtractor.createBy(targetClass); - return JdbcUtil.extractData(rs, 0, Integer.MAX_VALUE, rowExtractor, false).toMergedEntities(targetClass, idPropNameForMerge); + return JdbcUtil.extractData(rs, 0, Integer.MAX_VALUE, rowExtractor, false).toMergedEntities(idPropNameForMerge, targetClass); }; } @@ -681,7 +681,7 @@ static ResultExtractor> toMergedList(final Class target * @param targetClass * @param idPropNamesForMerge * @return - * @see DataSet#toMergedEntities(Class, Collection, Collection) + * @see DataSet#toMergedEntities(Collection, Collection, Class) */ static ResultExtractor> toMergedList(final Class targetClass, Collection idPropNamesForMerge) { N.checkArgNotNull(targetClass, "targetClass"); @@ -689,7 +689,7 @@ static ResultExtractor> toMergedList(final Class target return rs -> { final RowExtractor rowExtractor = RowExtractor.createBy(targetClass); - return JdbcUtil.extractData(rs, 0, Integer.MAX_VALUE, rowExtractor, false).toMergedEntities(targetClass, idPropNamesForMerge); + return JdbcUtil.extractData(rs, 0, Integer.MAX_VALUE, rowExtractor, false).toMergedEntities(idPropNamesForMerge, targetClass); }; } @@ -4626,7 +4626,7 @@ public static RowMapper get(final Type type) { * @return */ public static RowMapper readJson(final Class targetType) { - return rs -> N.fromJSON(targetType, rs.getString(1)); + return rs -> N.fromJSON(rs.getString(1), targetType); } /** @@ -4637,7 +4637,7 @@ public static RowMapper readJson(final Class targetType) { * @return */ public static RowMapper readXml(final Class targetType) { - return rs -> N.fromXML(targetType, rs.getString(1)); + return rs -> N.fromXML(rs.getString(1), targetType); } /** diff --git a/src/main/java/com/landawn/abacus/jdbc/JdbcUtil.java b/src/main/java/com/landawn/abacus/jdbc/JdbcUtil.java index 92d680c1..6da70b35 100644 --- a/src/main/java/com/landawn/abacus/jdbc/JdbcUtil.java +++ b/src/main/java/com/landawn/abacus/jdbc/JdbcUtil.java @@ -3952,12 +3952,12 @@ public static DataSet extractData(final ResultSet rs, final int offset, final in } /** - * * - * @param rs - * @param filter - * @return - * @throws SQLException + * + * @param rs + * @param filter + * @return + * @throws SQLException */ public static DataSet extractData(final ResultSet rs, final RowFilter filter) throws SQLException { return extractData(rs, 0, Integer.MAX_VALUE, filter, INTERNAL_DUMMY_ROW_EXTRACTOR, false); @@ -4227,10 +4227,10 @@ public static CheckedStream stream(final ResultSet resul *
* {@code JdbcUtil.stream(resultset).onClose(Fn.closeQuietly(resultSet))...} * - * @param - * @param resultSet + * @param + * @param resultSet * @param targetClass Array/List/Map or Entity with getter/setter methods. - * @return + * @return */ public static CheckedStream stream(final ResultSet resultSet, final Class targetClass) { N.checkArgNotNull(targetClass, "targetClass"); @@ -4761,13 +4761,13 @@ public static CheckedStream queryByPage(final javax.sql.D /** * Runs a {@code Stream} with each element(page) is loaded from database table by running sql {@code query}. * - * @param - * @param ds + * @param + * @param ds * @param query this query must be ordered by at least one key/id and has the result size limitation: for example {@code LIMIT pageSize}, {@code ROWS FETCH NEXT pageSize ROWS ONLY} - * @param pageSize + * @param pageSize * @param paramSetter the second parameter is the result set for previous page. it's {@code null} for first page. - * @param resultExtractor - * @return + * @param resultExtractor + * @return */ @SuppressWarnings("rawtypes") public static CheckedStream queryByPage(final javax.sql.DataSource ds, final String query, final int pageSize, @@ -4794,13 +4794,13 @@ public static CheckedStream queryByPage(final javax.sql.Dat /** * Runs a {@code Stream} with each element(page) is loaded from database table by running sql {@code query}. * - * @param - * @param ds + * @param + * @param ds * @param query this query must be ordered by at least one key/id and has the result size limitation: for example {@code LIMIT pageSize}, {@code ROWS FETCH NEXT pageSize ROWS ONLY} - * @param pageSize + * @param pageSize * @param paramSetter the second parameter is the result set for previous page. it's {@code null} for first page. - * @param resultExtractor - * @return + * @param resultExtractor + * @return */ @SuppressWarnings("rawtypes") public static CheckedStream queryByPage(final javax.sql.DataSource ds, final String query, final int pageSize, @@ -4842,13 +4842,13 @@ public static CheckedStream queryByPage(final Connection /** * Runs a {@code Stream} with each element(page) is loaded from database table by running sql {@code query}. * - * @param - * @param conn + * @param + * @param conn * @param query this query must be ordered by at least one key/id and has the result size limitation: for example {@code LIMIT pageSize}, {@code ROWS FETCH NEXT pageSize ROWS ONLY} - * @param pageSize + * @param pageSize * @param paramSetter the second parameter is the result set for previous page. it's {@code null} for first page. * @param resultExtractor the second parameter is the result set for previous page. it's {@code null} for first page. - * @return + * @return */ @SuppressWarnings("rawtypes") public static CheckedStream queryByPage(final Connection conn, final String query, final int pageSize, @@ -4875,13 +4875,13 @@ public static CheckedStream queryByPage(final Connection co /** * Runs a {@code Stream} with each element(page) is loaded from database table by running sql {@code query}. * - * @param - * @param conn + * @param + * @param conn * @param query this query must be ordered by at least one key/id and has the result size limitation: for example {@code LIMIT pageSize}, {@code ROWS FETCH NEXT pageSize ROWS ONLY} - * @param pageSize + * @param pageSize * @param paramSetter the second parameter is the result set for previous page. it's {@code null} for first page. - * @param resultExtractor - * @return + * @param resultExtractor + * @return */ @SuppressWarnings("rawtypes") public static CheckedStream queryByPage(final Connection conn, final String query, final int pageSize, @@ -7208,7 +7208,7 @@ public static String blob2String(final Blob blob, final Charset charset) throws * @throws IOException */ public static long writeBlobToFile(final Blob blob, final File output) throws SQLException, IOException { - return IOUtil.write(output, blob.getBinaryStream()); + return IOUtil.write(blob.getBinaryStream(), output); } /** diff --git a/src/main/java/com/landawn/abacus/jdbc/JdbcUtils.java b/src/main/java/com/landawn/abacus/jdbc/JdbcUtils.java index 111a676e..a71c2d01 100644 --- a/src/main/java/com/landawn/abacus/jdbc/JdbcUtils.java +++ b/src/main/java/com/landawn/abacus/jdbc/JdbcUtils.java @@ -1901,13 +1901,13 @@ public static long importData(final Iterator stmtSetter) throws SQLException, IOException { @@ -2043,13 +2043,13 @@ public static long importCSV(final File file, final long o /** * Imports the data from CSV to database. * - * @param is - * @param sourceDataSource + * @param is + * @param sourceDataSource * @param insertSQL the column order in the sql should be consistent with the column order in the CSV file. - * @param stmtSetter - * @return - * @throws SQLException - * @throws IOException + * @param stmtSetter + * @return + * @throws SQLException + * @throws IOException */ public static long importCSV(final InputStream is, final javax.sql.DataSource sourceDataSource, final String insertSQL, final Throwables.BiConsumer stmtSetter) throws SQLException, IOException { @@ -2122,13 +2122,13 @@ public static long importCSV(final InputStream is, long of /** * Imports the data from CSV to database. * - * @param reader - * @param sourceDataSource + * @param reader + * @param sourceDataSource * @param insertSQL the column order in the sql should be consistent with the column order in the CSV file. - * @param stmtSetter - * @return - * @throws SQLException - * @throws IOException + * @param stmtSetter + * @return + * @throws SQLException + * @throws IOException */ public static long importCSV(final Reader reader, final javax.sql.DataSource sourceDataSource, final String insertSQL, final Throwables.BiConsumer stmtSetter) throws SQLException, IOException { @@ -2202,7 +2202,7 @@ public static long importCSV(final Reader reader, long off final PreparedQuery stmtForSetter = new PreparedQuery(stmt); final Function headerParser = CSVUtil.getCurrentHeaderParser(); - final BiConsumer lineParser = CSVUtil.getCurrentLineParser(); + final BiConsumer lineParser = CSVUtil.getCurrentLineParser(); long result = 0; final BufferedReader br = Objectory.createBufferedReader(reader); @@ -2214,16 +2214,16 @@ public static long importCSV(final Reader reader, long off // continue } - final String[] strs = new String[titles.length]; + final String[] output = new String[titles.length]; while (result < count && (line = br.readLine()) != null) { - lineParser.accept(strs, line); + lineParser.accept(line, output); - if (filter != null && !filter.test(strs)) { + if (filter != null && !filter.test(output)) { continue; } - stmtSetter.accept(stmtForSetter, strs); + stmtSetter.accept(stmtForSetter, output); stmtForSetter.addBatch(); if ((++result % batchSize) == 0) { @@ -2234,7 +2234,7 @@ public static long importCSV(final Reader reader, long off } } - N.fill(strs, null); + N.fill(output, null); } if ((result % batchSize) > 0) { diff --git a/src/test/java/com/landawn/abacus/Maven.java b/src/test/java/com/landawn/abacus/Maven.java index 7a130ff1..7130985a 100644 --- a/src/test/java/com/landawn/abacus/Maven.java +++ b/src/test/java/com/landawn/abacus/Maven.java @@ -49,7 +49,7 @@ public static void main(String[] args) throws Exception { for (String line : lines) { newLines.add(line.replaceAll(sourceVersion, targetVersion)); } - IOUtil.writeLines(file, newLines); + IOUtil.writeLines(newLines, file); }); System.exit(0);