Announcement Announcement Module
Collapse
No announcement yet.
optmistic lock problem doesn't work properly Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • optmistic lock problem doesn't work properly

    I tested my web application using 2 browser.
    I access the same edit form from 2 browser.
    Then i click updated entity from the first one ... then i update the entity from the second one. No problem is detected!
    Entity A , version = 15
    Entity B, version = 15

    when i is updating the entity i retrieve it by id using find method (EntityManager). Then i set the fields from form.
    after the update operation (using merge, the just operation for updating ) the version of A is 16 correctly.
    Then i click entity usng the second form (another browser).
    When i retrieve the entity B the version is 16 and not 15 , so no problem is detected by optimistic lock.

  • #2
    I tested my web application using 2 browsers.
    In details , I accessed the same edit form from 2 browsers.
    I click to upodate the entity from the first one ... then i click to update the entity from the second one. No problem is detected!
    Details in debug mode:
    For example i have a entity Person with id 10.
    I begin with this status: Person with id 10 , version = 15


    when i is updating the Person (from the form ) i retrieve it by id using find method (EntityManager). Then i set the fields from form.
    After the update operation (using merge, the just operation for updating ) the version of Person (id 10) is 16 correctly.
    Then i click in the second form for updtating the same Person(id 10) using the second form (another browser).
    When i retrieve the Person entity using find method ( i receive back the data from the form) the version is 16 and not 15 , so no problem is detected (no optimistic lock problem).
    I expect that the Person is saved in the different sessions using 2 different browsers so 2 different instances of Person entity are used but it seamns to be the same. Why ?

    Comment


    • #3
      It are 2 different instances but you retrieve it before you are updating it so it is the same id/version you are updating. You should store it in the http session instead of retrieving it before update.

      Comment

      Working...
      X