1

現在、Excel を解析して詳細をデータベースに更新する必要がある一括アップロード操作を実行しようとしています。問題は、データを複数のテーブルに格納する必要があり、関係が維持されることです。問題は、更新するレコードが約 50 ~ 100 件ある場合ではありませんが、更新するレコードが約 50000 件ある場合に大きな影響を受けます。アップロードには時間がかかり、ブラウザが応答の到着を待つことを断念することがあります。以下のコードとマッピング ファイルを参照してください。パフォーマンスを向上させ、処理をより迅速に完了するためにできることを教えてください。

注:カスケードはすべて必須です。

***.hbm.xml
    <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Mar 19, 2012 9:24:47 AM by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
    <class name="com.****.****.hibernate.****" table="V_ACCOUNT_DIM">
        <id name="acctDimIdN" type="long">
            <column name="ACCT_DIM_ID_N" precision="10" scale="0" />
             <generator class="sequence">
                <param name="sequence">ACCOUNT_DIM_SEQ</param>
            </generator>
        </id>
        <property name="gdwIdN" type="long">
            <column name="GDW_ID_N" precision="38" scale="0" not-null="true" />
        </property>
        <property name="pycisInstnIdN" type="java.lang.Long">
            <column name="PYCIS_INSTN_ID_N" precision="10" scale="0" />
        </property>
        <property name="acctNotesC" type="string">
            <column name="ACCT_NOTES_C" length="4000" />
        </property>
        <property name="trdSysShrtNmC" type="string">
            <column name="TRD_SYS_SHRT_NM_C" length="100" />
        </property>
        <property name="reimbAuthorizeD" type="date">
            <column name="REIMB_AUTHORIZE_D" length="7" />
        </property>
        <property name="reimbInitD" type="date">
            <column name="REIMB_INIT_D" length="7" />
        </property>
        <property name="reimbEffD" type="date">
            <column name="REIMB_EFF_D" length="7" />
        </property>
        <property name="acctGainLossAmtN" type="java.lang.Double">
            <column name="ACCT_GAIN_LOSS_AMT_N" precision="15" />
        </property>
        <property name="buySellIndC" type="string">
            <column name="BUY_SELL_IND_C" length="10" />
        </property>
        <property name="navImpcN" type="java.lang.Double">
            <column name="NAV_IMPC_N" precision="15" />
        </property>
        <property name="delIndC" type="string">
            <column name="DEL_IND_C" length="1" not-null="true" />
        </property>
        <property name="updUsrC" type="string">
            <column name="UPD_USR_C" length="12" />
        </property>
        <property name="updTsD" type="date">
            <column name="UPD_TS_D" length="7" />
        </property>
        <property name="insUsrC" type="string">
            <column name="INS_USR_C" length="12" not-null="true" />
        </property>
        <property name="insTsD" type="date">
            <column name="INS_TS_D" length="7" not-null="true" />
        </property>
        <set name="incidentAcctSecFacts" table="V_INCIDENT_ACCT_SEC_FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="ACCT_DIM_ID_N" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.****.***.***.I***Fact" />
        </set>
        <set name="incidentAcctFacts" table="V_INCIDENT_ACCT_FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="ACCT_DIM_ID_N" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.****.***.***.I***Fact" />
        </set>
        <set name="accountAttachmentFacts" table="V_ACCOUNT_ATTACHMENT_FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="ACCT_DIM_ID_N" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.****.***.***.A****Fact" />
        </set>
    </class>
</hibernate-mapping>

I****Dim.hbm.xml

    <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Mar 19, 2012 9:24:47 AM by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
    <class name="com.****.***.***.I****Dim" table="V_****_DIM">
        <id name="incidentDimIdN" type="long">
            <column name="INCIDENT_DIM_ID_N" precision="10" scale="0" />
            <generator class="sequence">
                <param name="sequence">INCIDENT_DIM_SEQ</param>
            </generator>
        </id>
        <property name="errMemoIdC" type="string">
            <column name="ERR_MEMO_ID_C" length="60" not-null="true" unique="true" />
        </property>
        <property name="errMemoD" type="date">
            <column name="ERR_MEMO_D" length="7" />
        </property>
        <property name="idD" type="date">
            <column name="ID_D" length="7" not-null="true" />
        </property>
        <property name="incidentD" type="date">
            <column name="INCIDENT_D" length="7" not-null="true" />
        </property>
        <property name="ntfcD" type="date">
            <column name="NTFC_D" length="7" not-null="true" />
        </property>
        <property name="totGainLossN" type="java.lang.Double">
            <column name="TOT_GAIN_LOSS_N" precision="18"  scale="2"/>
        </property>
        <property name="ovrdAttachedAcctC" type="string">
            <column name="OVRD_ATTACHED_ACCT_C" length="1" />
        </property>
        <property name="gainLossCalcMthdC" type="string">
            <column name="GAIN_LOSS_CALC_MTHD_C" length="4000" />
        </property>
        <property name="deemedAnErrC" type="string">
            <column name="DEEMED_AN_ERR_C" length="1" not-null="true" />
        </property>
        <property name="errRatifiedC" type="string">
            <column name="ERR_RATIFIED_C" length="1" not-null="true" />
        </property>
        <property name="errAcctUsedC" type="string">
            <column name="ERR_ACCT_USED_C" length="1" not-null="true" />
        </property>
        <property name="aprvPrcsC" type="string">
            <column name="APRV_PRCS_C" length="4000" />
        </property>
        <property name="incidentShrtDescC" type="string">
            <column name="INCIDENT_SHRT_DESC_C" length="4000" />
        </property>
        <property name="incidentSumC" type="string">
            <column name="INCIDENT_SUM_C" length="4000" />
        </property>
        <property name="incidentNotesC" type="string">
            <column name="INCIDENT_NOTES_C" length="4000" />
        </property>
        <property name="delIndC" type="string">
            <column name="DEL_IND_C" length="1" not-null="true" />
        </property>
        <property name="updUsrC" type="string">
            <column name="UPD_USR_C" length="12" />
        </property>
        <property name="updTsD" type="date">
            <column name="UPD_TS_D" length="7" />
        </property>
        <property name="insUsrC" type="string">
            <column name="INS_USR_C" length="12" not-null="true" />
        </property>
        <property name="insTsD" type="date">
            <column name="INS_TS_D" length="7" />
        </property>
        <set name="incidentAttachmentFacts" table="V_****FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="INCIDENT_DIM_ID_N" precision="10" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.****.***.***.I***Fact" />
        </set>
        <set name="incidentActionItemFacts" table="V_****_FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="INCIDENT_DIM_ID_N" precision="22" scale="0" />
            </key>
            <one-to-many class="com.****.***.***.I****Fact" />
        </set>
        <set name="incidentAcctSecFacts" table="V_****FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="INCIDENT_DIM_ID_N" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.***.***.****.IncidentAcctSecFact" />
        </set>
        <set name="irgMemberAssignmentFacts" table="V_IRG_MEMBER_ASSIGNMENT_FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="INCIDENT_DIM_ID_N" precision="22" scale="0" />
            </key>
            <one-to-many class="com.***.***.****.IrgMemberAssignmentFact" />
        </set>
        <set name="incidentAcctFacts" table="V_INCIDENT_ACCT_FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="INCIDENT_DIM_ID_N" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.***.***.****.IncidentAcctFact" />
        </set>
        <set name="acctAttachmentFacts" table="V_ACCOUNT_ATTACHMENT_FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="INCIDENT_DIM_ID_N" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.***.***.****.AccountAttachmentFact" />
        </set>
    </class>
</hibernate-mapping>

CerSecurityDim.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Mar 19, 2012 9:24:47 AM by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
    <class name="com.***.***.****.CerSecurityDim" table="V_CER_SECURITY_DIM">
        <id name="cerSecuDimIdN" type="long">
            <column name="CER_SECU_DIM_ID_N" precision="22" scale="0" />
             <generator class="sequence">
                <param name="sequence">CER_SECURITY_DIM_SEQ</param>
            </generator>
        </id>
        <property name="fmrCusipC" type="string">
            <column name="FMR_CUSIP_C" length="30" not-null="true" />
        </property>
        <property name="tckrC" type="string">
            <column name="TCKR_C" length="30" />
        </property>
        <property name="secuNmC" type="string">
            <column name="SECU_NM_C" not-null="true" />
        </property>
        <property name="numOfShrTrdN" type="java.lang.Long">
            <column name="NUM_OF_SHR_TRD_N" precision="10" scale="0" />
        </property>
        <property name="secuGainLossN" type="java.lang.Double">
            <column name="SECU_GAIN_LOSS_N" precision="15" />
        </property>
        <property name="buySellIndC" type="string">
            <column name="BUY_SELL_IND_C" length="10" />
        </property>
        <property name="delIndC" type="string">
            <column name="DEL_IND_C" length="1" not-null="true" />
        </property>
        <property name="updUsrC" type="string">
            <column name="UPD_USR_C" length="12" />
        </property>
        <property name="updTsD" type="date">
            <column name="UPD_TS_D" length="7" />
        </property>
        <property name="insUsrC" type="string">
            <column name="INS_USR_C" length="12" not-null="true" />
        </property>
        <property name="insTsD" type="date">
            <column name="INS_TS_D" length="7" not-null="true" />
        </property>
        <set name="incidentAcctSecFacts" table="V_INCIDENT_ACCT_SEC_FACT" inverse="true" lazy="true" fetch="select" cascade="all-delete-orphan"  >
            <key>
                <column name="SECU_DIM_ID_N" precision="22" scale="0" not-null="true" />
            </key>
            <one-to-many class="com.***.***.****.IncidentAcctSecFact" />
        </set>
    </class>
</hibernate-mapping>


IncidentAcctFact.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Mar 19, 2012 9:24:47 AM by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
    <class name="com.***.***.****.IncidentAcctFact" table="V_INCIDENT_ACCT_FACT">
        <id name="incidentAcctFactIdN" type="long">
            <column name="INCIDENT_ACCT_FACT_ID_N" precision="22" scale="0" />
            <generator class="sequence">
                <param name="sequence">INCIDENT_ACCT_FACT_SEQ</param>
            </generator>
        </id>
        <many-to-one name="accountDim" class="com.***.***.****.AccountDim" fetch="select">
            <column name="ACCT_DIM_ID_N" precision="22" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="incidentDim" class="com.***.***.****.IncidentDim" fetch="select">
            <column name="INCIDENT_DIM_ID_N" precision="22" scale="0" not-null="true" />
        </many-to-one>
       <!--  <many-to-one name="attachmentTypeDim" class="com.***.***.****.AttachmentTypeDim" fetch="select">
            <column name="ATTACHMENT_TYPE_DIM_ID_N" precision="22" scale="0" not-null="false" />
        </many-to-one> -->
        <property name="relEffFromD" type="date">
            <column name="REL_EFF_FROM_D" length="7" />
        </property>
        <property name="relEffThruD" type="date">
            <column name="REL_EFF_THRU_D" length="7" />
        </property>
        <property name="ltstRelIndC" type="string">
            <column name="LTST_REL_IND_C" length="1" />
        </property>
        <property name="delIndC" type="string">
            <column name="DEL_IND_C" length="1" not-null="true" />
        </property>
        <property name="updUsrC" type="string">
            <column name="UPD_USR_C" length="12" />
        </property>
        <property name="updTsD" type="date">
            <column name="UPD_TS_D" length="7" />
        </property>
        <property name="insUsrC" type="string">
            <column name="INS_USR_C" length="12" />
        </property>
        <property name="insTsD" type="date">
            <column name="INS_TS_D" length="7" />
        </property>
    </class>
</hibernate-mapping>


IncidentAcctSecFact.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Mar 19, 2012 9:24:47 AM by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
    <class name="com.***.***.****.IncidentAcctSecFact" table="V_INCIDENT_ACCT_SEC_FACT">
        <id name="incidentAcctSecIdN" type="long">
            <column name="INCIDENT_ACCT_SEC_ID_N" precision="22" scale="0" />
            <generator class="sequence">
                <param name="sequence">INCIDENT_ACCT_SEC_FACT_SEQ</param>
            </generator>
        </id>
        <many-to-one name="accountDim" class="com.***.***.****.AccountDim" fetch="select">
        <column name="ACCT_DIM_ID_N" precision="22" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="cerSecurityDim" class="com.***.***.****.CerSecurityDim" fetch="select">
            <column name="SECU_DIM_ID_N" precision="22" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="incidentDim" class="com.***.***.****.IncidentDim" fetch="select">
            <column name="INCIDENT_DIM_ID_N" precision="22" scale="0" not-null="true" />
        </many-to-one>
         <property name="relEffFromD" type="date">
             <column name="REL_EFF_FROM_D" length="7" />
         </property>
         <property name="relEffThruD" type="date">
             <column name="REL_EFF_THRU_D" length="7" />
         </property>
         <property name="ltstRelIndC" type="string">
             <column name="LTST_REL_IND_C" length="1" />
         </property>
         <property name="delIndC" type="string">
             <column name="DEL_IND_C" length="1" />
         </property>
         <property name="updUsrC" type="string">
             <column name="UPD_USR_C" length="12" />
         </property>
         <property name="updTsD" type="date">
             <column name="UPD_TS_D" length="7" />
         </property>
         <property name="insUsrC" type="string">
             <column name="INS_USR_C" length="12" />
         </property>
         <property name="insTsD" type="date">
             <column name="INS_TS_D" length="7" />
         </property>
    </class>
</hibernate-mapping>


The method where the actual processing is as follows.

   public boolean retrieveDataAndParseFile(IncidentDetailsForm incidentDetailsForm,  BaseViewBean baseViewBean$Session, 
                                                ActionMessages errors) throws Exception {
        boolean savedStatus = false;    
        boolean deletedstatus = false;

        /*List<AccountDim> accountsList = new ArrayList<AccountDim>();
        List<CerSecurityDim> cerSecuList = new ArrayList<CerSecurityDim>();
        List<IncidentAcctSecFact> inciAcctSecFactList = new ArrayList<IncidentAcctSecFact>();
        List<IncidentAcctFact> inciAcctFactList = new ArrayList<IncidentAcctFact>();
        List<IncidentDim> incidentList = new ArrayList<IncidentDim>();*/

        try {
            double totalSecGL= 0.00;
            double secTrdNetTotal= 0.00;
            DecimalFormat twoDForm = new DecimalFormat("#.##");

            String loginUser = baseViewBean$Session.getLoggedInUser().getUserId();
            List<Long> addedElementList = new ArrayList<Long>();

            CerSecurityDim cerSecDim = null;
            AccountDim account = null;
            IncidentAcctSecFact iasFact = null;
            IncidentAcctFact iaFact = null;
            long incidentId = baseViewBean$Session.getIncidentDim$Session().getIncidentDimIdN();
            IncidentDim incident = (IncidentDim)incidentDimDao.findById(IncidentDim.class, incidentId);
            ExcelListenerBean beanDetails;

            List<AccountDim> acctList = new ArrayList<AccountDim>();
            List <CerSecurityDim> cerSecList = new ArrayList<CerSecurityDim>();
            List <IncidentAcctSecFact> iasFactList = new ArrayList<IncidentAcctSecFact>();

            for (Map.Entry<Integer, ExcelListenerBean> entry : baseViewBean$Session.getExcelRecords().entrySet())
            {
                beanDetails = entry.getValue();

                //Initialize the net amounts for incorrect trade and correction trade.
                secTrdNetTotal= 0;

                cerSecDim = new CerSecurityDim();
                account = new AccountDim();
                iasFact = new IncidentAcctSecFact();
                iaFact = new IncidentAcctFact();

                //
                Object[] pycisDet = investmentDimDao.getPyCISIdByShrtName(beanDetails.getShortName());
                if(pycisDet != null && pycisDet.length > 0){
                    account.setPycisInstnIdN((Long)pycisDet[0]);
                    account.setGdwIdN((Long)pycisDet[1]);
                    account.setTrdSysShrtNmC(beanDetails.getShortName());
                    if(!addedElementList.contains((Long)pycisDet[0])){
                        addedElementList.add((Long)pycisDet[0]);
                    } 
                } 

                //
                cerSecDim.setFmrCusipC(beanDetails.getFmrCusip());
                SecurityDim sec = getSecDetailsByCusip(beanDetails.getFmrCusip());
                if(sec != null){
                    cerSecDim.setSecuNmC(sec.getSecuNmC());
                    cerSecDim.setTckrC(sec.getTckrC());
                }else {
                    cerSecDim.setSecuNmC("UNKNOWN");
                    cerSecDim.setTckrC("UNKNOWN");
                }

                //
                cerSecDim.setNumOfShrTrdN(beanDetails.getIncorrectTrdShares().longValue());

                //
                cerSecDim.setBuySellIndC(beanDetails.getIncorrectTrdBuySell().toUpperCase());
                account.setBuySellIndC(beanDetails.getIncorrectTrdBuySell().toUpperCase());

                //
                secTrdNetTotal  = Double.valueOf(twoDForm.format(beanDetails.getIncorrectTrdNet())) +
                                                Double.valueOf(twoDForm.format(beanDetails.getCorrectionTrdNet()));

                //
                totalSecGL = totalSecGL + secTrdNetTotal;

                boolean updatedStatus = false;

                // create the relationship and then add to the respective lists.
                cerSecDim.setInsUsrC(loginUser);
                cerSecDim.setInsTsD(AppGlobalUtil.getCurrentTimeStamp());
                cerSecDim.setDelIndC(AppGlobalConstants.HardCodedValues.No);

                if(!acctList.isEmpty()){
                    for( AccountDim olderAccount :acctList){
                        if(olderAccount.getPycisInstnIdN().compareTo(account.getPycisInstnIdN()) == 0) {
                            double newAcctGainLossAmt=0;
                            double oldAcctGainLossAmt=0;
                            if(account.getAcctGainLossAmtN() != null){
                                newAcctGainLossAmt = account.getAcctGainLossAmtN();
                            }
                            if(olderAccount.getAcctGainLossAmtN() != null){
                                oldAcctGainLossAmt = olderAccount.getAcctGainLossAmtN();
                            }
                            double newGLAmt = newAcctGainLossAmt + oldAcctGainLossAmt;
                            account = olderAccount;
                            account.setAcctGainLossAmtN(newGLAmt);
                            updatedStatus = true;
                        }
                    }
                }

                if(!cerSecList.isEmpty()){
                    for(CerSecurityDim olderCerSecDim : cerSecList){
                        if(olderCerSecDim.getFmrCusipC().equals(cerSecDim.getFmrCusipC())) {
                            cerSecDim = olderCerSecDim;
                            double newSecuGainLoss = 0;
                            double oldSecuGainLoss = 0;
                            if(cerSecDim.getSecuGainLossN() != null){
                                newSecuGainLoss = cerSecDim.getSecuGainLossN();
                            }
                            if(olderCerSecDim.getSecuGainLossN() != null){
                                oldSecuGainLoss = olderCerSecDim.getSecuGainLossN();
                            }
                            cerSecDim.setSecuGainLossN(newSecuGainLoss + oldSecuGainLoss);

                            for(IncidentAcctSecFact olderIASFact : iasFactList){
                                if(olderIASFact != null && olderIASFact.getCerSecurityDim() != null
                                        && olderIASFact.getCerSecurityDim().getFmrCusipC().equals(cerSecDim.getFmrCusipC())){
                                    iasFact = olderIASFact;
                                }
                            }
                        }
                    }
                }
                if(!deletedstatus){
                    deleteAllImpactedAccounts(baseViewBean$Session);
                    deletedstatus = true;
                }
                totalSecGL = Double.valueOf(twoDForm.format(totalSecGL));

                account.setInsUsrC(loginUser);
                account.setInsTsD(AppGlobalUtil.getCurrentTimeStamp());
                account.setDelIndC(AppGlobalConstants.HardCodedValues.No);
                accountDimDao.saveOrUpdate(account);

                iasFact.setAccountDim(account);
                iasFact.setIncidentDim(incident);
                iasFact.setCerSecurityDim(cerSecDim);
                iasFact.setInsUsrC(loginUser);
                iasFact.setInsTsD(AppGlobalUtil.getCurrentTimeStamp());
                iasFact.setDelIndC(AppGlobalConstants.HardCodedValues.No);

                cerSecDim.getIncidentAcctSecFacts().add(iasFact);
                account.getIncidentAcctSecFacts().add(iasFact);
                incident.getIncidentAcctSecFacts().add(iasFact);

                if(!updatedStatus){ 
                    iaFact.setAccountDim(account);
                    iaFact.setIncidentDim(incident);
                    iaFact.setInsUsrC(loginUser);
                    iaFact.setInsTsD(AppGlobalUtil.getCurrentTimeStamp());
                    iaFact.setDelIndC(AppGlobalConstants.HardCodedValues.No);

                    incident.getIncidentAcctFacts().add(iaFact);
                    account.getIncidentAcctFacts().add(iaFact);
                }
                incident.setTotGainLossN(totalSecGL);

                cerSecurityDimDao.saveOrUpdate(cerSecDim);
                incidentAcctSecFactDao.saveOrUpdate(iasFact);
                if(!updatedStatus){
                    accountDimDao.saveOrUpdate(account);
                }
                if(!acctList.contains(account)){
                    acctList.add(account);
                }
                if(!cerSecList.contains(cerSecDim)){
                    cerSecList.add(cerSecDim);
                }
                if(!iasFactList.contains(iasFact)){
                    iasFactList.add(iasFact);
                }
                if(!updatedStatus){
                    incidentAcctFactDao.saveOrUpdate(iaFact);
                }
                incidentDimDao.saveOrUpdate(incident);

                NumberFormat formatter = new DecimalFormat("#0.00");
                incidentDetailsForm.setTotalGainLoss(formatter.format(totalSecGL));

                savedStatus = true;

                /*accountsList.add(account);
                cerSecuList.add(cerSecDim);
                inciAcctSecFactList.add(iasFact);
                inciAcctFactList.add(iaFact);
                incidentList.add(incident);*/
            }

        } catch (Exception e) {
            logger.error(e.getMessage());
            e.printStackTrace();
            throw e;
        }
        finally{
            baseViewBean$Session.getExcelRecords().clear();
            baseViewBean$Session.setExcelRecords(null);
        }

        /*accountDimDao.saveOrUpdateAll(accountsList);
        cerSecurityDimDao.saveOrUpdateAll(cerSecuList);
        incidentAcctSecFactDao.saveOrUpdateAll(inciAcctSecFactList);
        incidentAcctFactDao.saveOrUpdateAll(inciAcctFactList);
        incidentDimDao.saveOrUpdateAll(incidentList);*/

        return savedStatus;
    }

The dao functions are accessed from another file. 

Please let me know how i can increase my performance.    
4

4 に答える 4

0

似たような問題があります。

  • 結合フィールドと検索フィールドのすべてのキーがあることを確認してください。
  • ファイルを一時的な場所に保存してから、並列スレッドで処理できる場合があります。
  • もう 1 つのオプションは、ステートレス セッションを使用することです (ネット上にはほとんど情報がありません。休止状態のマニュアルを参照してください)。ManyToMany コレクションを埋めるオプションがあるかどうかはわかりません。
  • テーブルのコピーをメモリに保存して getOrCreate クエリをキャッシュすると役立つ場合があります (ただし、OutOfMemory 例外が発生する可能性があるため、アプリに -Xmx パラメータを渡します)。
  • これらすべてが問題を解決しない場合があります。ネイティブ SQL クエリを使用してこれらの挿入を実装することにしました。
于 2012-12-15T10:46:43.980 に答える
0

検討すべき複数の問題があります。

  1. 長時間実行される操作は、非同期で実行する必要があります。たとえば、Spring を使用している場合は、注釈を付けることができ@Asyncます。そうすれば、トランザクションはネットワーク接続やブラウザ/HTTP タイムアウトの影響を受けません。
  2. Hibernate でのバッチ操作は非常に遅くなる可能性があります。JDBC バッチ処理をセットアップしたとしても、Hibernate のドキュメントの指示に従っても、ORM を使用しているという事実に縛られています。ORMS は、個々のオブジェクトの状態の関連性が低いバッチ操作ではなく、オブジェクト指向操作の状態を維持するために最適に使用されます。
  3. Hibernate でのバッチ操作は非常に扱いにくい場合があります。たとえば、Hibernate のバッチ処理のドキュメントでは、正しくバッチ処理を行うために構成に追加のフラグを設定する必要があることに注意していません。詳細については、この投稿を参照してください。

結局のところ、ORM は常にベース SQL よりも遅くなります。ベース SQL に切り替えるか、SQL ステートメントを連結してデータベースのトリップを減らすか、ストアド プロシージャを使用して、データのバッチを proc に渡して挿入を実行することを検討してください。

于 2012-12-16T17:30:27.937 に答える
0

問題は、ページのデフォルトのタイムアウトが 30 秒であるブラウザからこれを実行しようとしていることです。レコードのアップロードを待機する時間を制御できるように、アプリケーションからこれを行う必要があります。

于 2012-12-15T07:42:19.973 に答える