FRQDO
12/06/2018, 4:38 AMtransaction
to obtain an entry from the database, like so:
val testBook = transaction { Book.findById(1)!! }
Now, immediately after that line, I tried
<http://log.info|log.info>("Book title: ${testBook.title}")
…which gave me an org.h2.jdbc.JdbcSQLException: The object is already closed [90007-196]
exception.
From what I gathered, this is intended behavior because I am not within the transaction anymore.
But in order to avoid this error:
Would I need to find a place from which I can basically wrap my entire application within one giant transaction for the entire life cycle of the app? That seems very wrong to me.
Would I need to create copies of the database objects within a transaction and then only use the copies afterwards? Why would I then want to create the corresponding DAOs if I cannot use them like other objects?
Or is there some magic bit of code that I just don’t know about yet?