Skip to content

Commit

Permalink
GH-261 - Avoid materializing JpaEventPublication to mark it completed.
Browse files Browse the repository at this point in the history
We now simply issue an update query.
  • Loading branch information
odrotbohm committed Aug 9, 2023
1 parent 1a84ae2 commit 0de4879
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ class JpaEventPublicationRepository implements EventPublicationRepository {
p.publicationDate asc
""";

private static final String MARK_COMPLETED_BY_EVENT_AND_LISTENER_ID = """
update JpaEventPublication p
set p.completionDate = ?3
where p.serializedEvent = ?1
and p.listenerId = ?2
""";

private static final String DELETE_COMPLETED = """
delete
from JpaEventPublication p
Expand Down Expand Up @@ -111,8 +118,11 @@ public EventPublication create(EventPublication publication) {
@Transactional
public void markCompleted(Object event, PublicationTargetIdentifier identifier, Instant completionDate) {

findEntityBySerializedEventAndListenerIdAndCompletionDateNull(event, identifier)
.map(it -> it.completionDate = completionDate);
entityManager.createQuery(MARK_COMPLETED_BY_EVENT_AND_LISTENER_ID)
.setParameter(1, serializeEvent(event))
.setParameter(2, identifier.getValue())
.setParameter(3, completionDate)
.executeUpdate();
}

/*
Expand Down

0 comments on commit 0de4879

Please sign in to comment.