2 Replies Latest reply on Feb 1, 2011 12:55 AM by Michal Wroblewski

    What does the sync-on-commit-only do.

    Christian Percy Newbie

      On some container types there is a "sync-on-commit-only" option that is not documented and which is always set to false in the container configurations in standardjboss.xml).
      What does it do exactly. When do I need to put it to true in my container configuration.
      (I checked the source and the default value is false, so in the container definitions in "server\default\conf\standardjboss.xml" where it is defined in some configurations, it always confirms the default hard coded "false")

      Thanks for any information

      Percy Christian

        • 1. Re: What does the sync-on-commit-only do.
          Michal Wroblewski Newbie

          The main description what i found it is located in jboss_5_0.dtd.

           

          <!-- The sync-on-commit-only element determines the behavior of ejbStore
          calls on finds, selects and removes. If set to true, ejbStore will only be
          called on transaction commit.
          -->
          <!ELEMENT sync-on-commit-only (#PCDATA)>

           

           

          1. On ejb invoke set method;

          2. Result is view for ejb not on DB.

          3. I must to invoke some find, select see description above.

           

          If you have invoke finder on current data, include change in the current transaction, you must configurate to false.

          False determine invoke store before calls on finds, selects and removes.

           

          If you hase on true, DB not view change on ejb.

          • 2. What does the sync-on-commit-only do.
            Michal Wroblewski Newbie

            Because I had problem with invoke insert after update on the same table, constrain on DB see old vlaue of fields,

            I had add

                 <container-configuration extends="Instance Per Transaction CMP 2.x EntityBean">

                    <container-name>XYZ</container-name>   

                    <!--call-logging>false</call-logging-->

                    <sync-on-commit-only>false</sync-on-commit-only>

                    <insert-after-ejb-post-create>true</insert-after-ejb-post-create>

                    <container-interceptors>

                                   <interceptor>.......EntitySynchronizationOnSetInterceptor</interceptor>.

             

             

            public class EntitySynchronizationOnSetInterceptor extends AbstractInterceptor{

             

                protected EntityContainer container;

             

                public Container getContainer(){

                    return container;

                }

             

                public void setContainer(Container container){

                    this.container = (EntityContainer)container;

                }

             

                public Object invoke(Invocation invocation) throws Exception {

                    if(invocation.getMethod()!= null

                            && invocation.getMethod().getName().startsWith("set")){

                        EntityEnterpriseContext ctx = (EntityEnterpriseContext)invocation.getEnterpriseContext();

                        Object result  = super.invoke(invocation);

                        container.invokeEjbStore(ctx);

                        container.storeEntity(ctx);

                        return result;

                    }else{

                        return super.invoke(invocation);

                    }

                }

            }

             

            Then connect concret EJB with container-name.

             

            It resolved my problem.

             

            Regards