我可以在调用存储过程的方法上使用 @Transactional(readOnly = true),该存储过程 returns 结果集还更新行吗?
Can i use @Transactional(readOnly = true) on a method that calls a stored procedure which returns resultsets but also updates rows?
我有一个通过 entityManager
实例调用存储过程的方法
ProcedureCall storedProcedureCall = entityManager.unwrap(Session.class).createStoredProcedureCall(StoredProcedures.GET_WEB_APPLICATION_STATE_DATA_AND_UPDATE_USER_STATUS.toString());
此存储过程检索用户首选项,同时将用户状态从离线更新为在线。我可以使用 @Transactional(readOnly = true)
而不是 @Transactional
因为更新查询不是由数据请求应用程序本身完成的吗?
答案似乎是否定的。当我在调用既获取数据又写入数据的存储过程的方法上使用 @Transactional(readOnly = true)
时,我会得到异常。
java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
我有一个通过 entityManager
实例调用存储过程的方法
ProcedureCall storedProcedureCall = entityManager.unwrap(Session.class).createStoredProcedureCall(StoredProcedures.GET_WEB_APPLICATION_STATE_DATA_AND_UPDATE_USER_STATUS.toString());
此存储过程检索用户首选项,同时将用户状态从离线更新为在线。我可以使用 @Transactional(readOnly = true)
而不是 @Transactional
因为更新查询不是由数据请求应用程序本身完成的吗?
答案似乎是否定的。当我在调用既获取数据又写入数据的存储过程的方法上使用 @Transactional(readOnly = true)
时,我会得到异常。
java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed