[BAEL-2566] Add example of Insert with Modifying Native Query (#6164)

* [BAEL-2566] Add example of Insert with Modifying Native Query

* [BAEL-2557] Fix MR conflicts

* [BAEL-2557] Cleanup tests
This commit is contained in:
FrancoCorleone
2019-02-18 17:48:46 +01:00
committed by Josh Cummings
parent 96fbef6a14
commit 243c671edb
2 changed files with 26 additions and 10 deletions
@@ -67,10 +67,14 @@ public interface UserRepository extends JpaRepository<User, Integer> , UserRepos
@Query(value = "UPDATE Users u SET u.status = ? WHERE u.name = ?", nativeQuery = true)
int updateUserSetStatusForNameNative(Integer status, String name);
@Query(value = "INSERT INTO Users (name, age, email, status) VALUES (:name, :age, :email, :status)", nativeQuery = true)
@Modifying
void insertUser(@Param("name") String name, @Param("age") Integer age, @Param("status") Integer status, @Param("email") String email);
@Modifying
@Query(value = "UPDATE Users u SET status = ? WHERE u.name = ?", nativeQuery = true)
int updateUserSetStatusForNameNativePostgres(Integer status, String name);
@Query(value = "SELECT u FROM User u WHERE u.name IN :names")
List<User> findUserByNameList(@Param("names") Collection<String> names);
List<User> findUserByNameList(@Param("names") Collection<String> names);
}