-->
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.  [ 5 posts ] 
Author Message
 Post subject: Why does a Fetch / get / query throw OptimisticLockException
PostPosted: Fri Mar 25, 2011 4:07 pm 
Newbie

Joined: Mon Mar 21, 2011 3:40 pm
Posts: 10
I'm working with JPA 1.99 and Optimistic Concurrency.

I have versioned entities, and am fetching/locking/merging them as needed.

My question is: Why does the retrieval throw an optimisticLockException? I would think it wouldn't throw until it tries to merge/persist the the entity.

-JD


Top
 Profile  
 
 Post subject: Re: Why does a Fetch / get / query throw OptimisticLockException
PostPosted: Fri Mar 25, 2011 5:50 pm 
Newbie

Joined: Mon Mar 21, 2011 3:40 pm
Posts: 10
Continuing to debug this...
I notice that a select is doing an update for some reason...

So.. Insert EntityVersion =0;

Fetch... Does a select, and then an Update to version 1.

Doesn't seem right to me.


Top
 Profile  
 
 Post subject: Re: Why does a Fetch / get / query throw OptimisticLockException
PostPosted: Fri Mar 25, 2011 7:15 pm 
Newbie

Joined: Mon Mar 21, 2011 3:40 pm
Posts: 10
Closing in on this issue I think I know generally what it is now...

My entity has a couple Custom User Types to Support double[] array's and int[] arrays

I think the User Type or some other part of Hibernate thinks that they are always modified... and so after the Select it automatically does an Update...

For similar reasons this is exploding all my optimistic concurrency code.


Top
 Profile  
 
 Post subject: Re: Why does a Fetch / get / query throw OptimisticLockException
PostPosted: Fri Mar 25, 2011 7:34 pm 
Newbie

Joined: Mon Mar 21, 2011 3:40 pm
Posts: 10
Audit Columns... Oh audit .. why did I have to be so clever.... The trigger of course changes the modified date on insert...

Problem solved.


Top
 Profile  
 
 Post subject: Re: Why does a Fetch / get / query throw OptimisticLockException
PostPosted: Sun Mar 27, 2011 6:52 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Nice one :)
What's JPA 1.99 by the way?

_________________
Sanne
http://in.relation.to/


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

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.