diff --git a/merlin-driver/src/main/java/gov/nasa/jpl/aerie/merlin/driver/engine/SimulationEngine.java b/merlin-driver/src/main/java/gov/nasa/jpl/aerie/merlin/driver/engine/SimulationEngine.java index fed9782634..d57945b7f9 100644 --- a/merlin-driver/src/main/java/gov/nasa/jpl/aerie/merlin/driver/engine/SimulationEngine.java +++ b/merlin-driver/src/main/java/gov/nasa/jpl/aerie/merlin/driver/engine/SimulationEngine.java @@ -884,7 +884,7 @@ private TreeMap>> createSerializedTimelin } } } - var activitySpanID = Optional.of(spanToActivities.get(event.provenance()).id()); + var activitySpanID = Optional.ofNullable(spanToActivities.get(event.provenance())).map(ActivityInstanceId::id); output = EventGraph.concurrently( output, EventGraph.atom( diff --git a/merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/InsertSimulationEventsAction.java b/merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/InsertSimulationEventsAction.java index 7b0f9c7a04..8ad0f1eb13 100644 --- a/merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/InsertSimulationEventsAction.java +++ b/merlin-server/src/main/java/gov/nasa/jpl/aerie/merlin/server/remotes/postgres/InsertSimulationEventsAction.java @@ -10,6 +10,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +import java.sql.Types; import java.util.List; import java.util.Map; @@ -65,7 +66,7 @@ private static void batchInsertEventGraph( statement.setString(5, causalTime); statement.setInt(6, event.topicId()); statement.setString(7, serializedValueP.unparse(event.value()).toString()); - statement.setLong(8, event.spanId().isPresent() ? event.spanId().get() : null); + statement.setObject(8, event.spanId().orElse(null), Types.INTEGER); statement.addBatch(); } }