-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: crash when using optimistic locking without version field
PostPosted: Thu Nov 07, 2013 8:53 pm 
Newbie

Joined: Thu Nov 07, 2013 8:13 pm
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.