Integrating Spring data with actors

so the problem starts with this, when using actors, interacting with database becomes async, and as i tested,while inserting, i can only make read transactions, i cant update any rows.

how can i integrate spring data jpa with actors ?

do i have to make an actor for doing database transactions? if yes,how can i tell actor which method and which repository to use to run the method?

JPA in is not threadsafe, that means that you must use the entity manager and do all modifications until you commit the changes on the same thread. Only ways to guarantee that with an actor is to do complete transactions in the same actor (you should not be sending mutable state between actors anyway, which kind of rules out passing JPA entities between actors for mutating them).

Another option could maybe be to use the pinned dispatcher, to have one actor that will always run on the same thread and can safely do a transaction on the same entities over a number of incoming commands. But I think the first option is a better idea.

Not sure if there is anything additional about Spring Data that would be problematic. I know that some other Spring modules store context-like things in ThreadLocal which does not work with actors since they do not all execute on the same thread.