Explicit locking of Entity JavaBean

Hi!
I am developing local WD application based on EJB model using SAP NetWeaver Developer Studio 7.0.12
There's Employee entity javabean, that is shown as a table on EmployeeView webdynpro view (model node, bound to controller).
There's also EmployeeEdit webdynpro view, where Employee entity javabean is shown as set of InputFields (same model node, bound to controller).
When user clicks Save button in EmployeeEdit view, changed values are saved.
The problem arises when two users want to change the same record of Employee entity. Both can go to EmployeeEdit view, change values of record and click Save button, because actual transaction for saving is implemented only when users click Save button.
The workaround for this would be explicit locking of entity record when first user goes to EmployeeEdit view, if it's not already locked. But I couldn't find enough information about this.
[EJBLocking interface|http://help.sap.com/javadocs/nw04/current/en/com/sap/engine/interfaces/ejb/locking/EJBLocking.html] might be what I need, but I don't know how to use it.
Can anyone give me an idea about all this?
Thanks in advance
Renat

Hi, Ganga!
Thank You for reply,
I've already chosen "Local" locking for my entity bean and trying to realize explicit locking for my entity.
I can't understand, what parameters do I need to pass to lock method.
Here is code of entity home method, which is called to lock this entity.
     public void ejbHomeLockMe() {
          EJBLocking ejbl = null;
          Context ctx = null;
          try {
               ctx = new InitialContext();
               ejbl = (EJBLocking) ctx.lookup("java:comp/EJBLocking");
          } catch (NamingException ne) {
               ne.printStackTrace();
               throw new OklaException(ne.getMessage());
          try {
               DataSource ds = (DataSource) ctx.lookup("jdbc/OKLA_DS");
               ejbl.lock( //here I get NullPointerException
                    TableLocking.LIFETIME_TRANSACTION,
                    ds.getConnection(),
                    (EntityBean) this,
                    TableLocking.MODE_EXCLUSIVE_NONCUMULATIVE);
          } catch (SQLException sqle) {
               sqle.printStackTrace();
               throw new OklaException(sqle.getMessage());
          } catch (NamingException ne) {
               ne.printStackTrace();
               throw new OklaException(ne.getMessage());
As a result I get this exception
   java.lang.NullPointerException
    at com.sap.engine.services.ejb.entity.pm.lock.EJBLockingImpl.getPKMap(EJBLockingImpl.java:108)
    at com.sap.engine.services.ejb.entity.pm.lock.EJBLockingImpl.lock(EJBLockingImpl.java:48)
    at my.company.okla.employee.EmployeeBean.ejbHomeLockMe(EmployeeBean.java:92)
Any thoughts about this?
Many thanks
Renat

Similar Messages

  • Error while deploying entity javabean (CMP)

    Hello,
    I have a problem while I'm trying to deploy an entity javabean (with container managed persistance). I'm using JDeveloper 3.2.3 and 8.1.7.2 database.
    Here is the error I get:
    *** Executing deployment profile E:\Xaris\JDeveloper\General\EJBs\EmpCmp\EmpCmp.prf ***
    *** Generating archive file E:\Xaris\JDeveloper\General\EJBs\EmpCmp\empcmp.jar ***
    Compiling the project...done
    Validating the profile...done
    Initializing deployment...done
    Scanning project files...done
    Generating classpath dependencies...done
    Generating archive entries table...done
    *** Archive generation completed ***
    *** Deploying the EJB to 8i JVM ***
    EJB deployment argument list:
    "E:\Program Files\Oracle\JDeveloper 3.2.3\java1.2\jre\bin\javaw"
    "-DPATH=E:\Program Files\Oracle\JDeveloper 3.2.3\bin;E:\Program Files\Oracle\JDeveloper 3.2.3\java1.2\bin"
    -classpath
    "E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\aurora_client.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\javax-ssl-1_2.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\jasper.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\vbjorb.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\vbjapp.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\vbjtools.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\vbj30ssl.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\aurora.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\sqlj\lib\translator.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\sqlj\lib\runtime.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\aurora\lib\mts.jar;E:\Xaris\JDeveloper\General\EJBs\EmpCmp\classes;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\jdev-rt.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\jdbc\lib\oracle8.1.7\classes12.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\connectionmanager.zip;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\javax_ejb.zip;C:\Program Fil
    s\JavaSoft\JRE\1.3.1\lib\i18n.jar;C:\Program Files\JavaSoft\JRE\1.3.1\lib\jaws.jar;C:\Program Files\JavaSoft\JRE\1.3.1\lib\rt.jar;C:\Program Files\JavaSoft\JRE\1.3.1\lib\sunrsasign.jar;E:\Program Files\Oracle\JDeveloper 3.2.3\lib\xmlparserv2.jar"
    oracle.aurora.ejb.deployment.GenerateEjb
    -u
    harris
    -p
    harris
    -s
    sess_iiop://192.168.10.218:2481:WORK
    -keep
    -temp
    TEMP
    -descriptor
    "E:\Xaris\JDeveloper\General\EJBs\EmpCmp\EmpCmp.xml"
    -oracledescriptor
    E:\Xaris\JDeveloper\General\EJBs\EmpCmp\EmpCmp_oracle.xml
    -generated
    "E:\Xaris\JDeveloper\General\EJBs\EmpCmp\EmpCmpClient.jar"
    "E:\Xaris\JDeveloper\General\EJBs\EmpCmp\empcmp.jar"
    Reading Deployment Descriptor...done
    Verifying Deployment Descriptor...done
    Gathering users...done
    Processing container managed persistence bean...done
    Generating Comm Stubs.............................................done
    Compiling Stubs...done
    Generating Jar File...done
    Loading EJB Jar file and Comm Stubs Jar file...done
    Generating EJBHome and EJBObject on the server...
    An exception occurred during code generation: null
    *** Errors occurred while deploying the EJB to 8i JVM ***
    *** Deployment completed ***
    Can anyone help me understand where is the error?
    Thanks in advance,
    Charalampos

    Volker,
    Let me try again (in the hope that this time you will understand
    what I am saying).
    "database embedded EJB container" and "EJB" are not the same thing.We are a little bit further in technology, so that we have no single Engine, single
    Processor Systems any more.
    Distribution over many computers (RAC) is done by Visigenic ORB (9i) or OC4J.
    EJB Framework is for distribution of Business Logic or in your words of
    Database Logic.
    Oracle is abandoning the "database embedded EJB container".
    Oracle is not abandoning EJB.Please step into technology and make a comparison of Java Stored
    Procedures, look at the native compiler ncomp and try to figure out which
    classes are important for Server Side software development.
    Oracle recommends using OC4J as the EJB container.
    Here is a recent post (from an Oracle employee and regular forum
    participant) from the J2EE forum:
    High number of http 404 errors from webcache
    Here is a quote from that post:
    starting from Oracle9i Release 2 Database EJBs are going to be desupported from database. EJBs can only be deployed in OC4J component of Oracle9iASAs far as I can see, it makes no sense to do that step.
    I beleave, that this decision is very very short lived.
    Unfortunately, my German is very poor -- I can only try to explainYou are right, I am a German.
    things to you in English. Hopefully (if you are still not comprehending
    what I am saying), some kind soul (who must have a better levelAmerican english is for everyone.
    of reading and comprehension in English than you) will explain it
    to you in your native tongue.I have understood, what you said!
    So let me summarize:
    Oracle is abandoning the database embedded EJB container.I don't beleave that! Is that OK!
    By the way, something may have gotten lost in the translation, or
    this may be just another example of your comprehension problem, but
    what is the connection between the TowerJ JVM and the Oracle databasencomp has the same architecture as TowerJ native Compiler.
    Ok?
    embedded EJB container?
    The very best of luck to you,Thanks a lot!
    Avi +Volker!

  • Object locking of entity bean in a SSBean[Environment: WebLogic 10.0, EJB3.0, Kodo/OpenJPA]

    Hello friends,
    I am facing bottle neck with Object Locking for an Entity bean using OpenJPA Persistence Manager under Weblogic 10.0 application server deployments.
    I want to block [ for the specific method ] entity bean being accessed from other client programs when they invoke common method in a Stateless Session EJB. Particularly, Consider the situation:
    Client1: Modifying Customer entity with id: 100. Then I locked that entity using OpenJPA Entity Manager within the transaction block. And i entered that thread to sleep before committing the transaction.
    At this time, started new thread, Client2: Modifying the same Customer entity with id:100. I expected this thread will be get blocked when control pass to the lock() method. But it doesn't happened. It goes through the line of codes and also put into sleep.
    After thread sleep timeout, first thread Client1 commit successfully. But the second gets Rollback Exception due to optimistic lock exception occurring since customer entity is modified in another transaction.
    This exception is occurred because of Database level concurrency control for optimistic locking in a weblogic server. Its default to weblogic.
    But, what i expected is to assert lock at the object level, thereby the 2nd thread - Client2 will be blocked while Client1 is in the middle of a transaction and then Client2 use modified Customer entity . But it doesn't happened. I used Kodo Persistance Provider as Persistence Unit, OpenJPAEntityManager to do transaction, locking , finding and merging the entity bean.
    Can anyone provide help to fine grain this object locking functionality ??? I look forward to your brilliant thoughts......
    Rajesh KR
    Geojit Technologies

    Dear Chicon,
    I made thread to sleep for checking the "Object Locking" functionality of OpenJPAEntityManager. My intention was to block the second thread when the first thread being locked when a concurrent access occurs. But it doesn't happened and code execution passed to thread sleep.
    I mean when 2 client access the same entity at same time (in same milliseconds) , and what happens to 2nd thread when 1st thread locks the entity object.
    I guarantee you that i started the 2nd thread before the 4sec time stamp given to the object locking. I tested it with a bigger timestamp, still it given concurrent blocking of the same entity bean.
    My question is why the object locking is not working with concurrent access to same entity bean from more than one thread???
    I think you get the correct question what i intended ????
    Regards,
    Raj...

  • Explicit Lock on for Update Table

    If I want to perform explicit lock acquiring on updating all records in “customer” table with “state” equals to “CA”. What command should I run?

    Hi,
    Refer to following ppt.
    http://www.indiana.edu/~dbateam/Documents/oracle_locking.ppt#260,5,Oracle Isolation Levels
    You can get to know the things.
    - Pavan Kumar N

  • Oracle Explicit Locks

    Hello experts ,
    Once again i want to clear my basic knowldge in terms of oracle locks.
    what i knows is that oracle atumatically locked the object whenever we perform any dml operation.( update,delete)
    but it is row level exclusive lock ( i.e. RX,in v$locked_object, it show locked mode 3 )
    It is implicit lock which oracle provided automatically.
    and the other lock is Explicit lock,
    it is either we have to locked the by using LOCK statement ( by using LOCK statement we can lock the table in modes
    (i.e row share(2),row exclusive(3), share(4), row share exclusive(5),exclusive(6) )
    OR
    the table is also locked by statemet "select ..for update"( but its row exlusive lock (RX 3))
    but
    when and in what condition we apply explicit lock?
    what are the practical future of these lock?
    can you please explain about these explicit lock like
    row share(2)
    row exclusive(3)
    share(4)
    row share exclusive(5)
    exclusive(6)
    I have read about these lock from books , blogs and other internet sites , but still my concepts is not clear
    in these area.
    Thanks in advance for your help.
    Regards,
    Prashant Mhatre

    Oracle uses locks (aka enqueues) to prevent destructive concurrent operations on a resource. Here is a short description of the different lock types written by Jonathan Lewis ("the international recognized Oracle Expert"): http://jonathanlewis.wordpress.com/2010/06/21/locks/.
    Except of the SELECT FOR UPDATE case I don't think there are many situation in which setting an explicit lock is necessary - the server knows where and when locks have to be used.

  • Locking Bol entity in Simple object

    Hi,
    I have created a Simple Object with a structure and have assigned the BOL entity to my custom view. Now if I want to lock the structure in event handing method, the locking fails. how can I lock the custom structure?
    Thanks,
    Nandini

    Dear Chicon,
    I made thread to sleep for checking the "Object Locking" functionality of OpenJPAEntityManager. My intention was to block the second thread when the first thread being locked when a concurrent access occurs. But it doesn't happened and code execution passed to thread sleep.
    I mean when 2 client access the same entity at same time (in same milliseconds) , and what happens to 2nd thread when 1st thread locks the entity object.
    I guarantee you that i started the 2nd thread before the 4sec time stamp given to the object locking. I tested it with a bigger timestamp, still it given concurrent blocking of the same entity bean.
    My question is why the object locking is not working with concurrent access to same entity bean from more than one thread???
    I think you get the correct question what i intended ????
    Regards,
    Raj...

  • Explicit Locking Question

    Dear all
    I have a question about <<Developer’s Guide>> Explicit Locking (27-3):
    "In a replicated cache, puts are blocked, but they are not blocked in a partitioned cache. "
    I want to know why "puts are not blocked in a partitioned cache."
    Thanks

    wangjw wrote:
    Dear all
    I have a question about <<Developer’s Guide>> Explicit Locking (27-3):
    "In a replicated cache, puts are blocked, but they are not blocked in a partitioned cache. "
    I want to know why "puts are not blocked in a partitioned cache."
    ThanksThe normal behaviour is that lock does not block anything other than another lock.
    The put-blocking behaviour at replicated caches is an anomaly which may be necessary due to backward compatibility reasons, or possibly a necessity due to the message flow for mutating operations in a replicated cache.
    So the question really would be why puts are blocked in a replicated cache, and I would also be interested in the answer, although I have my guesses.
    Best regards,
    Robert

  • Cannot Lock Base Entity

    Hi,
    We are having an issues with one of the base entity locking it. When we try to Lock the entity, it doesn't do anything. It just says "Requesting Data from Server" and then disappears.
    The ENtity is consolidated. No Phase Submission enabled and no Out of Balance. Still not able to LOCK. Version is 11.1.1.3
    Any thoughts?
    Thanks,
    P

    Hi there,
    It seems like an application issue.
    Do you have the same issue with other entities? In other years? Can you Lock the entity on another application?
    Regards,
    Thanos

  • I Can't lock an entity that has "OK" calculation status and "Published" review level

    The problem into the HFM aplication is that I have to lock the actual period but one entity has "OK" calculation status and "Published" review level; when I clic "lock" on the entity, the system send a message "The process Unit cannot be locked if it needs to be calculated, translated, or consolidated"
    Thank you

    Check the Other Value dimensions.  Locks are value specific(So locking Entity Currency doesn't necessarily lock Parent Currency).  Make sure all the value dimensions are at OK status.

  • CAF Entity locking HELP

    hello
    I am doing some tests in WebDynpro and CAF Core services.
    I have a piece of code as below that retrieves an entity from CAF Core for update. I need this entity to be locked during the update but the two methods lock() and unlock() do nothing. I can still access for update the same entity instance from another user.
    This probably works if the transaction is happening within CAF service but I also need to lock entities from webdynpro when doing complex updates. In other words I am not willing to create a custom method in CAF service for each update I need to implement in webdynpro.
    Any advice ? How are we supposed to use the class com.sap.tc.col.client.generic.api.LockStrategy ? I did not find much about this api.
    Thanks in advance
    Vitaliano
      public void UpdateKAMInTransaction( )
        //@@begin UpdateKAMInTransaction()
         IServiceFacade serviceFacade = CAFServiceFactory.getServiceFacade(cplxmdlDefinition.class);
        String guid = wdContext.currentAKamElement().getGuid();
         AKam akam = MyAppProxy.readKam(guid);
         //locking is not working at all. concurrent changes are lost
         akam.lock(LockStrategy.EXCLUSIVE);
         //update a value here
         akam.setVersion(akam.getVersion() + 1);
         akam.getAspect().sendChanges();
         serviceFacade.save();
         //locking is not working at all. concurrent changes are lost
         akam.unlock();
         wdThis.wdGetAPI().getMessageManager().reportSuccess("done update AKAM=" + akam);
        //@@end

    Now I feel lost. Please keep helping a newby.
    I have implemented my custom method in CAF Services. Here I lock the entity, make all my chanegs, then update and return. I call this custom CAF Application Service method from WebDynpro.
    Nevertheless I noticed that concurrency can still happen. If more than one user updates the same entity at the same time, and exception is thrown in the log files but no exception is thrown. I.e. I cannot intercept the collision.
    in the log file a huge stacktrace is written, while the most interesting message is "javax.jdo.JDOUserException: optimistic transaction failed".
    So... what am I doing wrong here? Should'nt new locking just hold until the existing one is released?
    HELP!
    Vitaliano
         public java.lang.String myUpdateKam(java.lang.String guid, long newVersion) throws com.sap.caf.rt.exception.ServiceException
              // logging
              java.lang.String CAF_user = sessionContext.getCallerPrincipal().getName();
              java.lang.String CAF_methodHeader = MyAppBean.JARM_REQUEST + ":" + "myUpdateKam(java.lang.String, long)";
              Object[] CAF_parameters = new Object[] { guid, new java.lang.Long(newVersion)};
              com.sap.caf.rt.util.CAFPublicLogger.entering(CAF_user, MyAppBean.JARM_REQUEST, CAF_methodHeader, MyAppBean.location, CAF_parameters);
              java.lang.String retValue;
              try
                   //@@custom code start - myUpdateKam(java.lang.String, long)
                   //Read the BO and prepare for changes
                   retValue = "";
                   Kam kam = getKamService().read(guid);
                   char modeLock = IBusinessEntityService.MODE_WRITE;
                   try
                        //Lock BO before updating
                        try
                             getKamService().lock(kam.getKey(), modeLock, 3000);
                             retValue += "-lock-";
                        catch (CAFLockException e)
                             retValue += e.getMessage();
                        //Now do the update and commit
                        // =====> NOTE: regardelss if there is another update in progress,
                        // a concurrent update still gets down to here. WHY ?
                        long counter = kam.getVersion();
                        kam.setVersion(++counter);
                        getKamService().update(kam);
                        retValue += "-update-";
                   catch (CAFUpdateException e)
                        //This case is when concurrent update occurs
                        retValue += e.getMessage();
                   catch (Exception e)
                        //any other exception thrown?
                        retValue += e.getMessage();
                   finally
                        //Make sure we always leave our BO unlocked
                        try
                             getKamService().unlock(kam.getKey(), modeLock);
                             retValue += "-unlock-";
                        catch (CAFLockException e)
                             retValue += e.getMessage();
                   //@@custom code end - myUpdateKam(java.lang.String, long)
                   return retValue;
              finally
                   com.sap.caf.rt.util.CAFPublicLogger.exiting(CAF_user, MyAppBean.JARM_REQUEST, CAF_methodHeader, MyAppBean.location, CAF_parameters);
    This is the code in WebDynpro to invoke CAF custom method.
      public void UpdateKAMRemotely( )
        //@@begin UpdateKAMRemotely()
         IServiceFacade serviceFacade = CAFServiceFactory.getServiceFacade(cplxmdlDefinition.class);
         IAspect retValue = null;
         for (int i = 1; i < 101; i++)
              long newLong = wdContext.currentAKamElement().getVersion() +i;
              retValue = MyAppProxy.myUpdateKam(wdContext.currentAKamElement().getGuid(),newLong);
              IAspectRow row = retValue.getAspectRow(0);
              String retMsg = row.getAttributeAsString("value");
              wdThis.wdGetAPI().getMessageManager().reportSuccess("IAspectRow=" + row + "index="+i);
              serviceFacade.save();
        //@@end
    Message was edited by:
            Vitaliano Trecca

  • NON-transactional session bean access entity bean

    We are currently profiling our product using Borland OptmizeIt tool, and we
    found some interesting issues. Due to our design, we have many session beans which
    are non transactional, and these session beans will access entity beans to do
    the reading operations, such as getWeight, getRate, since it's read only, there
    is no need to do transaction commit stuff which really takes time, this could
    be seen through the profile. I know weblogic support readonly entity bean, but
    it seems that it only has benefit on ejbLoad call, my test program shows that
    weblogic still creates local transaction even I specified it as transaction not
    supported, and Transaction.commit() will always be called in postInvoke(), from
    the profile, we got that for a single method call, such as getRate(), 80% time
    spent on postInvoke(), any suggestion on this? BTW, most of our entity beans are
    using Exclusive lock, that's the reason that we use non-transactional session
    bean to avoid dead lock problem.
    Thanks

    Slava,
    Thanks for the link, actually I read it before, and following is what I extracted
    it from the doc:
    <weblogic-doc>
    Do not set db-is-shared to "false" if you set the entity bean's concurrency
    strategy to the "Database" option. If you do, WebLogic Server will ignore the
    db-is-shared setting.
    </weblogic-doc>
    Thanks
    "Slava Imeshev" <[email protected]> wrote:
    Hi Jinsong,
    You may want to read this to get more detailed explanation
    on db-is-shared (cache-between-transactions for 7.0):
    http://e-docs.bea.com/wls/docs61/ejb/EJB_environment.html#1127563
    Let me know if you have any questions.
    Regards,
    Slava Imeshev
    "Jinsong HU" <[email protected]> wrote in message
    news:[email protected]...
    Thanks.
    But it's still not clear to me in db-is-shared setting, if I specifiedentity
    lock as database lock, I assumed db-is-shared is useless, because foreach
    new
    transaction, entity bean will reload data anyway. Correct me if I amwrong.
    Jinsong
    "Slava Imeshev" <[email protected]> wrote:
    Jinsong,
    See my answers inline.
    "Jinsong Hu" <[email protected]> wrote in message
    news:[email protected]...
    Hi Slava,
    Thanks for your reply, actually, I agree with you, we need to
    review
    our db
    schema and seperate business logic to avoid db lock. I can not say,guys,
    we need
    to change this and that, since it's a big application and developedsince
    EJB1.0
    spec, I think they are afraid to do such a big change.Total rewrite is the worst thing that can happen to an app. The
    better aproach would be identifying the most critical piece and
    make a surgery on it.
    Following are questions in my mind:
    (1) I think there should be many companies using weblogic serverto
    develop
    large enterprise applications, I am just wondering what's the maintransaction/lock
    mechanism that is used? Transional session / database lock,
    db-is-shared
    entity
    I can't say for the whole community, as for my experience the standard
    usage patthern is session fasades calling Entity EJBs while having
    Required TX attribute plus plain transacted JDBC calls for bulk
    reads or inserts.
    is the dominant one? It seems that if you speficy database lock,
    the
    db-is-shared
    should be true, right?Basically it's not true. One will need db-is-shared only if thereare
    changes
    to the database done from outside of the app server.
    (2) For RO bean, if I specify read-idle-timeout to 0, it shouldonly
    load
    once at the first use time, right?I assume read-timeout-seconds was meant. That's right, but if
    an application constantly reads new RO data, RO beans will be
    constantly dropped from cache and new ones will be loaded.
    You may want to looks at server console to see if there's a lot
    of passivation for RO beans.
    (3) For clustering part, have anyone use it in real enterpriseapplication?
    My concern, since database lock is the only way to choose, how aboutthe
    affect
    of ejbLoad to performance, since most transactions are short live,if high
    volume
    transactions are in processing, I am just scared to death about
    the
    ejbLoad overhead.
    ejbLoad is a part of bean's lifecycle, how would you be scared ofit?
    If ejbLoads take too much time, it could be a good idea to profile
    used SQLs. Right index optimization can make huge difference.
    Also you may want cosider using CMP beans to let weblogic
    take care about load optimization.
    (4) If using Optimization lock, all the ejbStore need to do
    version
    check
    or timestamp check, right? How about this overhead?As for optimistic concurrency, it performs quite well as you can
    use lighter isolation levels.
    HTH,
    Slava Imeshev
    "Jinsong Hu" <[email protected]> wrote in message
    news:[email protected]...
    We are using Exclusive Lock for entity bean, because of we do
    not
    want
    to
    load
    data in each new transaction. If we use Database lock, that means
    we
    dedicate
    data access calls to database, if database deadlock happens,
    it's
    hard
    to
    detect,
    while using Exclusive lock, we could detect this dead lock in
    container
    level.
    The problem is, using Exclusive concurrency mode you serialize
    access to data represented by the bean. This aproach has negative
    effect on ablity of application to process concurrent requests.As
    a
    result the app may have performance problems under load.
    Actually, at the beginnning, we did use database lock and usingtransactional
    The fact that you had database deadlocking issues tells that
    application logic / database schema may need some review.
    Normally to avoid deadlocking it's good to group database
    operations mixing in updattes and inserts into one place so
    that db locking sequence is not spreaded in time. Moving to
    forced serialized data access just hides design/implementation
    problems.
    session bean, but the database dead lock and frequent ejbLoad
    really
    kill
    us,
    so we decided to move to use Exclusive lock and to avoid dead
    lock,
    we
    change
    some session bean to non-transactional.Making session beans non-transactions makes container
    creating short-living transactions for each call to entity bean
    methods. It's a costly process and it puts additional load to
    both container and database.
    We could use ReadOnly lock for some entity beans, but since weblogicserver will
    always create local transaction for entity bean, and we found
    transaction
    commit
    is expensive, I am arguing why do we need create container leveltransaction for
    read only bean.First, read-only beans still need to load data. Also, you may seeRO
    beans
    contanly loading data if db-is-shared set to true. Other reason
    can
    be
    that
    RO semantics is not applicable the data presented by RO bean (forinstance,
    you have a reporting engine that constantly produces "RO" data,
    while
    application-consumer of that data retrieves only new data and neverasks
    for "old" data). RO beans are good when there is a relatively stable
    data
    accessed repeatedly for read only access.
    You may want to tell us more about your app, we may be of help.
    Regards,
    Slava Imeshev
    I will post the performance data, let's see how costful
    transaction.commit
    is.
    "Cameron Purdy" <[email protected]> wrote:
    We are currently profiling our product using Borland
    OptmizeIt
    tool,
    and we
    found some interesting issues. Due to our design, we have
    many
    session
    beans which
    are non transactional, and these session beans will access
    entity
    beans
    to
    do
    the reading operations, such as getWeight, getRate, since
    it's
    read
    only,
    there
    is no need to do transaction commit stuff which really takes
    time,
    this
    could
    be seen through the profile. I know weblogic support readonly
    entity
    bean,
    but
    it seems that it only has benefit on ejbLoad call, my test
    program
    shows
    that
    weblogic still creates local transaction even I specified
    it
    as
    transaction not
    supported, and Transaction.commit() will always be called
    in
    postInvoke(),
    from
    the profile, we got that for a single method call, such as
    getRate(),
    80%
    time
    spent on postInvoke(), any suggestion on this? BTW, most of
    our
    entity
    beans are
    using Exclusive lock, that's the reason that we use
    non-transactional
    session
    bean to avoid dead lock problem.I am worried that you have made some decisions based on an improper
    understand of what WebLogic is doing.
    First, you say "non transactional", but from your description
    you
    should
    have those marked as tx REQUIRED to avoid multiple transactions
    (since
    non-transactional just means that the database operation becomesits
    own
    little transaction).
    Second, you say you are using exclusive lock, which you shouldonly
    use
    if
    you are absolutely sure that you need it, (and note that it
    does
    not
    work in
    a cluster).
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    http://www.tangosol.com/coherence.jsp
    Tangosol Coherence: Clustered Replicated Cache for Weblogic
    "Jinsong Hu" <[email protected]> wrote in message
    news:[email protected]...
    >

  • MySQL Locks

    Hi,
    This is quite complicated, and probably I'm making a big mess in many concepts... but can someone help me with this??
    All right... I'm using MySQL DB, and it's default table types do not support transactions, so I'm supposed to use table locks instead. There are also InnoDB table types in MySQL which support transactions, but since the server I'm putting all in is still unknown, I don't want to assume it will support InnoDB tables.
    Then, when using JDBC API to access this DB, it seems by the documentation that all results are in the ResultSet type. But this representation is in fact a pointer to the DB row, and it pulls up the data just when requested.
    For example, if I execute a select statement that returns me 10 rows, one will be read directly from the DB everytime i call the method next.
    Is everything correct until now?
    OK... the problem is... if I lock the table in order to protect this reading from other threads writings and the rows take some time to process individually, will the table be locked all that long? Or the JDBC implementation does all that for me and I don't even have to use locks? Or this is just an illusion and all the results are read and there is no further concurrency problem - after I release the lock, of course?
    I know select, update and other operations are atomic in mysql default tables, but this will be used all over...
    One last thing, I'm using MySQL Connector/J 3.0 JDBC driver.
    I hope I could describe my doubt...
    Thanks

    There are also InnoDB table types in MySQL which support
    transactions, but since the server I'm putting all in
    is still unknown, I don't want to assume it will
    support InnoDB tables.If you really need transactions, I think you can safely assume that it is available, since MySQL-Max versions since around 3.23.40+ have supported InnoDB.
    Still, if you want to use MyISAM, you could, but individual table locking won't really give you transactional semantics. It may prevent premature dirty reads, but that's all, and it's an extremely expensive way of doing this.
    But you may not need to do this, since the MyISAM table manager automatically locks the table when processing a query (so that no inserts or updates can take place while the query is being processed). So you won't get inconsistent results in terms of reading the result of half of an update, for instance.
    However, you will never really get transactional semantics unless you lock the entire DB, but that's REALLY nasty.
    But this representation is in fact a pointer to the DB
    row, and it pulls up the data just when requested.False. MySQL doesn't have anything like DB cursors, so the entire
    query result is read into memory as soon as you executeQuery(),
    and the next() simply returns you values from memory.
    So yes, if you start a query without a restrictive WHERE clause and without a LIMIT clause on a giant table, you'll run out of memory before you can even get the first row.
    OK... the problem is... if I lock the table in order
    to protect this reading from other threads writings
    and the rows take some time to process individually,
    will the table be locked all that long? No - see the above. If you're not using explicit locking, the tables being queried will be temporarily locked until the results are generated into the server's memory, and then the locks are released. Then the results are transferred completely to the client's JDBC driver memory, and it then feeds the results on each next() call.
    On the other hand, if you lock the DB, you won't get a chance to unlock the DB until all the above steps are completed (i.e. until the last byte of the result set has been sent back to the JDBC driver and processed by it into the ResultSet).
    This would make your application nearly unusable.
    Or the JDBC implementation does all that for me and I don't
    even have to use locks? Well, JDBC won't do this for you. If all you want is a clean query without partial individual-update side-effects, you can get that for free without doing any locking, courtesy of MySQL's MyISAM table manager.
    However, if you need transactional semantics (i.e. you want to consider a series of updates or inserts as one transaction, and don't want any other query to see partial results after a subset of those updates), then:
    (a) you'll have to do explicit locking, with all the hazards described above,
    OR
    (b) you'll have to break down and use InnoDB, and ask your users to install MySQL-Max 3.23.latest or 4.0.latest.

  • Error when locking period

    Hello Experts,
    I am trying to lock a period and I am receiving an error when I try. Error states "Cannot lock data because the validation account is not zero." I haven't had any issues with any other period except August. I noticed that there is country that would not lock. All the entities within that one country locked; however, at the parent and consolidated level, it would not. Please help if you can.
    Thanks!

    Hi,
    Please refer the below article that might help you ,
    "Cannot lock data because the validation account is not zero" when trying to lock a parent entity (Doc ID 1314837.1)
    Cause
    The cause was that there were calculated values in the <Parent Currency> Value member in the child entity. This is caused by rules, and previous periods may not have these calculated values. It is not possible to lock <Parent Currency> value member of the child entity if it is not zero in the validation account.
    When the <Entity Currency> value member of a parent entity is locked, the system also needs to lock the <Parent Currency> of the child entity in the same action. If the value of the validation account at <Parent Currency> level in the child entity is not zero, the user will not be allowed to lock the <Entity Currency> of the parent. If calculation or translation rules are writing values to this <Parent Currency> value member, they will need to be checked to ensure that this value remains zero.
    Solution:
    1) The calculation or translation rules will need to be adjusted so that numerical non-zero values are not generated in the <Parent Currency> value member of the child entity.
    2) Then the entity will be lockable at "translation" (Parent currency) value member level,
    3) If it can be locked at this level, then the parent entity will be able to be locked at <Entity Currency> level.
    4) After amending the rules, load the changed rules, and run some translations and consolidations and test the locking process again.
    Regards,
    Gunasekaran Rayar

  • Problem with entity- set_property. Does not set the value on Save

    There is a custom field enhanced in BP_HEAD component in node header structure.
    Code to set the property is written in do_prepare_output method. This value gets set with X after BACK from contact details.
    I see the value X before Save of the account details. After Save, the set_property does not work and so the value is not displayed.
    Please help to explain what could be the reason and how to rectify it.
    Note: Before Save, If I select Edit I see the value on the field. If I select Save after the Edit. The value is retained.
    This issue occurs only when new account details is Saved.

    Hi ,
    The set_property( ) does not work if the field is non-editable. You have to make sure that you do this operation only for fields which are editable.
    Also if you done a set_property(   ), make you perform a modify also and there should be a save followed by a commit ( framework does it for you or you do it manually).
    * 1. Lock an entity and modify a property
    * here booking entity with technical name u2018UIFBokkingu2019
    2 Basic Features of the BOL Application Programming Interface
    <January 2009> 19
    lv_booking = lv_flight->get_related_entity(
    u2018FlightBookingRelu2019 ).
    IF lv_booking->lock( ) = ABAP_TRUE.
    lv_booking->set_property( iv_attr_name = u2018SMOKERu2019
    iv_value = u2018Xu2019 ).
    ENDIF.
    * 2. send all changes to BO layer
    lv_bol_core->modify( ).
    * 3. get the implicitly created global transaction
    DATA: lv_transaction TYPE REF TO if_bol_transaction_context.
    lv_transaction = lv_bol_core->get_transaction( ).
    * 4. save and commit your changes
    lv_transaction->save( ).
    lv_transaction->commit( ).
    Regards
    Kavindra

  • AQ subscription (dead)locks

    Hi,
    I posted a question in the OCCI forum (Subscribing/unsubscribing call is blocking (lock?) but now I'm starting to suspect that this is a general AQ problem.
    We have a AQ queue with multiple subscribers, where the subscribing clients are implemented in OCI/OCCI. At the startup of the client program, we subscribe to the queue trough a stored procedure, and creates a callback in the OCCI implementation of the client.
    The problem is that sometimes the subscription query / callback creation seems to block. Could this be because a lock has been put on the subscriber/queue? There is no explicit locking in our code, as far as I know.
    The stored procedure for subscribing basically does this:
    DBMS_AQADM.ADD_SUBSCRIBER(queue_name => v_queue_name,
    subscriber => subscriber,
         rule => p_rule);
    I'm an experienced programmer, but not too familiar with Oracle/AQ, so it would be great if someone could point me in the right direction of debugging this. I have access to Toad.
    EDIT: We are running three threads simultanously, all calling add_subscriber. Could this be a problem, creating some sort of deadlock?
    Thanks,
    Sverre

    Hi,
    do the clients have the same subcription name?
    In the documentation see this link:
    http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10785/jm_create.htm#i1005628
    EDIT (Sorry i assumed that you use JMS ;-(
    Can you tell me, what is the statement which shows up in the dbconsole in the top activity when the (dead)lock appears? (I hope you use 10g)
    Message was edited by:
    HEWizard

Maybe you are looking for