Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
simasch committed Nov 5, 2024
2 parents 370ed5d + 0ecd6ef commit af76942
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Add a dependency to the current version:
<dependency>
<groupId>ch.martinelli.oss</groupId>
<artifactId>jooq-spring</artifactId>
<version>0.2.0</version>
<version>0.3.0</version>
</dependency>
```

Expand All @@ -24,6 +24,19 @@ The JooqDAO follows the [DAO pattern](https://en.wikipedia.org/wiki/Data_access_
the [Repository pattern](https://martinfowler.com/eaaCatalog/repository.html) because the Repository is a pattern from
Domain Driven Design (DDD).

#### Usage

```java

@Component
public class AthleteDAO extends JooqDAO<Athlete, AthleteRecord, Long> {

public AthleteDAO(DSLContext dslContext) {
super(dslContext, ATHLETE);
}
}
```

#### Methods

| Return Type | Method | Description |
Expand All @@ -36,26 +49,13 @@ Domain Driven Design (DDD).
| `int` | `count()` | Counts the total number of records in the associated table. |
| `int` | `count(org.jooq.Condition condition)` | Counts the number of records in the associated table that match the given condition. |
| `int` | `save(R record)` | Saves the given record to the database. |
| `int[]` | `saveAll(List<R> record)` | Saves a list of records to the database using batch store operations. |
| `int` | `merge(R record)` | Merges the given record into the database. |
| `int` | `deleteById(ID id)` | Deletes a record from the database identified by its primary key. |
| `int` | `delete(R record)` | Deletes the specified record from the database. |
| `int` | `delete(org.jooq.Condition condition)` | Deletes records from the database that match the given condition. |

Checkout the code for documentation for further
information [JooqDAO](src/main/java/ch/martinelli/oss/jooqspring/JooqDAO.java).

#### Usage

```java

@Component
public class AthleteDAO extends JooqDAO<Athlete, AthleteRecord, Long> {

public AthleteDAO(DSLContext dslContext) {
super(dslContext, ATHLETE);
}
}
```
Check out the code documentation for further information [JooqDAO](src/main/java/ch/martinelli/oss/jooqspring/JooqDAO.java).

## License

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

<groupId>ch.martinelli.oss</groupId>
<artifactId>jooq-spring</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>

<name>jOOQ Spring Integration</name>
<description>Helpful utilities when using jOOQ with Spring</description>
Expand Down Expand Up @@ -132,7 +132,7 @@
<scm>
<connection>scm:git:[email protected]:martinellich/jooq-spring.git</connection>
<developerConnection>scm:git:[email protected]:martinellich/jooq-spring.git</developerConnection>
<url>[email protected]:maritnellich/jooq-spring.git</url>
<url>[email protected]:martinellich/jooq-spring.git</url>
</scm>

<distributionManagement>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/ch/martinelli/oss/jooqspring/JooqDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ public int save(R record) {
return record.store();
}

/**
* Saves a list of records to the database using batch store operations.
*
* @param records the list of records to be saved
* @return an array containing the number of affected rows for each batch operation
*/
@Transactional
public int[] saveAll(List<R> records) {
return dslContext.batchStore(records).execute();
}

/**
* Merges (INSERT … ON DUPLICATE KEY UPDATE) the given record into the database. Attaches the record to the DSLContext
* and attempts to merge it.
Expand Down

0 comments on commit af76942

Please sign in to comment.