我目前正在尝试进行批量上传操作,我需要解析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.
答案 0 :(得分:0)
问题在于您尝试从浏览器执行此操作,其中页面的默认超时为30秒。您应该从应用程序执行此操作,以便您可以控制等待上载记录的时间。
答案 1 :(得分:0)
我遇到了类似的问题。
答案 2 :(得分:0)
应该查看多个问题:
@Async
。然后,您的交易不会受到网络连接或浏览器/ HTTP超时的影响。在一天结束时,ORM总是比基本SQL慢。考虑切换到基本SQL,可能连接SQL语句,以便减少数据库跳数,或者使用存储过程,将数据传递给proc并让它运行插入。
答案 3 :(得分:0)
打开会话时使用openStatelessSession并在结尾调用session.update。这样,persistentcontext在缓存中不能有10000个对象,所有更新都在db。
中进行