Skip to content

Commit

Permalink
3.2.9
Browse files Browse the repository at this point in the history
* Add `PrefixFieldMapping`.
* Improvements and bug fix.
  • Loading branch information
landawn committed Sep 12, 2022
1 parent c32f35a commit 1cd13db
Show file tree
Hide file tree
Showing 11 changed files with 570 additions and 261 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 3.2.9

* Add `PrefixFieldMapping`.
* Improvements and bug fix.


### 3.2.8

* Improvements and bug fix.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.2.8-brightgreen.svg)](https://www.javadoc.io/doc/com.landawn/abacus-jdbc/3.2.8/index.html)
[![Javadocs](https://img.shields.io/badge/javadoc-3.2.9-brightgreen.svg)](https://www.javadoc.io/doc/com.landawn/abacus-jdbc/3.2.9/index.html)

Hope it will bring you the programming experiences: coding with SQL/DB is just like coding with Collections.

Expand Down Expand Up @@ -191,7 +191,7 @@ userDao.deleteById(100L);
* Gradle:
```gradle
// JDK 1.8 or above:
compile 'com.landawn:abacus-jdbc:3.2.8'
compile 'com.landawn:abacus-jdbc:3.2.9'
```
## User Guide:
Expand Down
6 changes: 3 additions & 3 deletions maven/0.0.1-SNAPSHOT/abacus-jdbc-0.0.1-SNAPSHOT.pom
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@
<dependency>
<groupId>com.landawn</groupId>
<artifactId>abacus-common</artifactId>
<version>3.5.1</version>
<version>3.5.3</version>
</dependency>

<dependency>
<groupId>com.landawn</groupId>
<artifactId>abacus-query</artifactId>
<version>1.2.6</version>
<version>1.2.7</version>
</dependency>

<dependency>
<groupId>com.landawn</groupId>
<artifactId>abacus-cache</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
</dependency>
</dependencies>

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.landawn</groupId>
<artifactId>abacus-jdbc</artifactId>
<version>3.2.9</version>
<version>3.2.10</version>
<packaging>jar</packaging>

<name>abacus-jdbc</name>
Expand All @@ -29,21 +29,21 @@
<dependency>
<groupId>com.landawn</groupId>
<artifactId>abacus-common</artifactId>
<version>3.5.1</version>
<version>3.5.3</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.landawn</groupId>
<artifactId>abacus-query</artifactId>
<version>1.2.6</version>
<version>1.2.7</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.landawn</groupId>
<artifactId>abacus-cache</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
<scope>provided</scope>
</dependency>

Expand Down
22 changes: 14 additions & 8 deletions samples/com/landawn/abacus/samples/DaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void test_parallel() throws Exception {
.parallel()
.map(Fn.ff(it -> userDao.gett(it)))
.onEach(it -> it.setCreateTime(null))
.sortedBy(it -> it.getId())
.sortedBy(User::getId)
.toList();

assertEquals(users.get(0), dbUsers.get(0));
Expand Down Expand Up @@ -203,7 +203,7 @@ public void test_refresh() throws Exception {
List<Long> ids = userDao.batchInsertWithId(users);
assertEquals(users.size(), ids.size());

List<User> dbUsers = userDao.batchGet(ids).stream().map(it -> N.copy(it)).collect(Collectors.toList());
List<User> dbUsers = userDao.batchGet(ids).stream().map(N::copy).collect(Collectors.toList());

dbUsers.forEach(it -> it.setFirstName(N.uuid()));

Expand Down Expand Up @@ -261,7 +261,7 @@ public void test_BindList() throws Exception {
List<Long> ids = userDao.batchInsertWithId(users);
assertEquals(users.size(), ids.size());

int[] intIds = Stream.of(ids).mapToInt(it -> it.intValue()).toArray();
int[] intIds = Stream.of(ids).mapToInt(Long::intValue).toArray();
long[] longIds = N.toLongArray(ids);
assertEquals(ids.size(), userDao.listByIds(intIds).size());

Expand Down Expand Up @@ -815,16 +815,16 @@ public void test_stream() throws SQLException {
userDao.stream(N.asList("firstName", "lastName"), CF.eq("firstName", "Forrest"), (rs, cnl) -> rs.getString(1)).forEach(Fnn.println());
}

userDao.list(CF.gt("id", 0), rs -> rs.getString(1) != null, Jdbc.RowMapper.builder().get(1, (rs, i) -> rs.getString(i)).toList()).forEach(Fn.println());
userDao.list(CF.gt("id", 0), rs -> rs.getString(1) != null, Jdbc.RowMapper.builder().get(1, ResultSet::getString).toList()).forEach(Fn.println());

userDao.list(CF.gt("id", 0), (rs, cnl) -> rs.getString(1) != null,
Jdbc.BiRowMapper.builder().get("firstName", (rs, i) -> rs.getString(i)).to(List.class)).forEach(Fn.println());
userDao.list(CF.gt("id", 0), (rs, cnl) -> rs.getString(1) != null, Jdbc.BiRowMapper.builder().get("firstName", ResultSet::getString).to(List.class))
.forEach(Fn.println());

userDao.list(CF.gt("id", 0), (rs, cnl) -> rs.getString(1) != null, Jdbc.BiRowMapper.builder().getString("firstName").to(LinkedHashMap.class))
.forEach(Fn.println());

userDao.list(CF.gt("id", 0), (rs, cnl) -> rs.getString(1) != null,
Jdbc.BiRowMapper.builder().get("firstName", (rs, i) -> rs.getString(i)).to(User.class)).forEach(Fn.println());
userDao.list(CF.gt("id", 0), (rs, cnl) -> rs.getString(1) != null, Jdbc.BiRowMapper.builder().get("firstName", ResultSet::getString).to(User.class))
.forEach(Fn.println());

userDao.list(CF.gt("id", 0), (rs, cnl) -> rs.getString(1) != null, Jdbc.BiRowMapper.to(User.class)).forEach(Fn.println());

Expand Down Expand Up @@ -904,6 +904,12 @@ public void test_mergedBy() throws SQLException {

userDao.listTomergedEntities().forEach(Fn.println());

userDao.listTomergedEntities_2().forEach(Fn.println());

userDao.listTomergedEntities_3().forEach(Fn.println());

assertEquals(userDao.listTomergedEntities_2(), userDao.listTomergedEntities_3());

userDao.findOneTomergedEntities().ifPresent(Fn.println());

userDao.deleteAllJoinEntities(user);
Expand Down
10 changes: 10 additions & 0 deletions samples/com/landawn/abacus/samples/dao/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.landawn.abacus.jdbc.annotation.MergedById;
import com.landawn.abacus.jdbc.annotation.NonDBOperation;
import com.landawn.abacus.jdbc.annotation.PerfLog;
import com.landawn.abacus.jdbc.annotation.PrefixFieldMapping;
import com.landawn.abacus.jdbc.annotation.Select;
import com.landawn.abacus.jdbc.annotation.SqlField;
import com.landawn.abacus.jdbc.annotation.SqlLogEnabled;
Expand Down Expand Up @@ -177,6 +178,15 @@ List<User> selectByIdWithDefine_4(@Define("tableName") String tableName, @Bind("
@MergedById("id")
Collection<User> listTomergedEntities() throws SQLException;

@Select(sql = "select user.id as \"id\", first_name, last_name, device.id as \"devices.id\", device.manufacture as \"devices.manufacture\", device.model as \"devices.model\", device.user_id as \"devices.user_id\", address.id as \"address.id\", address.street as \"address.street\", address.city as \"address.city\" from user left join device on user.id = device.user_id left join address on user.id = address.user_id")
@MergedById("ID, firstName")
Collection<User> listTomergedEntities_2() throws SQLException;

@Select(sql = "select user.id as \"id\", first_name, last_name, device.id as \"ds.id\", device.manufacture as \"ds.manufacture\", device.model as \"ds.model\", device.user_id as \"ds.user_id\", address.id as \"address.id\", address.street as \"address.street\", address.city as \"address.city\" from user left join device on user.id = device.user_id left join address on user.id = address.user_id")
@MergedById("ID, firstName")
@PrefixFieldMapping("ds = devices, as = address")
Collection<User> listTomergedEntities_3() throws SQLException;

@Select(sql = "select user.id as \"id\", first_name, last_name, device.id as \"devices.id\", device.manufacture as \"devices.manufacture\", device.model as \"devices.model\", device.user_id as \"devices.user_id\", address.id as \"address.id\", address.street as \"address.street\", address.city as \"address.city\" from user left join device on user.id = device.user_id left join address on user.id = address.user_id")
@MergedById("id")
Optional<User> findOneTomergedEntities() throws SQLException;
Expand Down
Loading

0 comments on commit 1cd13db

Please sign in to comment.