'Unecessary Casting JPA Specification

I think this is an easy one:

I have this following code that does a simple JPA query using Specification and with the clause "AND".

Why do I need to cast "Specification" in this case:? Am I doing something wrong or not following a good practice/pattern?

List<RoomEntity> roomEntity = roomRepository.findAll((Specification) SpecificationUtils
        .columnEquals("idRoom", idRoom)
        .and(SpecificationUtils.columnEquals("floor", floor)));

I refactored and created a method for that, and inside the method does not need the casting, but I would like to to keep the code in the same line.

Thanks.

jpa


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source