If JPA prompts executing an update / delete query, it must be because @ transactional and @ modifying are not added to the service layer.
Abnormal scene
When spring-boot2 + JPA performs add modify delete operation:
public interface UserRepository extends JpaRepository<User , Integer>{
@Modifying
@Query(value="update User c set c.state = ?1,c.lastupdatetime = ?2 where c.user_no= ?3")
void updateUser(int state,Date nowDate,String user_no);
}
Exception: executing an update / delete query
Solution
Because JPA requires “no transaction support, update and delete operations cannot be performed”.
So on the other hand, @ transactional must be added to the service layer or repository layer to represent that this is a transaction level operation. Addition, deletion, modification and query are all transaction level except for query. It is OK to regard this as a specification.
Read More:
- Spring boot JPA Repository exception Validation failed for query for method
- Serverlet: How to Add, Delete, Modify and Query item code
- Error: current transaction is aborted, commands ignored until end of transaction blockp
- Linux_ day07_ 05_ Configure common add, delete, modify and query commands in network
- Insert into / delete / update / select of SQL Server database table
- MYSQL ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
- [Java] spring transaction control configuration error, application- persstence.xml Transaction manager report red in file
- MySQL error code 1217 (ER_ROW_IS_REFERENCED): Cannot delete or update a parent row: a foreign key co
- For the installation of anaconda3 in manjaro system, after the update (CONDA update — all), the terminal prompts an error and cannot execute CONDA related commands
- Asset database transaction committed tweet appears when unity reports an error!
- After switching the tidb database, an error could not commit JDBC transaction appears from time to time
- Mysql error when deleting the table structure: Error Code: 1217. Cannot delete or update a parent row: a foreign key constraint fails
- Docker delete error response from daemon: Conflict: unable to delete xxxxx solution
- Vue console reports an error duplicate keys detected: ‘XXXX’. This may cause an update error. Solution
- Error in Maven packaging web project: webxml attribute is required (or pre existing WEB-INF)/ web.xml if executing in update)
- Springboot + mybatis plus transaction management
- Mybatis integrates Oracle query and reports an error in the datetime type field
- When installing mysql, an error occurs when executing the installation command with the CMD window. Install / Remove of the Service denied
- Windows update has an error code_ 800700C1
- About node error NPM update check failed try running with sudo or get access to the local update