Is there a way to block access to the object in the database before the end of the transaction?
It is impossible to answer your question because you did not provide enough details. What is it you need to do? What does your code look like?
Based on what you have said, I wonder whether this is the right forum for posting your question. It looks like you need to ask this on the forum/mailing list/chat channel/… of the database you are using, or you might try a general development Q&A site like Stack Overflow. Just because you are using Kotlin to solve a problem, does not mean questions related to that problem are best posted on this forum.
Solved, it was
SELECT FOR UPDATE