findById(引数)
And
Or
Between
LessThan
GreaterThan
IsNull
IsNotNull, NotNull
Like
NotLike
OrdeBy … AscやDescをつける
Not
In
NotIn
Repository
package com.example.demo.repositories; import com.example.demo.MyData; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface MyDataRepository extends JpaRepository<MyData, Long> { public Optional<MyData> findById(Long name); public List<MyData> findByNameLike(String name); public List<MyData> findByIdIsNotNullOrderByIdDesc(); public List<MyData> findByAgeGreaterThan(Integer age); public List<MyData> findByAgeBetween(Integer age1, Integer age2); }
単純検索は自動生成で複雑な検索のみDAOを定義
ほう、SpringBoot JPAの仕組みがわかってきた。