lopmkipm
lopmkipm

Reputation: 77

How to query by Id and by Boolean set to "True" using Spring Data JPA

In my Spring Repository (CRUD) I want to bypass the @Query annotation and query using Spring Data JPA Query Creation and Entity by its Id and where a boolean : Deleted of it is set to false. I tried :

ReturnType findByIdAndDeletedFalse(@Param("id") Long id)

My question is : is it possible to write it that way to do the query ? I am using MongoDB,

Thanks for the guidance.

Upvotes: 2

Views: 3130

Answers (1)

https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#repository-query-keywords

IsFalse is a repository query keyword and so you can use findByIdAndDeletedIsFalse

Upvotes: 2

Related Questions