cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling optimistic locking on NetWeaver

Former Member
0 Kudos

Hi,

I want to use optimistic locking on selected EJB entities. I annotated an entity-Attribute as @Version (type long) and changed isolation level on the data source alias to 'transaction read committed'. But the entities version-attribute is not incremented and no exception is thrown. What do I need to do in order to make optimistic locking work in NetWeaver 7.31 / JPA 1.0 and MaxDB?

Thanks.

Regards

Anja

Accepted Solutions (0)

Answers (1)

Answers (1)

isaias_freitas
Advisor
Advisor
0 Kudos

Hello Anja,

Are you talking about enqueue locks (transaction SM12)?

Regards,

Isaías

Former Member
0 Kudos

Hi Isaias,

no, as far as I know enqueue locks is something else. And I'm talking about developing a Java application on Application Server NetWeaver and not SAP ERP.

Regards

Anja

isaias_freitas
Advisor
Advisor
0 Kudos

Hello Anja,

The NW Java has the enqueue mechanism as well...

I believe that first we need clarification of what locking mechanism you are talking about (enqueue? database?). Then, we can try to give some inputs .

Regards,

Isaías

Former Member
0 Kudos

Hi Isaias,

I'm developing a JEE application with EJB, running on NW 7.31 with two nodes, no cluster. I face a concurrency problem: two threads access concurrently the same entity to modify it and the thread writing last overwrites the changes of the earlier thread. I don't see a way to avoid programmatically for sure that two threads operate concurrently. JEE offers entity annotation @versionId (the field is handled by the persistence provider) which combinded with DB-isolation level READ_COMMITTED guaranties that such inconsistencies are avoided. Although changing isolation level on the DB connection in NWA and restarting the server, a redeployment seems to reset the change. At least the isolation level change is not for long. I figured out to make optimistic locking work with READ_UNCOMMITTED and a version generation table (configured in persistence.xml), although it should be possible to set reliable the DB isolation level. Using the @versionId should be simple as this whereas the enqueue server seems to be complicated.

But finally I have to solve this concurrency problem, no matter what the best solution might be.

Regards

Anja

isaias_freitas
Advisor
Advisor
0 Kudos

Hello Anja,

OK, that does not seem related to the enqueue mechanism, indeed.

In this case, I will not be able to help .

Hopefully, someone else will be able to help you.

Good luck!

Isaías