Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:16:16+00:00 2026-06-13T13:16:16+00:00

I am using Ebean with Play Framework 2 and sometimes it falls with OptimisticLockException

  • 0

I am using Ebean with Play Framework 2 and sometimes it falls with OptimisticLockException of such kind:

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[OptimisticLockException: Data has changed. updated [0] rows sql[update manager set modification_time=?, session_id=?, expiration_date=? where id=? and rating=? and creation_time=? and modification_time=? and name=? and surname=? and login=? and password_hash=? and email=? and session_id=? and expiration_date=?] bind[null]]]

This happen when few actors start to access database.

So, Manager class is:

public class Manager extends Model {
@Getter @Setter
Long id;

@Getter @Setter
private String name;

@Getter @Setter
private String surname;

@Column(unique = true)
@Getter @Setter
private String login;

@Getter @Setter
private String passwordHash;

@Getter @Setter
private String email;

@Embedded
@Getter @Setter
private ManagerSession session;

@Getter
private Timestamp creationTime;

@Getter
private Timestamp modificationTime;

@Override
public void save() {
    this.creationTime       = new Timestamp(System.currentTimeMillis());
    this.modificationTime   = new Timestamp(System.currentTimeMillis());
    super.save();
}

@Override
public void update() {
    this.modificationTime   = new Timestamp(System.currentTimeMillis());
    super.update();
}

}

save() and update() hooks used instead @PrePersist annotations, because of Ebean doesn’t support it.
As I know @Version annotation allways brings Optimistic lock mode, so I start to use such trick. I know what Optimistick lock is, but how this situation should be solved, when many actors should modify same db record, where last modification wins?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:16:17+00:00Added an answer on June 13, 2026 at 1:16 pm

    Solution:

    The problem: Saving a detached EBean model directly from the Play Form causes either OptimisticLockException, or when using @Version it causes NullpointerException.

    Form<Venue> form = form(Venue.class).bindFromRequest();
    form.get().update(id); // this causes the exception
    

    The solution: The form should support supplying it an object from database, before binding from the request parameters. The parameters found in the request should then overwrite the relevant properties on the object. Perhaps call fill() before bindFromRequest():

    Form<Venue> form = form(Venue.class).fill(Venue.find.byId(id)).bindFromRequest();
    form.get().update(id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing small app, using Play Framework 2.0 which uses Ebean as ORM.
I'm using Ebean in Play Framework 2 for storing some basic information. This application
I am using Play 2.0.2 with ebean. In Info class, I defined @ManyToMany(fetch=FetchType.EAGER) private
Using The Play Framework how easy would it be to allow an admin user
I am exploring JPA and Ebean within Play Framework 2.0.1 to research what is
I'm using Ebean, and define such a model: @Entity @Table(name = users) public class
Using PostgreSQL 8.4 and with a table such as this: create table log (
Using Core Data, I have a fetch request to fetch the minimum of a
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using HTML 5, I want to play multiple sounds simultaneously. how can I do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.