0

i am working in rest api via spring.

i have isdeleted a field in a table i need to find if isdeleted =0 in mysql then it show the data in row in a table as well as in application list but if isdeleted=1,the data remains in table in database but doesn't show in list in applicatiopn that is soft delete,how could i implement this condition in repository file by using findall() method

public interface FoodCourtRepository  extends JpaRepository<FoodCourtEntity, Long> {


    List<FoodCourtEntity> findAll(isdeleted=false???);


}
Prabhat G
  • 2,974
  • 1
  • 22
  • 31
bkumar
  • 51
  • 9
  • Create a custom RowMapper , Take reference from this [RowMapper](https://www.javatpoint.com/RowMapper-example) – Utkarsh Shekhar Jul 25 '17 at 08:50
  • 1
    Possible duplicate of [Handling soft-deletes with Spring JPA](https://stackoverflow.com/questions/19323557/handling-soft-deletes-with-spring-jpa) – vedarthk Jul 25 '17 at 08:52
  • Dear thanks for response it not getting right this codition is having one solution by in repository file ((select e from foodstallentity where e.isdelete=0" ))but i have to find this by another condition – bkumar Jul 25 '17 at 08:58
  • Iterable findAll(Example example); public interface FoodCourtRepository extends JpaRepository { List findAll(isdeleted=false); } how could i apply this condition by this method(( Iterable findAll(Example example);)) in spring suite tool in repository file – bkumar Jul 25 '17 at 09:00
  • That boolean flag seems like a bad, non-RESTful design. – duffymo Jul 25 '17 at 09:07

1 Answers1

0

Just add the following method to your interface repository:

List<FoodCourtEntity> findByDeleted(boolean isDeleted);

You can learn more from Spring Data JPA documentation

phil_g
  • 516
  • 6
  • 13