I have a Spring Boot application to track books. The Book entity is similar to this.

```js
@Entity
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Builder
public class Book implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long bookId;

    @Column(nullable = false, unique = true)
    private String bookName;
}
```

And it has a repository, via which I can delete a book by its `bookName` attribute.

```js
@Repository
public interface BookRepository extends JpaRepository<Book, String> {
    Optional<Book> deleteByBookName(String bookName);
}
```

And my delete method looks like this.

```js
@Transactional
public void deleteBook(String bookName) {

  Optional<Book> deletedBook = bookRepository.deleteByBookName(bookName);
  if (deletedBook.isEmpty()) {
      throw new ResourceNotFoundException("Book Not Found");
  }

}
```

However, instead of returning an `Optional<Book>` type instance, this `deleteByBookName` method returns Optional objects such as `Optional[0]`, `Optional[1]` which have the deleted book counts as values.

Due to this, `deletedBook.isEmpty()` is always true, even when 0 books are deleted.

Why this `deleteByBookName` method returns the deleted count inside Optional, instead of the deleted entity?