自動的に生成されないカスタム @Query を設定しようとしていますが、何を試しても、メソッド名のプロパティを返すオブジェクトのプロパティと一致させようとしています。
クエリを構築しようとせずにこのクエリを実行し、org.springframework.data.mapping.PropertyReferenceException で失敗するにはどうすればよいですか? おそらく @Query は間違ったアノテーションですか?
現在、私のレポは次のようになっています。
@Repository
public interface ScheduleRepository extends CrudRepository<Schedule, Integer>
{
@Query
List<Schedule> findByTypeAndAirDateBetweenOrderByAirDateDesc(String type, Date startDate, Date endDate);
@Query("SELECT s FROM Schedule s WHERE s.type = 'A' AND (s.airDate BETWEEN :startDate AND :endDate) ORDER BY ABS(DATEDIFF(s.airDate, NOW())) LIMIT 1")
List<Schedule> findCurrentAd(Date startDate, Date endDate);
}
Schedule クラスで一致する「現在の」フィールドが見つからない場合、例外が発生します。私はそれをしたくありません。定義したとおりにクエリを実行したいだけで、質問はありません。
お気づきかもしれませんが、Spring MVC と Data は初めてです。
誰の助けにも感謝します!