Added error checking to addBookToCategory methods so that the mapping is
only added if the Book and Category have an id set.