문제

Hi i am new to spring JPA . I have a table which has two columns namely 'active_from' and 'active_to'.Now I would like to get a column which has a date(ie.current date) which has a value between "active_from" and "active_to".How to acheive this using spring jpa repositories.?

도움이 되었습니까?

해결책

This link you could find query methods to add queries that are not covered by the common jpa repository or with the support creation.

Check 2.3.4 Using @Query in JPA repositories

Using Query methods you can do that, try something like this.

public interface UserRepository extends JpaRepository<User, Long> {

  @Query(value = "SELECT * FROM USERS WHERE active_from > :?0 AND active_to < :?0 )
  List<User> findBetweenDate(String currentDate);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top