is it possible for Spring JPA Query methods on the interface to have default value?
This is the common one: Optional<DocumentTypeEntity> findByIdAndStatus(BigInteger id, String status);
I want the status to have a value of "ACTIVE" (this won't work though) Optional<DocumentTypeEntity> findByIdAndStatus(BigInteger id, "ACTIVE");
Maybe anyone has ideas? custom query is my last resort! Thanks!
maybe you can create two methods:
Optional<DocumentTypeEntity> findByIdAndStatus(BigInteger id, String status);
default Optional<DocumentTypeEntity> getActiveById(BigInteger id) {
return findByIdAndStatus(id, "ACTIVE");
}
I suggest using @Query. In case you don't need a predicate framework in an application (Specifications, QueryDSL,...), it's just easier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.