0

I am using Spring data JPA now every-time I perform update or delete Spring data JPA does select before running actual query.

@Modifying
@Query("update Device d set d.latestDevice = ?1 where d.senderId = ?2")
@Transactional(readOnly = false)
int updateLatestDevice(Device newDevice, Integer senderId);

@Modifying
@Transactional(readOnly = false)
int deleteById(Integer deviceId);

I can not find an exact answer to this situation.

quintin
  • 812
  • 1
  • 10
  • 35
  • Does this answer your question? [Hibernate select before update](https://stackoverflow.com/questions/16303691/hibernate-select-before-update) – Valijon Jun 02 '20 at 19:53
  • Previous question only talks about how to disable select. I am looking for a reason why a select was triggered before update & delete? – quintin Jun 03 '20 at 06:22

1 Answers1

0

I'm not sure about the update, I'm actually surprised that it triggers a select.

The delete though triggers events which have the deleted entity as a payload so they need to get loaded.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348