2 Replies Latest reply on Dec 6, 2011 8:07 AM by Urs Rothenhäusler

    Locking, Transaction, SFSB, 2 apps

    Urs Rothenhäusler Newbie

      Hello,

       

      I get a row locking error from the database when I try to read (and possibly write) a record from a table which has exactly one row. This table holds a value for generating a key. The problem is that this table/entity is accessed by different applications. It's implement like this:

       

      @Stateful

      @Remote( VZBusinessRemote.class )

      @Local( VZBusinessLocal.class )

      public class VZBean implements VZBusinessLocal, VZBusinessRemote {

       

          @PersistenceContext(unitName="AUnitEJB")

          private EntityManager em;

       

          @EJB( name="vzBeanAVPBasis", beanName="AVPBasisBean" )

          private AVPBasisBusinessLocal basisBean;

       

          private Long key;

       

      @Override

          public void unmarshalAVZ( AVZ avz, int startAt, int endat ){

      ...domanythings...

               key = basisBean.findKeyAndSaveKey();

      ....domanythings...

      }

       

      After invoking the SFSB unmarshalAVZ() and calling basisBean.findKeyAndSaveKey() inside this method other applications cannot read nor write to the table/entity with the key table. Even if I call em.clear() after getting and updating the key table the record is locked for other application, but it should be possible for other apps even to write to the locked record. When the method unmarshalAVZ() is finished, locking isn't a problem anymore, but this method can take a very long time and thus locks the key table.

       

      So - what can I do or what's wrong?

       

      Thanks for an answer