Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthorService(private val authorDAO: AuthorDAO, private val bookDAO: BookD

@Throws(Exception::class)
override fun update(obj: Author): Author {
return if(authorDAO.existsById(obj.id)){//check if author exists because the save method will insert a record if does not exists
return if(authorDAO.existsById(obj.id.toString()){//check if author exists because the save method will insert a record if does not exists
authorDAO.save(obj).apply { //update author
obj.id?.let { //if does has Id then
bookDAO.saveAll(bookDAO.findByAuthorId(it).map { it.also { it.author=this } })//update all his books
Expand All @@ -36,4 +36,4 @@ class AuthorService(private val authorDAO: AuthorDAO, private val bookDAO: BookD
}
}
}
}
}