@tapac it will help to add to the FAQ link mention of nested transactions.
n
Norg
07/23/2018, 4:42 PM
according to this https://github.com/JetBrains/Exposed/wiki/DAO#many-to-many-reference I have to add references after creation transaction finished. Will savepoints help me? I need to be able to rollback the outer transaction along with creation if references were not added.
t
tapac
07/23/2018, 5:25 PM
In that case you don't need to create separate transaction, just move
film.actors = SizedCollection(listOf(actor))
from
new
block.
Copy code
transaction {
val actor = Actor.new {
firstname = "Daisy"
lastname = "Ridley"
}
val film = StarWarsFilm.new {
name = "The Last Jedi"
sequelId = 8
director = "Rian Johnson"
}
film.actors = SizedCollection(listOf(actor))
}
tapac
07/23/2018, 5:28 PM
Then on any exception within transaction block whole transaction will be rolled back