Skip to content

Commit

Permalink
Add Support to Upsert/Insert Ignore on PDB (feedzai#388)
Browse files Browse the repository at this point in the history
* Add Support to Upsert/Insert Ignore on PDB
- Makes the implementation of DatabaseEngine optional, so it does not break compatibility with other library clients.

---------
Co-authored-by: Victor Camargo <victor.camargo@feedzai.com>
  • Loading branch information
victorcmg committed Jun 22, 2023
1 parent 1ef860d commit d4f7c4e
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,14 @@ public interface DatabaseEngine extends AutoCloseable {
/**
* Flushes the batches for all the registered entities upserting duplicated entries.
*
* @implNote The default implementation of this method throws an {@link UnsupportedOperationException}
* for backward-compatibility reasons. If this method is supposed to be called, it must be explicitly overridden.
*
* @throws DatabaseEngineException If something goes wrong while persisting data.
*/
void flushUpsert() throws DatabaseEngineException;
default void flushUpsert() throws DatabaseEngineException {
throw new UnsupportedOperationException("Method not implemented.");
}

/**
* Commits the current transaction. You should only call this method if you've previously called
Expand Down Expand Up @@ -397,9 +402,15 @@ default AbstractBatch createBatch(final int batchSize, final long batchTimeout,
*
* @param name The entity name.
* @param entry The entry to persist.
*
* @implNote The default implementation of this method throws an {@link UnsupportedOperationException}
* for backward-compatibility reasons. If this method is supposed to be called, it must be explicitly overridden.
*
* @throws DatabaseEngineException If something goes wrong while persisting data.
*/
void addBatchUpsert(final String name, final EntityEntry entry) throws DatabaseEngineException;
default void addBatchUpsert(final String name, final EntityEntry entry) throws DatabaseEngineException {
throw new UnsupportedOperationException("Method not implemented.");
}

/**
* Executes the given query.
Expand Down

0 comments on commit d4f7c4e

Please sign in to comment.