OpenJPA dirty read hint

We have the following DAO stack:

  • DB2 9.7 Express-C
  • OpenJPA 2.0.1
  • Spring 3.0.5
  • Bitronix 2.1.1

How do you tell OpenJPA to add the WITH UR sql clause to the end of the query?

I browsed sites and manuals for several days, it should be something like this:

 Query q = em.createQuery("select m from Magazine m where ... "); q.setHint("openjpa.FetchPlan.ReadLockMode","WRITE"); List r = q.getResultList(); 

but, alas, I could not find a workable OpenJPA property that would be passed as the setHint() argument and give the WITH UR result as the result, so I use SpringJDBC queries, which, unfortunately, I can no longer use.

Any ideas? Thank you very much

+4
source share
2 answers

OpenJPA does not support using the WITH UR clause with JPQL. You can always use your own query for this function.

+4
source

I have a pretty similar problem right now - it would seem, the installation:

 query.setHint("openjpa.FetchPlan.Isolation", "READ_UNCOMMITTED"); 

would do the trick. Unfortunately, the source code shows that the withURClause constant from org.apache.openjpa.jdbc.sql.DB2Dictionary never read.

In addition, OpenJPA never takes into account the sample plan hint if the query is not FOR UPDATE . I have a select statement that locks on exclusive locks and it can really work with uncommitted data - no-go with OpenJPA.

0
source

All Articles