I am a little newbie on the Lagom framework and I need to know what the right way to do a delete operation in this framework. I develop with Java and I tested two approaches:
In terms of logic, I think the second approach is the most logical but I want to know if there is a good practice that the Lagom framework offers developers to do delete operations
EDIT 1 This is my ReadSideHandler code, how can I proceed to handle properly the empty option
@Override
public ReadSideHandler<AuthenticationEvent> buildHandler() {
return readSide.<AuthenticationEvent>builder("authenticationEventOffset")
.setGlobalPrepare(this::createTables)
.setPrepare(tag -> prepareStatements())
.setEventHandler(AuthenticationLoginEvent.class,
e -> insertAuthentication(e.getAuthentication()))
.setEventHandler(AuthenticationLogoutEvent.class, e -> deleteAuthentication(e.getAccessToken()))
.build();
}
I finally found the problem. it was bad handling in my event class, I was using Preconditions.checkNotNull on my variable which is apparently wrong. I removed this xpression from my code and everything works fine