• This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts

  • kevin
    Keymaster
    Postcount 29

    Hello,

    I need query by dates with Spring Data JPA? How can I do?


    kevin
    Keymaster
    Postcount 29

    You can use code below:

    1. Create Student entity:

    @Entity
    public class Student {

    @Id
    @GeneratedValue
    Integer id;

    @Temporal(TemporalType.DATE)
    Date birthday;
    }

    2. Create Student Repository:

    public interface StudentRepository extends CrudRepository<Student, Integer> {

    @Query(“from Student where birthday = :birthday”)
    List<Student> findStudentsByBirthday(@Param(“birthday”) Date birthday);

    }

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Top