How can I write execute store procedure when update Entity using jpa Native Query?

  1. Execute store procedure
  2. Update A Table

Query is working Sql

@Query("UPDATE A SET A.No=(SELECT * FROM f_SP(tn,year,'name','1'))
,A.status=7  WHERE id=:id") 
A saveObject(@Param("year") Integer year, @Param("tn") Long tn,          
@Param("name") String name, @Param("id") Long id);

Upvotes: 0

Views: 97

Answers (1)

eeedev
eeedev

Reputation: 149

You may need to separate out the stored proc query and the update query at repository level like this :

@Procedure(procedureName = "f_SP")
Long reconcileEOMAndPIPSP(Long tn, String name, 'name','1');

@Query("UPDATE A SET A.No= :spResult ,A.status=7  WHERE id=:id") 
A saveObject(@Param("spResult") Long spResult, @Param("id") Long id);

and wire then together at the calling class.

Upvotes: 1

Related Questions