我有两个不同的调度cron作业,每15分钟运行一次,并在60秒内完成作业。两者都作用于相同的enity:读取,然后处理,然后使用JpaRepository保存方法保存整体,这会导致下面的错误
org.springframework.orm.ObjectOptimisticLockingFailureException: Object of class [nl.coin.comp.domain.ServiceProvider] with identifier [105]: optimistic locking failed; nested exception is org.hibernate.S
在某个事务的作用域中,我的应用程序上的某些实体需要被锁定。我需要锁定所有参与事务的实体,并且不想创建特殊的方法来锁定我的DAO上的实体。我使用了spring的声明性事务,并为那个特定的方法调用设置了隔离级别,但是当数据被获取时,生成的SQL查询是一个普通的SELECT而不是SELECT XXX for UPDATE。我必须在hibernate上的事务上手动指定每个参与实体的锁吗?这不应该从事务隔离中进行控制吗?当将锁模式设置为在hibernate的会话中更新时,我可以看到正确的查询,这是否意味着我需要手动指定锁,即使我已经指定了隔离。
最好的
一些系统信息,它使用Spring,Spring数据,JPA和Hibernate。
我的问题是,2有什么区别?见下文:
//this uses plain JPA, and uses Spring's Transactional
@Transactional(isolation=Isolation.READ_UNCOMMITTED)
public List getData() {
//code
}
//this uses Spring Data
@Lock(LockModeType.None)
public List getData() {
//code
}
环境:
我们有一个部署在JBoss 4.2.3.GA服务器上的应用程序,它使用Hibernate 3.4和JTA1.0。
有一个导入程序,它创建或更新某些实体,然后导入一些数据。由于几个原因,大部分导入是在新事务中完成的,在每个事务中,在外部事务中创建/更新的实体可能会再次更新。
调用序列类似于以下伪代码:
Service1:
//container managed transaction T1 is started here
import() {
A a = ... ;//new or read from database
if( isNew( a ) ) {
我们使用hibernate更新表的值,然后我得到以下错误
org.hibernate.engine.jdbc.spi.SqlExceptionHelper | Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to access table 'dev.TASKS' directly or indirectly in database 'DEV' to update, delete, or insert the row t
我正在建立一个基于java的web应用程序,在SQL服务器上工作。
SQL server的默认数据库隔离级别为READ_COMMITTED。
我得到了以下异常:
Cause: org.hibernate.exception.LockAcquisitionException: Transaction (Process ID 124) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
2016-0
我们的应用程序正面临死锁情况
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 62) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at com.microsoft.sqlserver.jdbc.SQLServerExceptio