jpa - PESSIMISTIC_READ lock on same entity cannot be acquired by 2 services -


from jpa documentation, pessimistic_read lock on entity can acquired if no 1 holding pessimistic_write lock on entity. however, tested using openjpa 2.0.0, websphere , mssql (as db2), seems 2 services cannot acquire pessimistic_read lock on same entity @ same time.

this code (in configejb) used lock entity:

configentity configentity = this.getentitybyid(1); // entity this.entitymanager.lock(configentity, lockmodetype.pessimistic_read); 

2 instances of configejb invoked. first instance acquire lock successfully. however, second instance couldn't lock, , blocked until first instance finished transaction (i expected lock).

has ever encountered problem? or expected behavior of jpa? how let services obtain pessimistic_read locks properly?

not found in reference, pro jpa2 saying:

some databases support locking mechanisms repeatable read isolation without acquiring write lock. pessimistic_read mode can used pessimistically achieve repeatable read semantics when no writes entity expected. fact kind of situation not encountered often, combined the allowance providers have of implementing using pessimistic write lock, leads mode not 1 picked , commonly used.

so, seems database provider replace pessimistic_read pessimistic_write


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -