Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: use @GetGeneratedKeys to retrieve auto-generated history record_id
While the implementation is JDBC driver specific, it seems to be working fine for our use-case (h2, MariaDB and PostgreSQL). Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
- Loading branch information
Showing
2 changed files
with
4 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
import org.killbill.billing.util.entity.dao.EntityModelDao; | ||
import org.skife.jdbi.v2.sqlobject.Bind; | ||
import org.skife.jdbi.v2.sqlobject.BindBean; | ||
import org.skife.jdbi.v2.sqlobject.GetGeneratedKeys; | ||
import org.skife.jdbi.v2.sqlobject.SqlQuery; | ||
import org.skife.jdbi.v2.sqlobject.SqlUpdate; | ||
|
||
|
@@ -33,8 +34,8 @@ public interface HistorySqlDao<M extends EntityModelDao<E>, E extends Entity> { | |
@SqlQuery | ||
public List<EntityHistoryModelDao<M, E>> getHistoryForTargetRecordId(@Bind("targetRecordId") final long targetRecordId, | ||
@BindBean InternalCallContext context); | ||
|
||
@SqlUpdate | ||
public void addHistoryFromTransaction(@EntityHistoryBinder EntityHistoryModelDao<M, E> history, | ||
@GetGeneratedKeys | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
pierre
Author
Member
|
||
public Long addHistoryFromTransaction(@EntityHistoryBinder EntityHistoryModelDao<M, E> history, | ||
@BindBean InternalCallContext context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 17c56ae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I am guessing when this annotation is present JDBI will use the new JDBC 3.0 method getGeneratedKeys() to automatically return the AUTO_INCREMENT key?