In entity class Flights I have fields private City flight_from and private City flight_to and I need repository method to return flights by id of flight_from. I am trying to do like this:
List<Flights> findByFlight_toId(Integer id);
I have tried findByFlightToId, findByFlight_to_id, findByFlight__toId with double underscore and other, still can't find it. Is there any solution for that?
spring-data treats the underscore as a special character, see this .
Your best solution is to follow the naming conventions and rename your variables flightTo
and flightFrom
.
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.