I want to delete an item from table.
Present valuee like below:
CatId CatName
1 Name1
1 Name2
1 Name3
1 ABC1
1 ABC2
2 Name4
3 Name5
Both columns are in same table. How to delete NAME1,NAME2, NAME3 from CatName column where CatId is 1 using spring boot jpa?
You need to create Cat Repository and put this method as follows..
@Repository
public interface CatRepository extends JpaRepository<Cat, Integer > {
List<Cat> findAllByCatIdAndCatNameLike(Integer catId, String catName);
}
In your service class create method and put in to following code lines.
List<Cat> catList = catRepository.findAllByCatIdAndCatNameLike(1, Name);
catRepository.deleteAll(catList);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.