I have seen these links
- How to use JPA Query to insert data into db? which uses nativeQuery=true
- How to insert into db in spring-data? which suggests using built-in save method (there is also a saveAndFulsh() method)
My example is below:
Person is a simple Entity w/ 3 fields "Long id, String name, Integer age", and, maps to a corresponding Person table w/ 3 columns per above)
@Repository
public interface DualRepository extends JpaRepository<Dual,Long> {
@Modifying
@Query(? - what goes here - ?)
public int modifyingQueryInsertPerson(@Param("id")Long id, @Param("name")String name, @Param("age")Integer age);
}
Is there way to do the insert by just using @Query & @Modifying (i.e. without using native SQL query & nativeQuery=true, or, save(), or, saveAndFlush() ?