That's the query method in my stateless EJB
public Myobj getById(Long id){
Myobj myobj = entityManager.find(Myobj .class, id);
return myobj ;
}
I don't set a write lock explicitely - maybe openejb set the default behaviour
to use a write lock? How can I switch of the write lock explictely (is this
done in persistence.xml?)?
If I use hibernate (in this openejb scenario) it works fine (I mean as desired).
J Grassel wrote:
> Good morning!
>
> Couple questions. When you fetch the entity with the getById() call, are
> you:
> 1) Modifying any of its persistent fields?
> 2) Establishing a write-lock? (by API action or configured default
> behavior)
>
> If you're just fetching data, without mutating it and without any
> write-locks, then there is some sort of problem which would need to be
> addressed.
>
> As for the Exception,
> org.apache.openjpa.persistence.OptimisticLockException, being thrown, the
> javadoc at
> http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/javadoc/index.html
> states that org.apache.openjpa.persistence.OptimisticLockException extends
> javax.persistence.OptimisticLockException, so a catch block for
> javax.persistence.OptimisticLockException will still catch it.
>
>
> verkehr wrote:
>> I'm using openejb 3.1.1 with includes openjpa. I'm annotating an Integer
>> field with "@Version".
>> Every time I'm querying a row (e.g. calling "ejb.getById()") will cause an
>> update of the row with a new version! A call to "ejb.getAll()" (which
>> retrieves all rows as a java.util.List) updates all rows with a new
>> version number!!
>> In my opinion nn update of the version field (column) should only occur
>> calling "persist()". - Hibernate does so! JPA specification chapter 3.4.
>> says it too.
>>
>> Is there a parameter to set that changes this behaviour.
>>
>> Further, openjpa throws an
>> org.apache.openjpa.persistence.OptimisticLockException and not
>> javax.persistence.OptimisticLockException
>> Why? This prohibits protability. Hibernate throws
>> javax.persistence.OptimisticLockException
>> --
>> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
>> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>>
>>
>
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01