I have to get all data from MySQL in a table using condition select query where fields is isdeleted=0, location=1. How could I implement this in repository and access manager.
public interface FoodCourtRepository extends JpaRepository<FoodCourtEntity, Long> {
List<FoodcaseEntity> findByIsdeleted(Boolean isDeleted);
}
In access manager
public List<FoodcaseDO> getAllFoodCourt() {
List<FoodcaseEntity> foodCaseList = foodcourtRepository.findByIsdeleted(false);
}
You need to add another condition as well, for location, e.g.:
public List<FoodcaseEntity> findByIsdeletedAndLocation(boolean deleted, int location);
And call it with false and 1 as arguments, e.g.:
List<FoodcaseEntity> foodCaseList = foodcourtRepository.findByIsdeletedAndLocation(false, 1);
This should give you the required result.
Updte
If you want to fetch the data for multiple locations then you need to write a method that supports IN, e.g.:
public List<FoodcaseEntity> findByIsdeletedAndLocationIn(boolean deleted, List<Integer> location);
And then call it like this:
List<FoodcaseEntity> foodCaseList = foodcourtRepository.findByIsdeletedAndLocation(false, Arrays.asList(2,3,4,5));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With