Adding your own implementation in JPA
Spring Boot JPA provides not only CRUD Operations,if you extend JpaRepository, a whole lot of implementation will be available
Some of them are shown below
findByLastnameAndFirstname
findByLastnameOrFirstname
findByStartDateBetween
findByAgeLessThan
findByAgeLessThanEqual
findByAgeGreaterThan
findByAgeGreaterThanEqual
findByStartDateAfter
findByStartDateBefore
findByAgeIsNull
findByAge(Is)NotNull
findByFirstnameLike
findByFirstnameNotLike
findByFirstnameStartingWith
Before adding your own custom implementation,I would suggest you to look at all the implementations that are already available here.
Your own implementation can be added as shown below
public interface PersonDAO extends JpaRepository<Person, Long> {
@Query("update User u set u.username = :username where u.userid=:userid")
Integer updateUsernameByUserid(@Param("username") String username,@Param("userid") int userid);
}
0 comments:
Post a Comment