This discussion is archived
4 Replies Latest reply: Jan 15, 2013 1:24 AM by EJP RSS

always updating same varialble instance in the loop

adf009 Explorer
Currently Being Moderated
hi my loop is always updates the same variable instance in your loop,how can i correct that,mycode is
DCIteratorBinding it = ADFUtils.findIterator("UamOrganisationsView1Iterator");
          UAMAppModuleImpl am = (UAMAppModuleImpl)ADFUtils.getApplicationModuleForDataControl("UAMAppModuleDataControl1");  
           EntityDefImpl accDef4 =UamOrganisationsImpl.getDefinitionObject(); 
           UamOrganisationsImpl org = (UamOrganisationsImpl)accDef4.createInstance2(am.getDBTransaction(),null);
           if(it1 != null && it1.size() > 0){ 
               for(Row r : it1.getAllRowsInRange() ){
           
          
           otype = (String)r.getAttribute("Organisationtypecode");
           osubtype = (String)r.getAttribute("Orgsubtypecode"); 
               org.setOrganisationtypecode(otype);
               System.out.println("onsertorgtype " + otype);
               org.setOrgsubtypecode(osubtype);
               System.out.println("insertedsubtype " + osubtype);
                   
                   
           }
               
           }
 
 am.getDBTransaction().commit();
Edited by: adf0994 on 2013/01/11 9:57 AM
  • 1. Re: always updating same varialble instance in the loop
    EJP Guru
    Currently Being Moderated
    Err, move the creation of 'org' inside the loop? Is this a trick question?
  • 2. Re: always updating same varialble instance in the loop
    gimbal2 Guru
    Currently Being Moderated
    adf0994
    Oracle ADF doesn't generally require programming. So yeah when you make the decision that you do need programming (which is often not true but simply the result of not knowing how certain parts of ADF really work), you run into the issue that you may know a little code but you don't really understand it.
  • 3. Re: always updating same varialble instance in the loop
    adf009 Explorer
    Currently Being Moderated
    hi i did what u say i must do but am geting this error
    java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("ORGANISATIONNAME") the error point to this line am1.getDBTransaction().commit();
    ORA-06512: at line 1

         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
         at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)
         at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)
         at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)
         at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)
         at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:213)
         at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1111)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1488)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3904)
         at oracle.jdbc.driver.OracleCallableStatement.executeUpdate(OracleCallableStatement.java:9417)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1512)
         at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:429)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:8575)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6816)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3290)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:3093)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2097)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2378)
         at uam.cadastre.gov.za.CreateOrganisationBean.addOrginisation(CreateOrganisationBean.java:239)
         at uam.cadastre.gov.za.OrgDetails.getNextStopPayment(OrgDetails.java:692)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(Unknown Source)
         at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
         at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
         at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:148)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:1018)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:386)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:194)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:179)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
            String n = (String)orgDetails.getDpayment().getValue();
            Number orgid =null;
            CreateUserBean cu = new  CreateUserBean();
            OrgDetails orgDetails1 = new OrgDetails(); 
            String  newIdAssigned = cu.createAcc(n,orgDetails.getCadastreAccountBean() );
            System.out.println(" newIdAssigned :"+ newIdAssigned  );       
            EntityDefImpl accDef4 =UamOrganisationsImpl.getDefinitionObject();    
                     String otype = null;
              String osubtype = null;
     UAMAppModuleImpl am1 = (UAMAppModuleImpl)ADFUtils.getApplicationModuleForDataControl("UAMAppModuleDataControl1");
               DCIteratorBinding it0 = ADFUtils.findIterator("UamOrganisationsView1Iterator");
               if(it0 != null && it0.size() > 0){ 
                   
                   
                   for(Row r : it0.getAllRowsInRange() ){
                   //Number orgid1 =null;
                   UamOrganisationsImpl org = (UamOrganisationsImpl)accDef4.createInstance2(am1.getDBTransaction(),null);
              
               otype = (String)r.getAttribute("Organisationtypecode");
               osubtype = (String)r.getAttribute("Orgsubtypecode"); 
                   org.setOrganisationtypecode(otype);
                   System.out.println("onsertorgtype " + otype);
                   org.setOrgsubtypecode(osubtype);
                   System.out.println("insertedsubtype " + osubtype);
                   org.setOrganisationname(orgDetails1.getName());
                   System.out.println("AddedOrganisation " + orgDetails1.getName());    
                   org.setCadastreaccount(newIdAssigned);
                   System.out.println("Addedcardaccount " + newIdAssigned);    
                   org.setOrganisationemail(orgDetails.getEmail());
                   System.out.println("Addedemail " + orgDetails1.getEmail());  
                   org.setRegistrationnumber(orgDetails.getRegNumber());    
                   System.out.println("Registrationnumber " +orgDetails1.getRegNumber());    
                   org.setRegistrationstatus("Y");
                   org.setStatus("Y"); 
                   orgid =  org.getOrganisationid();                              
               }
                    
               }
               am1.getDBTransaction().commit();
    Edited by: adf0994 on 2013/01/11 2:27 PM
  • 4. Re: always updating same varialble instance in the loop
    EJP Guru
    Currently Being Moderated
    You created 'orgDetails'; you never put anything into it; you get things out of it to put into 'org'; and they are null; so you get the error.

    I suggest you conduct a proper code review with your colleagues. You'll never get it fixed by asking here.

    Your duplicate post deleted.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points