TopLink Unit of Work Primer classes

Hello,
I found the contents of White Paper : "Oracle Application Server TopLink Unit of Work Primer" very interessant.
It is possible to provide me the java definition of the three classes used: Fart, PetOwner and VetVisit?
Regards,
TT

Sorry about that. I posted that too soon. It should become available today (Monday Aug 22nd).
Doug

Similar Messages

  • Cloning and Unit Of Work

    Hello,
    I have asked this question years ago and unfortunately I dont remember the answer.
    When I do the following code
    Employee employee = new Employee();
    Employee empClone = (Employee)uow.registerObject(employee);
    Does TopLink Unit Of Work framework clone the dependent objects of Employee as well or only the primary object i.e. Employee and its direct fields only ? Say Employee had a Vector of PhoneNumbers. Do the phone number objects get cloned as well ?
    Thanks and apologies if its a FAQ. If somebody could point me to the relevant URL that would be more than sufficient.
    Thanks,
    Aswin.

    The UnitOfWork will clone all reachable objects to form a complete isolated graph of objects for the scope of the transaction. This is minimized with indirection. When a relationship is reached that uses indirection (lazy loading) then the associated object(s) are not cloned until requested.
    Doug

  • Unit Of work upgrade issue 9.0.3- 10.1.4

    Hi,
    I recently upgraded from Toplink 9.0.3 to Toplink 10.1.3. I changed nothing in my code except the deployment java descriptor to use the new classes implemented instead of the deprecated classes. I also used the new TypeConversions for my CLOBs and BLOBs. Everything worked fine in my unit tests but then once I'd deployed the application into production my users kept on getting an irregular error. I can't reproduce the error myself as its so irregular. I have tracked it down to when my users enter a clob/blob of data into the database. The strange thing is that I close the unit of work and even test if its still active and I get false as an answer but somehow when I execute on the session it uses the UnitOfWork which has expired for some reason. I have checked my code and can't find anything that is changed.
    All my code basically always checks whether a UOW is active and if it is not it uses the session to execute the query. Here is a java code extract:
    if ( isTxActive() ) {
    objectResults = uow.readAllObjects(Class.forName(objectType), expression);
    objectResults = uow.registerAllObjects(objectResults);
    } else
    objectResults = session.readAllObjects(Class.forName(objectType), expression);
    I use the following setup:
    - Oracle 9i database
    - JDK 1.5
    - Oracle JDBC Thin Driver version - 10.1.0.2.0
    I have tried the following:
    - Specified my OraclePlatform i.e. Oracle9Platform
    - Tried playing around with the SQL String binding
    - Double checked my type conversions
    Below is my logfile output and also my login parameters and extract of one of my descriptors.
    Any help would be appreciated.
    I was wondering if there is a timeout on the UnitOfWork or if its multi-threaded hence my application doesn't wait for my CLOB to finish being written?
    Thanks in advance,
    Paula
    2006-05-24 11:32:05,870 (toplink) DEBUG - execute_query
    2006-05-24 11:32:05,871 (toplink) DEBUG - execute_query
    2006-05-24 11:32:05,871 (toplink) DEBUG - DatabaseAccessor(connected)--INSERT INTO chebi.AUTOGEN_STRUCTURES (ID, STRUCTURE_ID) VALUES (12599, 19211)
    2006-05-24 11:32:05,874 (toplink) DEBUG - execute_query
    2006-05-24 11:32:05,875 (toplink) DEBUG - execute_query
    2006-05-24 11:32:05,875 (toplink) DEBUG - DatabaseAccessor(connected)--INSERT INTO chebi.DEFAULT_STRUCTURES (ID, STRUCTURE_ID) VALUES (6968, 19213)
    2006-05-24 11:32:05,885 (toplink) DEBUG - execute_query
    2006-05-24 11:32:05,886 (toplink) DEBUG - execute_query
    2006-05-24 11:32:05,886 (toplink) DEBUG - DatabaseAccessor(connected)--INSERT INTO chebi.IMAGE_PRECOMPUTES (ID, FORMAT, IMAGE, STRUCTURE_ID) VALUES (7208, 'p
    ng', empty_blob(), 19213)
    2006-05-24 11:32:05,898 (toplink) DEBUG - DatabaseAccessor(connected)--SELECT IMAGE FROM chebi.IMAGE_PRECOMPUTES WHERE (ID = 7208) FOR UPDATE
    2006-05-24 11:32:05,905 (toplink) DEBUG - write_BLOB
    2006-05-24 11:32:05,905 (toplink) DEBUG - DatabaseAccessor(connected)--commit_transaction
    2006-05-24 11:32:05,915 (toplink) DEBUG - end_unit_of_work_commit
    2006-05-24 11:32:05,915 (toplink) DEBUG - release_unit_of_work
    2006-05-24 11:32:05,915 (controller.DatabaseAction) DEBUG - ModifyStructureAction_postprocess: empty method
    2006-05-24 11:32:05,915 (controller.DatabaseAction) DEBUG - ModifyStructureAction_findSuccess: start method
    2006-05-24 11:32:05,915 (controller.DatabaseAction) DEBUG - ModifyStructureAction_findSuccess: preparing forward ( set form | release lock | reset token )
    2006-05-24 11:32:05,915 (controller.DatabaseAction) DEBUG - ModifyStructureAction_findSuccess: forward to searchId
    2006-05-24 11:32:05,917 (toplink.ToplinkDAO) DEBUG - find(String objectType, String col, String val): start method
    2006-05-24 11:32:05,917 (toplink.ToplinkDAO) DEBUG - isTxActive: start method
    2006-05-24 11:32:05,917 (toplink.ToplinkDAO) DEBUG - isTxActive: false
    2006-05-24 11:32:05,917 (toplink) DEBUG - execute_query
    2006-05-24 11:32:05,917 (toplink) DEBUG - DatabaseAccessor(connected)--SELECT ID, SOURCE, ASCII_NAME, STATUS, CREATED_ON, DEFINITION, MODIFIED_BY, NAME, MODI
    FIED_ON, CREATED_BY, CHEBI_ACCESSION, MERGE_TYPE, PARENT_ID FROM chebi.COMPOUNDS WHERE (ID LIKE 6126)
    2006-05-24 11:32:05,980 (toplink) DEBUG - execute_query
    2006-05-24 11:32:06,046 (handlers.DefaultExceptionHandler) ERROR - Exception [TOPLINK-6027] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): ora
    cle.toplink.exceptions.QueryException
    Exception Description: Query sent to a unactivated UnitOfWork.
    Query: ReadAllQuery(uk.ac.ebi.chebi.compounds.model.CompoundName)
    uk.ac.ebi.chebi.compounds.application.curator2.exceptions.BeanUtilException: Exception [TOPLINK-6027] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060
    118)): oracle.toplink.exceptions.QueryException
    Exception Description: Query sent to a unactivated UnitOfWork.
    Query: ReadAllQuery(uk.ac.ebi.chebi.compounds.model.CompoundName)
    LOGIN:
    public void applyLogin () {
    DatabaseLogin login = new DatabaseLogin();
    login.usePlatform( ToplinkDeploymentHelper.getPlatform(options) );
    login.setDriverClassName(options.getDriver());
    login.setConnectionString(options.getDbUrl());
    login.setUserName(options.getDbUserName());
    login.setPassword(options.getDbPassword());
    // Configuration properties.
    // login.setUsesNativeSequencing(true);
    // login.setSequencePreallocationSize(100);
    // Replace with
    login.setDefaultSequence(new NativeSequence("", 1));
    login.setShouldBindAllParameters(false);
    login.setShouldCacheAllStatements(false);
    // String binding is used when the SQL string might be too large to
    // incorporate in the Oracle Thin driver. It will give an exception of string literal
    // too long. Hence string binding should be turned on for long strings such
    // as long names
    login.setUsesStringBinding(true);
    login.useStringBinding( );
    // This specifies for large bytes to use binding to prevent the same problem
    // above and improve performance
    login.setUsesByteArrayBinding(true);
    if ( login.shouldUseByteArrayBinding() ) { // Can only be used with binding.
    login.setUsesStreamsForBinding(false);
    login.setShouldForceFieldNamesToUpperCase(false);
    login.setShouldOptimizeDataConversion(true);
    login.setShouldTrimStrings(true);
    login.setUsesBatchWriting(false);
    if ( login.shouldUseBatchWriting() ) { // Can only be used with batch writing.
    login.setUsesJDBCBatchWriting(true);
    login.setUsesExternalConnectionPooling(false);
    login.setUsesExternalTransactionController(false);
    setLogin(login);
    ImagePrecompute descriptor:
    public ClassDescriptor buildImagePrecomputeDescriptor () {
    ClassDescriptor descriptor = new ClassDescriptor();
    descriptor.setJavaClass(uk.ac.ebi.chebi.compounds.model.ImagePrecompute.class);
    descriptor.addTableName( options.getDbSchemaName().concat(".").concat("IMAGE_PRECOMPUTES") );
    descriptor.addPrimaryKeyFieldName("IMAGE_PRECOMPUTES.ID");
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(50);
    descriptor.useRemoteNoIdentityMap();
    //descriptor.useRemoteSoftCacheWeakIdentityMap();
    //descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("IMAGE_PRECOMPUTES.ID");
    descriptor.setSequenceNumberName("image_precompute_sequence");
    descriptor.setAlias("ImagePrecomputes");
    descriptor.getQueryManager().checkCacheForDoesExist();
    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("IMAGE_PRECOMPUTES.ID");
    descriptor.addMapping(idMapping);
    OneToOneMapping structureMapping = new OneToOneMapping();
    structureMapping.setAttributeName("structure");
    structureMapping.setReferenceClass(uk.ac.ebi.chebi.compounds.model.Structure.class);
    structureMapping.dontUseIndirection();
    structureMapping.addForeignKeyFieldName("IMAGE_PRECOMPUTES.STRUCTURE_ID", "STRUCTURES.ID");
    descriptor.addMapping(structureMapping);
    DirectToFieldMapping imageMapping = new DirectToFieldMapping();
    imageMapping.setAttributeName("image");
    imageMapping.setFieldName("IMAGE_PRECOMPUTES.IMAGE");
    TypeConversionConverter imageMappingConverter = new TypeConversionConverter(imageMapping);
    imageMappingConverter.setObjectClass(byte[].class);
    imageMappingConverter.setDataClass(java.sql.Blob.class);
    imageMapping.setConverter(imageMappingConverter);
    descriptor.addMapping(imageMapping);
    DirectToFieldMapping formatMapping = new DirectToFieldMapping();
    formatMapping.setAttributeName("format");
    formatMapping.setFieldName("IMAGE_PRECOMPUTES.FORMAT");
    descriptor.addMapping(formatMapping);
    return descriptor;
    Message was edited by:
    pmatos

    Hi,
    Thanks for replying.
    I use log4j to log my toplink info so that I can write it to a file so that is why I have no session info. If you think it is will be useful then I will try to include it in my tool so that it can be reproduced.
    In the mean time here is the stacktrace:
    Exception Description: Query sent to a unactivated UnitOfWork.
    Query: ReadAllQuery(uk.ac.ebi.chebi.compounds.model.CompoundName)
    uk.ac.ebi.chebi.compounds.application.curator2.exceptions.BeanUtilException: Exception [TOPLINK-6027] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.QueryException
    Exception Description: Query sent to a unactivated UnitOfWork.
    Query: ReadAllQuery(uk.ac.ebi.chebi.compounds.model.CompoundName)
         at uk.ac.ebi.chebi.compounds.application.curator2.controller.helper.BeanAssembler.populateCompoundBean(Unknown Source)
         at uk.ac.ebi.chebi.compounds.application.curator2.controller.search.SearchIdAction.loadCompound(Unknown Source)
         at uk.ac.ebi.chebi.compounds.application.curator2.controller.search.SearchIdAction.executeLogic(Unknown Source)
         at uk.ac.ebi.chebi.compounds.application.curator2.controller.BaseAction.execute(Unknown Source)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
         at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
         at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:316)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: Exception [TOPLINK-6027] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.QueryException
    Exception Description: Query sent to a unactivated UnitOfWork.
    Query: ReadAllQuery(uk.ac.ebi.chebi.compounds.model.CompoundName)
         at oracle.toplink.exceptions.QueryException.querySentToInactiveUnitOfWork(QueryException.java:816)
         at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2530)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:981)
         at oracle.toplink.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:62)
         at oracle.toplink.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:55)
         at oracle.toplink.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:61)
         at oracle.toplink.indirection.IndirectList.buildDelegate(IndirectList.java:184)
         at oracle.toplink.indirection.IndirectList.getDelegate(IndirectList.java:307)
         at oracle.toplink.indirection.IndirectList.size(IndirectList.java:632)
         at java.util.ArrayList.<init>(ArrayList.java:133)
         at uk.ac.ebi.chebi.compounds.model.Compound.getAllCompoundNameList(Unknown Source)
         at uk.ac.ebi.chebi.compounds.application.curator2.controller.helper.BeanAssembler.populateAllNames(Unknown Source)
         ... 51 more

  • Getting Unit Of Work without JSP context

    We are developing an application using Toplink and ADF Datacontrols. We have timer (which starts right after deploy) which reads data from magnetic card reader and stores them into database (via Toplink). Our main problem is getting Unit Of Work (server session). If user interacts with application via jsp pages, obtaining uow is done from TopLinkDataControl (getAssociatedUnitOfWork()). But timer lives on its own, it has no jsp pages to get context from.
    We know one solution - getting server session from toplink descriptor (absolute path needed) - XMLProjectReader.read("c:\\...\\toplink-deployment-descriptor.xml"). Is there another way to create Unit Of Work for our timer in order to last whole application existence? Thanks.

    I was wrong, when I thought, that XMLProjectReader.read() with absolute path works. Your solution seems to be similar, with the same result. I'll describe my problem more closely:
    - Our web apllication consists of 2 projects - Model and ViewController. Each has set the classpath pointing to classes of the opposite project.
    - The only way, that I know of starting a Clock (from Model, Runnable) without creating JSP page is instatiating it in some servlet's init() method. (Servlet has set 'Load This Servlet When the Web App is Strted" in WEB.XML).
    - When I try in my clock to create UnitOfWork by XMLProjectReader.read("c:\\...\\toplink-deployment-descriptor.xml"), I get this error:
    EXCEPTION [TOPLINK-3007] (OracleAS TopLink - 10g (9.0.4.5) (Build 040930)): oracle.toplink.exceptions.ConversionException
    EXCEPTION DESCRIPTION: The Object [mypackage.MyClass], of class[class java.lang.String] could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate
    API passing in the appropriate class loader as required, or setting it
    on the default ConversionManager/
    INTERNAL EXCEPTION: java.lang.ClassNotFoundException: mypackage.MyClass
    - mypackage.MyClass is one of many classes from Model, mapped in toplink-deployment-descriptor.xml. It is in classpath of ViewController.
    - For the time being, our application runs in JDeveloper, it will be deployed to OracleAS 10g.
    Either somebody please help me how to solve above error or maybe suggest how to start my clock together with application deployment (no jsp context).
    Thanks.

  • Unit of Work and cache times

    Hello!
    I've got a question concerning read queries on a Unit of Work.
    In my specific case I'm executing a ReadAllQuery on the Unit of Work getting about 7000 objects. The Performance Profiler is recording a cache time of about 900 milliseconds. If I execute this query on the Session the Profiler records a cache time of about 300 milliseconds.
    Now I'd like to know what is happening within the Unit of Work? Why does it takes longer to maintain the objects in the cache? I know that the Unit of Work spends more time overall because of the registering of the objects.
    Thanks

    The UnitOfWork is a transaction abstraction beyond the shared cache. When you read through a UnitOfWork you still perform the same operations on the shared cache and then pull the working copies into the UnitOfWork's transactional cache. This means that your 300 ms case is really just a sub-set of what is happening in your 900 ms case.
    The recommended approach is to read in the objects that you plan to use read-only through the session and then register those you may modify with a UnitOfWork. This allows you to control and optimize the transactional nature of TopLink. Reading everything through a UnitOfWork may be less complex but that complexity comes with a performance cost.
    You may want to read through our UnitOfWork primer. It explains this much better then I can here.
    http://www.oracle.com/technology/products/ias/toplink/technical/unitOfWorkWP.pdf
    Doug

  • Acquire unit of work, default?

    Hi,
    I'm writing a finder using findManyByQuery with a readAllQuery for CMP 2.0 with weblogic 7.0.
    Watching the server output, I noticed that a new unit of work is acquired and released each time, how can I disable that and doing as if I would have called the executeQuery from the session?
    [TopLink]: ServerSession(1236551)--Connection(0)--client acquired
    [TopLink]: ClientSession(7337388)--Connection(0)--acquire unit of work:7163719
    [TopLink]: UnitOfWork(7163719)--Connection(0)--JTS#register()
    [TopLink]: ServerSession(1236551)--Connection(3785130)--SELECT NOM, IDVOITURE FROM VOITURE WHERE (ID
    VOITURE = 15389)
    [TopLink]: UnitOfWork(7163719)--Connection(0)--JTS#beforeCompletion()
    [TopLink]: UnitOfWork(7163719)--Connection(0)--JTS#afterCompletion()
    [TopLink]: UnitOfWork(7163719)--Connection(0)--release unit of work
    [TopLink]: ClientSession(7337388)--Connection(0)--client released
    Vlad

    It looks like there is somthing to do with JTS, but I'm a bit lost, where have I to write the code furnished in the example of the documentation, in the ejbCreate, in the project class?
    Thanks for help.

  • Conform in unit of work broken when not enabling Read Subclasses On Query

    Any business application must use conform in unit of work to have expected ACID properties or modifications done during a unit of work are not visible when executing queries.
    So our application is always using conform in unit of work. We are using TopLink 10.1.3.3.
    We have couple of mapped inheritances. One of them is setup so that when you query on the base class the subclasses are never returned. This is done in TopLink Workbench in inheritance tab by not checking checkbox "Read Subclasses On Query".
    The SQL generated is right. But the code handling conform in unit of work doesn't respect the flag.
    The code in UnitOfWork.java line 4185 is calling:
    getIdentityMapAccessor().getAllFromIdentityMap(expression, class1, databaserow, inmemoryqueryindirectionpolicy);
    This end-up to call IdentityMapManager.java line 648:
    public IdentityMap getIdentityMap(Descriptor descriptor)
    /* 648*/ if(descriptor.hasInheritance())
    /* 649*/ descriptor = descriptor.getInheritancePolicy().getRootParentDescriptor();
    No places in the code are trying to respect deactivation of "Read Subclasses On Query".
    So the query return also subclasses that were in the unit of work!
    Anybody else is using conform in unit of work?

    This is a bug, the subclasses should be getting filtered when conforming.
    Please contact Oracle technical support with this issue.
    As a workaround you could filter the subclass in your application after executing the query (or possibly use a query redirector), or disable conforming.
    <p>---
    <br>James Sutherland
    <br>Oracle TopLink, EclipseLink
    <br>Wiki: Java Persistence, EclipseLink

  • Issues updating with Unit of Work

    Hello,
    I think, I might be missing a point about toplink. I know that when I need to update an Object, i find the current object in cache(ReadObject) and then register that object to get a cloned object and do updates on the cloned object and then commit it.
    Everything works fine in above scenario, IF AND ONLY IF, I set the attributes of the cloned object individually. But the update doesn't work if I set the cloned object to a totally different object (clonedObj = otherObj) Here otherObj has changed attributes which i want to be updated. Toplink somehow doesn't like it.
    How do i do it?
    Sample working code:
    public void mergeData(Object obj, Class c){
    try{
    ReadObjectQuery query = ReadObjectQuery(obj);
    // get the object with the primary key as the one passed in
    Object persistableObject = session.executeQuery(query);
    Object objectClone = tx.register(persistableObject);
    //It is a User object
    ((User)objectClone).setName("New Neeraj");
    tx.commit();
    Sample NOT working code
    public void mergeData(Object obj, Class c){
    try{
    ReadObjectQuery query = ReadObjectQuery(obj);
    // get the object with the primary key as the one passed in
    Object persistableObject = session.executeQuery(query);
    Object objectClone = tx.register(persistableObject);
    objectClone = obj //passed in object
    tx.commit();
    Is it becuase of the ReadObjectQuery using the same object as used to set up the cloned object?
    Thanks in advance for the help.
    Regards,
    Neeraj

    Don,
    This is what the documentation says related to mergeClone:
    "Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged."
    What is the significance RMI and serialization in this.
    I tries mergeClone locally (using the UOW) and it works fine, but just want to make sure that I understand what the documentation says.
    Also, if you will be kind enough to explain the difference between mergeClone and mergeCloneWithReferences.
    Thanks,
    Neeraj

  • Order of delete in unit of work

    Hi,
    I'm trying to delete two objects, a beamprocess and a beamprocessType, where the beamprocess has a 1-1 relationship with the beamprocessType. This means of course that the beamprocess must be deleted before the beamprocessType. I illustrate this with a method below, but a short explanation is probably required.
    A sequence holds cycles, which holds beamprocesses. These are 1-M private relationships so these objects are all deleted when the sequence is deleted. For some of the beamprocesses I also want to delete the associated beamprocessType. My problem is that when I call commit on the unit of work, TopLink tries to delete the beamprocessType before the associated beamprocess, which is not possible. How can I solve this?
    Kind regards,
    Katarina
    The method:
    public void deleteSequence(String name) throws PMException {
      SequenceController sequenceController = (SequenceController) ServiceLocator.getInstance().getService(SequenceController.class);
      Sequence sequence = sequenceController.getSequence(NameFactory.createSequenceName(name));
      PersistenceTransaction tx = PersistenceLayerFactory.getPersistenceLayer().acquireTransaction();
        // Delete all the "beam-out" beamprocess types and settings.
      Cycle[] cycles = sequence.getCycles();
      for (int i = 0; i < sequence.getCycles().length; i++) {
        BeamProcess[] bps = cycles.getBeamProcesses();
    for (int j = 0; j < bps.length; j++) {
    BeamProcess bp = bps[j];
    if (bp.isBeamOut())
    tx.deleteObject(bp.getType());
    tx.deleteObject(sequence);
    tx.commit();

    Hi again,
    I have now tried to modify my descriptor by adding the contstraint afterwards, but with no success:
          java.util.Map descriptors = project.getDescriptors();
          Descriptor descriptor = (Descriptor) descriptors.get(BeamProcessImpl.class);
          descriptor.addConstraintDependencies(BeamProcessTypeImpl.class);As mentioned in the previous posting, we do not use any mappings that are not specified in the mapping workbench, so TopLink should be able to order them properly. I include below the mapping descriptor for the BeamProcess class, with the hope that this will give you additional information to be able to help me solve this "mystery". I also include the error message.
    Kind regards,
    Katarina
    Descriptor:
              <descriptor>
                   <java-class>cern.macsy.core.domainimpl.BeamProcessImpl</java-class>
                   <tables>
                        <table>CORE_BEAMPROCESS</table>
                   </tables>
                   <primary-key-fields>
                        <field>CORE_BEAMPROCESS.OID</field>
                   </primary-key-fields>
                   <descriptor-type-value>Normal</descriptor-type-value>
                   <sequence-number-field>CORE_BEAMPROCESS.OID</sequence-number-field>
                   <sequence-number-name>BP_SEQ</sequence-number-name>
                   <identity-map-class>oracle.toplink.internal.identitymaps.SoftCacheWeakIdentityMap</identity-map-class>
                   <remote-identity-map-class>oracle.toplink.internal.identitymaps.SoftCacheWeakIdentityMap</remote-identity-map-class>
                   <identity-map-size>100</identity-map-size>
                   <remote-identity-map-size>100</remote-identity-map-size>
                   <should-always-refresh-cache>false</should-always-refresh-cache>
                   <should-always-refresh-cache-on-remote>false</should-always-refresh-cache-on-remote>
                   <should-only-refresh-cache-if-newer-version>false</should-only-refresh-cache-if-newer-version>
                   <should-disable-cache-hits>false</should-disable-cache-hits>
                   <should-disable-cache-hits-on-remote>false</should-disable-cache-hits-on-remote>
                   <alias>BeamProcessImpl</alias>
                   <copy-policy>
                        <descriptor-copy-policy>
                             <type>oracle.toplink.internal.descriptors.CopyPolicy</type>
                        </descriptor-copy-policy>
                   </copy-policy>
                   <instantiation-policy>
                        <descriptor-instantiation-policy>
                             <type>oracle.toplink.internal.descriptors.InstantiationPolicy</type>
                        </descriptor-instantiation-policy>
                   </instantiation-policy>
                   <query-manager>
                        <descriptor-query-manager>
                             <existence-check>Check cache</existence-check>
                        </descriptor-query-manager>
                   </query-manager>
                   <event-manager>
                        <descriptor-event-manager emptyAggregate="true">
                        </descriptor-event-manager>
                   </event-manager>
                   <mappings>
                        <-snipp->
                        <database-mapping>
                             <attribute-name>oid</attribute-name>
                             <read-only>false</read-only>
                             <field-name>CORE_BEAMPROCESS.OID</field-name>
                             <type>oracle.toplink.mappings.DirectToFieldMapping</type>
                        </database-mapping>
                        <-snipp->
                        <database-mapping>
                             <attribute-name>type</attribute-name>
                             <read-only>false</read-only>
                             <reference-class>cern.macsy.core.domainimpl.BeamProcessTypeImpl</reference-class>
                             <is-private-owned>false</is-private-owned>
                             <uses-batch-reading>false</uses-batch-reading>
                             <indirection-policy>
                                  <mapping-indirection-policy>
                                       <type>oracle.toplink.internal.indirection.NoIndirectionPolicy</type>
                                  </mapping-indirection-policy>
                             </indirection-policy>
                             <uses-joining>false</uses-joining>
                             <foreign-key-fields>
                                  <field>CORE_BEAMPROCESS.BEAMPROCESS_TYPE</field>
                             </foreign-key-fields>
                             <source-to-target-key-field-associations>
                                  <association>
                                       <association-key>CORE_BEAMPROCESS.BEAMPROCESS_TYPE</association-key>
                                       <association-value>CORE_BEAMPROCESSTYPE.OID</association-value>
                                  </association>
                             </source-to-target-key-field-associations>
                             <type>oracle.toplink.mappings.OneToOneMapping</type>
                        </database-mapping>
                   </mappings>
                   <type>oracle.toplink.publicinterface.Descriptor</type>
              </descriptor>Error message:
    [EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3 (Build 423)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: ORA-02292: integrity constraint (MACSYDEV.BEAMPROCESS_BPTYPE) violated - child record found
    INTERNAL EXCEPTION: java.sql.SQLException: ORA-02292: integrity constraint (MACSYDEV.BEAMPROCESS_BPTYPE) violated - child record found
    ERROR CODE: 2292]

  • Private Owned, Conform Results in Unit Of Work, ...

    I'd like to have some precision on Private Owned, Conform Results in Unit Of Work, Use joining, Use Batch Reading, ...
    Thank in advance

    Think of Private Owned as "if I delete the source, should I delete the target". So if you have a 1-1 between Customer and Address, if you delete a customer, should you delete their associated address automatically? If so, then it's private owned.
    If you have a 1-M, say a Manager has 1-M to ManagedEmployees, if you remove a ManagedEmployee from a manager, should it be deleted from the database? Probably not, you may simply be assigning them to another Manager... So, it's probably not private owned.
    Don't use the Conform Results in Unit Of Work in the mapping work bench, that sets up a default behavior for queries on that class, and I prefer to set it as needed, not globally. Conforming a query is unit of work related. Imagine you have a UnitOfWork and then query for all Customers from "Ottawa". Imagine you get back 5 from the database. Then in the unit of work you change one of the customers from "Ottawa" to "Kanata". Then you query the unit of work again (before committing) to find all customers in "Ottawa". The default behavior of TopLink would be to return the customer that has moved to "Kanata", because as far as the database is concerned you haven't committed the change, so he's still technically in Ottawa. If you turned on conforming for that class, or for the specific query, then you would NOT get the customer that moved (at a performance cost, of course).
    The docs on Join/Batch reading are pretty good, see 6-6 of the Using TopLink manual in the optimization section. The option in the mapping workbench lets you setup defaults for the relationship, but again, my preference has always been to set it on a per query basis... This gives you a way to centralize the default behavior for batching and joining for certain relationships.
    - Don

  • What is luw (logical unit of work)

    pls tell me what is luw (logical unit of work)
    what r the types of luw .
    2 what ispurpose of code inspector and extended program check
    pls expalin the diffrence b/w those two
    3what are the candidate keys in db tables
    4 what is the difference b/w  occurs 1 and occurs 2 clauses
    data : begin of itab occurs 0 .
    data : itab type standard table of structure type initial size 1 with header line
    pls tell diffrence between theese two statements
    5can u pls tell what is the client in sap
    pls tell answers to questions
    pls dont give any websites addresses to see answers
    6 what is the transaction from database point of view
    7 what is the variant in alv reports
    how do we use reuse_alv_grid_variant_get fun module in alvs

    hi,
      this gives complete idea
      SAP LUW
    Since, as a rule, an application program is processed by several work processes in succession, and every change of the work process is linked with an implicit database commit , an application program is not automatically linked with a single database LUW. This applies in particular to dialog-oriented applications, in which one database LUW is assigned to one dialog step.
    To ensure the data consistency of application programs that are executed across different work processes, the application statements are not directly executed in an SAP LUW, rather, are first registered and then executed by a single work process, that is, in a single database LUW.
    Two techniques are available for bundling the change statements in a database LUW:
    Bundling via function modules (update)
    Through the statement CALL FUNCTION...IN UPDATE TASK, an update function module is registered for subsequent execution in an update work process.
    Bundling via function modules (transactional RFC)
    Through the statement CALL FUNCTION... IN BACKGROUND TASK DESTINATION, a remote- compatible function module is registered for subsequent asynchronous execution via the RFC interface (transactional RFC ).
    Bundling via subprograms
    Through the statement PERFORM ... ON COMMIT, a subprogram is registered for subsequent execution in a different work process.
    Statements for SAP LUWs
    A SAP LUW is controlled via the Open SQL statements COMMIT WORK, ROLLBACK WORK and SET UPDATE TASK LOCAL.
    Note
    A function module can be classified either as an update function module or remote-compatible, but not both at the same time. The update helps realize SAP LUWs within an SAP System, while the transactional RFC creates LUWs in distributed systems.
    COMMIT WORK
    Variants:
    1. COMMIT WORK [AND WAIT].
    2. COMMIT CONNECTION con.
    Effect
    Terminates an SAP LUW and stores the changes.
    Variant 1
    COMMIT WORK [AND WAIT].
    Effect
    The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the currenta SAP LUW in the process. In this case, COMMIT WORK performs the following actions:
    It executes all subroutines registered using PERFORM ON COMMIT.
    It triggers an internal event in Object Services that ensures the registration of changes in persistent objects as the last update function module, as well as the subsequent initialization of persistent object attributes.
    It initiates the processing of all registered update function modules in the update work process.
    This executes all high-priority update function modules registered using CALL FUNCTION ... IN UPDATE TASK in the order of their registration and in a common database LUW. If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating). If you specify the addition AND WAIT, however, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).
    If all high-priority update function modules are completed successfully, the statement executes the low-priority update function modules together in a common database LUW.
    In parallel, it also executes the individual function modules registered using CALL FUNCTION ... IN BACKGROUND TASK DESTINATION in a separate database LUW for each destination.
    It handles all SAP locks set in the current program according to the value of the formal parameter _SCOPE of the corresponding lock function modules.
    It triggers a database commit that also terminates the current database LUW.
    The completion of statement COMMIT WORK triggers the event TRANSACTION_FINISHED of the system class CL_SYSTEM_TRANSACTION_STATE, where the parameter KIND has the value of the constant CL_SYSTEM_TRANSACTION_STATE=>COMMIT_WORK.
    If the statement COMMIT WORK is executed by calling special programs, be aware of the following:
    In a program executed using batch input, or if you have called the program using the USING addition of the statement CALL TRANSACTION, COMMIT WORK terminates the batch input processing when using the corresponding settings.
    In a program called using CALL DIALOG, COMMIT WORK initiates the processing of subroutines or updated function modules registered using PERFORM ... ON COMMIT and CALL FUNCTION ... IN UPDATE TASK. Therefore, it does not complete the current SAP LUW. The SAP LUW cannot be completed until you execute the COMMIT WORK statement in the calling program.
    You cannot execute the COMMIT WORK statement during the updating procedure or during the execution of subroutines registered using PERFORM ... ON {COMMIT|ROLLBACK}.
    System fields
    sy-subrc Meaning
    0 You have specified the AND WAIT addition, and the updating of the update function modules was successful.
    4 You have specified the AND WAIT addition, and the updating of the update function modules was not successful.
    The COMMIT WORK statement always sets sy-subrc to 0 if the AND WAIT addition is not specified.
    Note
    The COMMIT WORK statement closes all database cursors . Open SQL statements that access a database cursor later ( SELECT loop and FETCH) raise an exception that cannot be handled.
    Variant 2
    COMMIT CONNECTION con.
    Note
    This statement is for internal use only.
    It cannot be used in application programs.
    Effect
    The COMMIT command is not executed on the standard database, but only on the secondary database connection specified by con. con is the name of the database connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can also be specified dynamically in the form (source_text) - the source_text field contains the name of the database connection. The source_text field must be of the type C or STRING.
    On the specified secondary database connection, the database commit:
    Closes all open database cursors (OPEN CURSOR)
    Releases all database locks
    Note
    Note that the COMMIT CONNECTION DEFAULT statement unlike COMMIT WORK executes a pure database commit on the DEFAULT connection.
    Exceptions
    Non-Catchable Exceptions
    Cause: COMMIT WORK is not possible in a FORM that was called using PERFORM ... ON COMMIT.
    Runtime Error: COMMIT_IN_PERFORM_ON_COMMIT
    Cause: COMMIT WORK is not allowed in the update.
    Runtime Error: COMMIT_IN_POSTING
    ROLLBACK WORK
    Variants:
    1. ROLLBACK WORK.
    2. ROLLBACK CONNECTION con.
    Effect
    Terminates a SAP-LUW without storing the changes.
    Variant 1
    ROLLBACK WORK.
    Effect
    The statement ROLLBACK WORK closes the current SAP-LUW and opens a new one. In doing so, all change requests of the current SAP-LUW are canceled. To do this, ROLLBACK WORK carries out the following actions:
    Executes all subprograms registered with PERFORM ON ROLLBACK.
    Deletes all subprograms registered with PERFORM ON COMMIT.
    Raises an internal exception in the Object Services that makes sure that the attributes of persistent objects are initialised.
    Deletes all update function modules registered with CALL FUNCTION ...IN UPDATE TASK from the VBLOG and deletes all transactional remote Function Calls registered with CALL FUNCTION ... IN BACKGROUND TASK from ARFCSSTATE and from ARFCSDATA.
    Removal of all SAP locks set in the current program in which the formal parameter _SCOPE of the lock function module was set to the value 2.
    Triggers a database rollback, which also ends the current database-LUW.
    After completion of the statement COMMIT WORK, the event TRANSACTION_FINISHED of the system class CL_SYSTEM_TRANSACTION_STATE is raised, in which the parameter KIND has the value of the constant CL_SYSTEM_TRANSACTION_STATE=>ROLLBACK_WORK.
    Variant 2
    ROLLBACK CONNECTION con.
    Note
    This statement is for internal use only.
    It cannot be used in application programs.
    Effect
    The ROLLBACK-statement is not executed on the standard database but only on the secondary database connection, specified through con. con is the name of the database connection as it was specified in table DBCON in column CON_NAME. The database connection con can also be specified dynamically in the form (source_text), in which the field source_text contains the name of the database connection. The field source_text must be of the type C or STRING.
    Notes
    As all opened database cursors on the respective database connections are closed at ROLLBACK, the attempt to continue a SELECT-loop after a ROLLBACK, leads to a runtime error. Due to the same reason, a FETCH after a ROLLBACK to the then closed cursor, leads to a runtime error. You have to make sure that cursors that are still open, are no longer used after ROLLBACK.
    After execution of the statement ROLLBACK, SY-SUBRC is always equal to 0. It is not necessary to check if SY-SUBRC is unequal to 0 after ROLLBACK.
    ROLLBACK must not be used during update (CALL FUNCTION ... IN UPDATE TASK) or during the execution of FORMs, which were registered with PERFORM ... ON COMMIT resp. PERFORM ...ON ROLLBACK.
    The statement ROLLBACK WORK is implicitly executed if a message of the type A is treated with the addition ERROR_MESSAGE when calling a function module with CALL FUNCTION.
    Exceptions
    Non-Catchable Exceptions
    Cause: ROLLBACK WORK is not allowed within a FORM that is called with PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK.
    Runtime Error: ROLLBACK_IN_PERFORM_ON_COMMIT
    Cause: ROLLBACK WORK is not allowed within an update.
    Runtime Error: ROLLBACK_IN_POSTING
    SET UPDATE TASK LOCAL
    Syntax
    SET UPDATE TASK LOCAL.
    Effect
    This statement specifies that the high-priority update function modules - registered during the current SAP LUW using CALL FUNCTION ... IN UPDATE TASK - are registered in the ABAP memory instead of the VBLOG database table. In addition, it specifies that the current work process and not the update work process run these modules during the current database LUW, when the COMMIT WORK statement is executed. This statement has no effect on low-priority update function modules.
    At the beginning of every SAP LUW, the local update function is deactivated. If you wish to use it, you must reactivate it again before the first update function module is registered.
    System fields
    sy-subrc Meaning
    0 The local update function is activated.
    1 The local update function has not been activated, because the program has already registered at least one update function module for the normal updating procedure in the current SAP-LUW.
    Notes
    The local update function performs a synchronous update according to the COMMIT WORK statement, independent of the addition AND WAIT.
    The occurrence of a database rollback during the local update affects all previous change requests.

  • Consume JMS Unit-Of-Work message through OSB proxy service

    Hi,
    Anyone know how to consume a JMS Unit-Of-Work (UOW) message using an OSB Proxy Service of JMS type?
    I can submit a unit-of-work JMS message (which consists of multiple constituent messages) using an OSB proxy & business service combination and setting the UOW transport headers appropriately. I can also separately produce and consume Java objects via a JMS queue where the consumption is done via OSB proxy (of java request message type), but these aren't UOW messages.
    Apparently as soon as it is a UOW message then the message consumed is an ObjectMessage ArrayList and one has to use the "Java" request message type for the JMS consumer proxy, but I'm unsure of how to create the concurrent client jar to use it in the same proxy service's JMS transport configuration in order to output the ObjectMessage ArrayList (UOW message). 
    Ideally I'd like to consume a single UOW XML message via an OSB JMS proxy service.
    Any pointers would be appreciated.
    R

    Finally got this working!!
    For posterity: Needed to insert Java Object JMS messages on the OSB JMS producer (Business Service) side with correct UOW jms transport header set in route node. Then consume the Unit-Of-Work message on the other side via jms proxy service with "java" request message type, with appropriate jar containing the Object class as the "Client jar" in the JMS Transport configuration. In the same JMS consumer proxy I had to do a java callout, passing the contents of $body, using java.util.ArrayList and javax.jms.ObjectMessage, as input into a method (.. decodeJavaMessage(ArrayList<ObjectMessage> ...)). In this java callout class you can get to each individual ObjectMessage via typecasting the get() method on the Arraylist to (ObjectMessage) and then just typecast the getObject() on this Objectmessage into your original Java Class (same as what you inserted onto queue originally).
    Hope this saves someone some time in future!

  • Unit of work exception

    I am doing an update all query and some inserts through the same unit of work. When trying to commit, toplink throws exception with the error message
    "Update all query not be issued within a unit of work containing other write operations".
    What is the workaround? I don't want to read all the objects I am bulk updating through update all query. Will a nested unit of work help?
    Pranab

    I believe this issue has been fixed, what version are you using?
    Perhaps try the latest release (EclipseLink 1.0 / TopLink 11g).
    Otherwise you could execute the query in a separate UnitOfWork.
    James : http://www.eclipselink.org

  • RE:logical unit of work

    Hi guys,
    What do u mean by logical unit of work...Can anyone explain me with an example.
    Regards,
    Alex.

    hi,
    this gives complete idea
    SAP LUW
    Since, as a rule, an application program is processed by several work processes in succession, and every change of the work process is linked with an implicit database commit , an application program is not automatically linked with a single database LUW. This applies in particular to dialog-oriented applications, in which one database LUW is assigned to one dialog step.
    To ensure the data consistency of application programs that are executed across different work processes, the application statements are not directly executed in an SAP LUW, rather, are first registered and then executed by a single work process, that is, in a single database LUW.
    Two techniques are available for bundling the change statements in a database LUW:
    Bundling via function modules (update)
    Through the statement CALL FUNCTION...IN UPDATE TASK, an update function module is registered for subsequent execution in an update work process.
    Bundling via function modules (transactional RFC)
    Through the statement CALL FUNCTION... IN BACKGROUND TASK DESTINATION, a remote- compatible function module is registered for subsequent asynchronous execution via the RFC interface (transactional RFC ).
    Bundling via subprograms
    Through the statement PERFORM ... ON COMMIT, a subprogram is registered for subsequent execution in a different work process.
    Statements for SAP LUWs
    A SAP LUW is controlled via the Open SQL statements COMMIT WORK, ROLLBACK WORK and SET UPDATE TASK LOCAL.
    Note
    A function module can be classified either as an update function module or remote-compatible, but not both at the same time. The update helps realize SAP LUWs within an SAP System, while the transactional RFC creates LUWs in distributed systems.
    COMMIT WORK
    Variants:
    1. COMMIT WORK [AND WAIT].
    2. COMMIT CONNECTION con.
    Effect
    Terminates an SAP LUW and stores the changes.
    Variant 1
    COMMIT WORK [AND WAIT].
    Effect
    The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the currenta SAP LUW in the process. In this case, COMMIT WORK performs the following actions:
    It executes all subroutines registered using PERFORM ON COMMIT.
    It triggers an internal event in Object Services that ensures the registration of changes in persistent objects as the last update function module, as well as the subsequent initialization of persistent object attributes.
    It initiates the processing of all registered update function modules in the update work process.
    This executes all high-priority update function modules registered using CALL FUNCTION ... IN UPDATE TASK in the order of their registration and in a common database LUW. If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating). If you specify the addition AND WAIT, however, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).
    If all high-priority update function modules are completed successfully, the statement executes the low-priority update function modules together in a common database LUW.
    In parallel, it also executes the individual function modules registered using CALL FUNCTION ... IN BACKGROUND TASK DESTINATION in a separate database LUW for each destination.
    It handles all SAP locks set in the current program according to the value of the formal parameter _SCOPE of the corresponding lock function modules.
    It triggers a database commit that also terminates the current database LUW.
    The completion of statement COMMIT WORK triggers the event TRANSACTION_FINISHED of the system class CL_SYSTEM_TRANSACTION_STATE, where the parameter KIND has the value of the constant CL_SYSTEM_TRANSACTION_STATE=>COMMIT_WORK.
    If the statement COMMIT WORK is executed by calling special programs, be aware of the following:
    In a program executed using batch input, or if you have called the program using the USING addition of the statement CALL TRANSACTION, COMMIT WORK terminates the batch input processing when using the corresponding settings.
    In a program called using CALL DIALOG, COMMIT WORK initiates the processing of subroutines or updated function modules registered using PERFORM ... ON COMMIT and CALL FUNCTION ... IN UPDATE TASK. Therefore, it does not complete the current SAP LUW. The SAP LUW cannot be completed until you execute the COMMIT WORK statement in the calling program.
    You cannot execute the COMMIT WORK statement during the updating procedure or during the execution of subroutines registered using PERFORM ... ON {COMMIT|ROLLBACK}.
    System fields
    sy-subrc Meaning
    0 You have specified the AND WAIT addition, and the updating of the update function modules was successful.
    4 You have specified the AND WAIT addition, and the updating of the update function modules was not successful.
    The COMMIT WORK statement always sets sy-subrc to 0 if the AND WAIT addition is not specified.
    Note
    The COMMIT WORK statement closes all database cursors . Open SQL statements that access a database cursor later ( SELECT loop and FETCH) raise an exception that cannot be handled.
    Variant 2
    COMMIT CONNECTION con.
    Note
    This statement is for internal use only.
    It cannot be used in application programs.
    Effect
    The COMMIT command is not executed on the standard database, but only on the secondary database connection specified by con. con is the name of the database connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can also be specified dynamically in the form (source_text) - the source_text field contains the name of the database connection. The source_text field must be of the type C or STRING.
    On the specified secondary database connection, the database commit:
    Closes all open database cursors (OPEN CURSOR)
    Releases all database locks
    Note
    Note that the COMMIT CONNECTION DEFAULT statement unlike COMMIT WORK executes a pure database commit on the DEFAULT connection.
    Exceptions
    Non-Catchable Exceptions
    Cause: COMMIT WORK is not possible in a FORM that was called using PERFORM ... ON COMMIT.
    Runtime Error: COMMIT_IN_PERFORM_ON_COMMIT
    Cause: COMMIT WORK is not allowed in the update.
    Runtime Error: COMMIT_IN_POSTING
    ROLLBACK WORK
    Variants:
    1. ROLLBACK WORK.
    2. ROLLBACK CONNECTION con.
    Effect
    Terminates a SAP-LUW without storing the changes.
    Variant 1
    ROLLBACK WORK.
    Effect
    The statement ROLLBACK WORK closes the current SAP-LUW and opens a new one. In doing so, all change requests of the current SAP-LUW are canceled. To do this, ROLLBACK WORK carries out the following actions:
    Executes all subprograms registered with PERFORM ON ROLLBACK.
    Deletes all subprograms registered with PERFORM ON COMMIT.
    Raises an internal exception in the Object Services that makes sure that the attributes of persistent objects are initialised.
    Deletes all update function modules registered with CALL FUNCTION ...IN UPDATE TASK from the VBLOG and deletes all transactional remote Function Calls registered with CALL FUNCTION ... IN BACKGROUND TASK from ARFCSSTATE and from ARFCSDATA.
    Removal of all SAP locks set in the current program in which the formal parameter _SCOPE of the lock function module was set to the value 2.
    Triggers a database rollback, which also ends the current database-LUW.
    After completion of the statement COMMIT WORK, the event TRANSACTION_FINISHED of the system class CL_SYSTEM_TRANSACTION_STATE is raised, in which the parameter KIND has the value of the constant CL_SYSTEM_TRANSACTION_STATE=>ROLLBACK_WORK.
    Variant 2
    ROLLBACK CONNECTION con.
    Note
    This statement is for internal use only.
    It cannot be used in application programs.
    Effect
    The ROLLBACK-statement is not executed on the standard database but only on the secondary database connection, specified through con. con is the name of the database connection as it was specified in table DBCON in column CON_NAME. The database connection con can also be specified dynamically in the form (source_text), in which the field source_text contains the name of the database connection. The field source_text must be of the type C or STRING.
    Notes
    As all opened database cursors on the respective database connections are closed at ROLLBACK, the attempt to continue a SELECT-loop after a ROLLBACK, leads to a runtime error. Due to the same reason, a FETCH after a ROLLBACK to the then closed cursor, leads to a runtime error. You have to make sure that cursors that are still open, are no longer used after ROLLBACK.
    After execution of the statement ROLLBACK, SY-SUBRC is always equal to 0. It is not necessary to check if SY-SUBRC is unequal to 0 after ROLLBACK.
    ROLLBACK must not be used during update (CALL FUNCTION ... IN UPDATE TASK) or during the execution of FORMs, which were registered with PERFORM ... ON COMMIT resp. PERFORM ...ON ROLLBACK.
    The statement ROLLBACK WORK is implicitly executed if a message of the type A is treated with the addition ERROR_MESSAGE when calling a function module with CALL FUNCTION.
    Exceptions
    Non-Catchable Exceptions
    Cause: ROLLBACK WORK is not allowed within a FORM that is called with PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK.
    Runtime Error: ROLLBACK_IN_PERFORM_ON_COMMIT
    Cause: ROLLBACK WORK is not allowed within an update.
    Runtime Error: ROLLBACK_IN_POSTING
    SET UPDATE TASK LOCAL
    Syntax
    SET UPDATE TASK LOCAL.
    Effect
    This statement specifies that the high-priority update function modules - registered during the current SAP LUW using CALL FUNCTION ... IN UPDATE TASK - are registered in the ABAP memory instead of the VBLOG database table. In addition, it specifies that the current work process and not the update work process run these modules during the current database LUW, when the COMMIT WORK statement is executed. This statement has no effect on low-priority update function modules.
    At the beginning of every SAP LUW, the local update function is deactivated. If you wish to use it, you must reactivate it again before the first update function module is registered.
    System fields
    sy-subrc Meaning
    0 The local update function is activated.
    1 The local update function has not been activated, because the program has already registered at least one update function module for the normal updating procedure in the current SAP-LUW.
    Notes
    The local update function performs a synchronous update according to the COMMIT WORK statement, independent of the addition AND WAIT.
    The occurrence of a database rollback during the local update affects all previous change requests.
    Regards
    vasu

  • Multi-page units of work with automatic state management

    Hi Jhs team:
    When my applications need to support an end-user task requiring data entry on many different web pages to complete,
    how to building multi-page units of work with automatic state management ? please give some instruction .

    Ting Rung,
    You can do this in two ways:
    - use a Struts form bean to collect all the values over the requests
    - submit the changes of each request to bc4j, but do not post and commit the changes to the database.
    The latter is easiest. For this to work, you must set the doCommit property of all your save actions in the stuts-condig to false, except for the last save action in the chain of requests.
    In addition, in your application module class, you need to overwrite method postChanges as follows:
    * DO NOT post the changes to the database
    public void postChanges() throws Exception
    // do not post here
    // posting will happen when the commitChanges
    // method on the handler is invoked
    Steven Davelaar,
    Jheadstart Team.

Maybe you are looking for

  • FM to calculate date month & year six months previous to the current date

    Hi All, Is there any function module or code to calculate date month & year six months previous to the current date. Thanks in advance.

  • SAP Conversion Agent Studio Preview Version

    Hi, Does anyone have knowledge about SAP Conversion Agent Studio Preview Version? I've downloaded it from SDN and it says it comes with an Eclipse version, but i doesnt. When i try to point it to my existing Eclipse it says it needs version 2.1.2 oe

  • PS as default for Win Explorer

    How can I prevent Win Explorer from defaulting to PS to open a .pdf file?

  • Upgrade related

    Hi, can any one say replcement for below FMs as these are obsolete. WEEK_GET_FIRST_DAY, DATE_GET_WEEK, WEEK_GET_FIRST_DAY

  • ERM - CUP Approval Workflow E-mails

    Hello gurus, We are experiencing an issue with Role Expert (ERM) to Access Enforcer (CUP) role approval workflow. When a role reaches the approval stage in ERM, an e-mail notification with a link to CUP approval is sent to the designated approver's L