简体   繁体   English

带下划线的存储库方法 findById Spring Boot

[英]Repository method findById with underscore Spring Boot

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.在实体 class Flights 中,我有字段 private City flight_from 和 private City flight_to 并且我需要存储库方法通过 flight_from 的 id 返回航班。 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.我试过 findByFlightToId、findByFlight_to_id、带双下划线的 findByFlight__toId 等,还是找不到。 Is there any solution for that?有什么解决办法吗?

spring-data treats the underscore as a special character, see this . spring-data 将下划线视为特殊字符,请参见this

Your best solution is to follow the naming conventions and rename your variables flightTo and flightFrom .您最好的解决方案是遵循命名约定并重命名您的变量flightToflightFrom

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM