Hi everyone. I have code like this: ==== MyValue v = (MyValue) session.get( MyValue.class, lockOptions);
if(v == null) { v = new MyValue(initialData); session.save(v); // persist the object flush(); session.buildLockRequest(lockOptions).lock(sn); }
v.ChangeData(); =====
which crashes Hibernate later if lockoptions is set to optimistic locking. MyValue doe not have anything annotated with @Version but the class is annotated with @org.hibernate.annotations.Entity( dynamicUpdate = true, dynamicInsert=true, optimisticLock = OptimisticLockType.ALL), which, as understand, allows not having such field.
Still, it seems Hibernate cannot handle it, because crashes with null pointer exception at === EntityVerifyVersionProcess.doBeforeTransactionCompletion(SessionImplementor) line: 56 ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion() line: 554 ActionQueue.beforeTransactionCompletion() line: 216 SessionImpl.beforeTransactionCompletion(Transaction) line: 571 JDBCContext.beforeTransactionCompletion(Transaction) line: 250 JDBCTransaction.commit() line: 138 HibernateTransactionManager.doCommit(DefaultTransactionStatus) line: 656 HibernateTransactionManager(AbstractPlatformTransactionManager).processCommit(DefaultTransactionStatus) line: 754 HibernateTransactionManager(AbstractPlatformTransactionManager).commit(TransactionStatus) line: 723 TransactionInterceptor(TransactionAspectSupport).commitTransactionAfterReturning(TransactionAspectSupport$TransactionInfo) line: 387 TransactionInterceptor.invoke(MethodInvocation) line: 120 ==== because EntityVerifyVersionProcess.entry.version is null.
What I would like to find out - is this because OptimisticLockType.ALL is broken beyond repair or is this me doing something wrong?
|