[Hibernate-JIRA] Created: (HHH-2152) Optimistic lock error although using LockMode.UPGRADE
by Per-Olov Wingren (JIRA)
Optimistic lock error although using LockMode.UPGRADE
-----------------------------------------------------
Key: HHH-2152
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2152
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: Oracle 10.2, Hibernate 3.1.3
Reporter: Per-Olov Wingren
Priority: Critical
Attachments: OptLockProblem.zip
I have a situation where two threads tries to update the same entity object at the same time. I use the Hibernate managed versioning using a version number but also a pessimistic lock using LockMode.UPGRADE.
One thread will lock the object in the database and the other will wait for the transaction of the first thread to commit (or rollback). The first thread updates the object, which also will make its version to be incremented. When the second tread get access to the object after the first is commited, it get an incorrect value of the version attribute. This leads to a StaleObjectStateException when the transaction is commited.
The entity object conists of a parent class and a subclass mapped to the database into two tables using <joined-subclass>.
If the testcase is modified to update an attribute in the subclass (numberB) instead of in the superclass it works without errors. Is the problem caused by the fact that Hibernate only locks the subclass in the database (for update of classb.oid) and not the superclass?
I attache a zip file containing a simple but complete test case that shows the problem.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
17 years, 5 months
[Hibernate-JIRA] Created: (HHH-2557) NPE in IdentityMap.IdentityKey.equals()
by Anders Wallgren (JIRA)
NPE in IdentityMap.IdentityKey.equals()
---------------------------------------
Key: HHH-2557
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2557
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3
Reporter: Anders Wallgren
The equals method in org.hibernate.util.IdentityMap.IdentityKey doesn't handle null objects:
{code}
java.lang.NullPointerException
at org.hibernate.util.IdentityMap$IdentityKey.equals(IdentityMap.java:103)
at java.util.HashMap.get(HashMap.java:305)
at org.apache.commons.collections.SequencedHashMap.get(SequencedHashMap.java:288)
at org.hibernate.util.IdentityMap.get(IdentityMap.java:135)
at org.hibernate.engine.StatefulPersistenceContext.getEntry(StatefulPersistenceContext.java:355)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:54)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:301)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at com.electriccloud.dao.HibernateFlushListener.onFlush(HibernateFlushListener.java:49)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:575)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:651)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:621)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:311)
at com.electriccloud.dao.TransactionAspect.withTransaction(TransactionAspect.java:121)
at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:576)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:562)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:60)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:76)
at com.electriccloud.operations.ConcurrentRetryAspect.performWithRetry(ConcurrentRetryAspect.java:168)
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:576)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:562)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:60)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:76)
at com.electriccloud.operations.OperationTimingAspect.logOperationPerformance(OperationTimingAspect.java:110)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:576)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:562)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:60)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:203)
at $Proxy97.perform(Unknown Source)
at com.electriccloud.operations.OperationInvoker.invoke(OperationInvoker.java:190)
at com.electriccloud.operations.OperationCaller.call(OperationCaller.java:126)
at com.electriccloud.operations.OperationCaller.call(OperationCaller.java:36)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
at com.electriccloud.util.queue.CommanderThread.run(CommanderThread.java:78)
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 5 months