DIsable Optimistic Locking

387 views
Skip to first unread message

Daryl Stultz

unread,
Sep 5, 2010, 4:37:14 PM9/5/10
to Ebean ORM
Hello,

I've got a complex block of code I'm trying to convert to Ebean. I'm
running into an Optimistic Locking problem (update didn't change any
rows). I don't have a version column yet. Is there a way to disable
Optimistic Locking?

Thanks
/Daryl

Rob Bygrave

unread,
Sep 6, 2010, 6:03:10 AM9/6/10
to eb...@googlegroups.com
>> Is there a way to disable Optimistic Locking?

No in that there is no deployment annotation to set the default concurreny checking more on a particular bean type to None (rather than Version or All).

You could use EbeanServer.update() ... when you know that it is an update (rather than an insert) with the caveats around primitives or explicitly specify the properties to update.

... or you could use an Update statement.   EbeanServer.createUpdate(...)

Daryl Stultz

unread,
Sep 7, 2010, 8:56:02 AM9/7/10
to Ebean ORM

On Sep 6, 6:03 am, Rob Bygrave <robin.bygr...@gmail.com> wrote:
> >> Is there a way to disable Optimistic Locking?
>
> No in that there is no deployment annotation to set the default concurreny
> checking more on a particular bean type to None (rather than Version or
> All).

Not sure I understand this. Are you referring to a JPA annotation?

I threw in a Version column and it's working now. The entity has
several timestamp columns so I imagine the update was failing due to
precision issues.

Here's an enhancement idea: it seems the logging line for the bound
values gets written after successful execution of the query. If the
query fails, we don't get to see the values that were bound. Can this
be changed? Write the bind line before executing the query?

Thanks.

/Daryl

Rob Bygrave

unread,
Sep 8, 2010, 5:50:28 AM9/8/10
to eb...@googlegroups.com
> Are you referring to a JPA annotation?

I was meaning an Ebean specific annotation which would enable you to effectively specify the concurrency mode = NONE (rather than ALL or VERSION) - but there is not one (in Ebean code you would set the ConcurrencyMode against the DeployBeanDescriptor but there is no deployment option to do that).


> If the query fails, we don't get to see the values that were bound.

Good point. I'll look at the catch block and look instead to include the bind values in the error message.
Reply all
Reply to author
Forward
0 new messages