1

I am trying to run an insert native query similar to the following

INSERT INTO t3(t1,t2)
SELECT t1.c1,sum(t1.c2) table1 t1 WHERE t1.c3 = 'something'
GROUP BY t1;

I am calling it using a repository and the system actually runs the query without any error. However, no value is being inserted. The query works when I try to run using the database interface.

PKS
  • 618
  • 1
  • 7
  • 19

2 Answers2

0

Run the query in your database, alternatively you dont need group by in insert scripts

WARUTS
  • 72
  • 7
0

I was able to make it work. My mistake was not using @Modifying annotation on top of the function. I was simple using @Transactional only. If you require more then one table to be impacted simultaneously then use the annotation as well. It got the job done for me. exapme snippet below

  @Transactional
  @Modifying
  @Query(value = Query.YOUR_QUERY, nativeQuery = true)
  void insert(@Param("param") var param1);
PKS
  • 618
  • 1
  • 7
  • 19