This article mainly introduces how to save entity data. The specific content is as follows;
1. XML sample
<?xml version="1.0" encoding="GBK"?><!-- 1..1 --><cisReports batNo="Query batch number" unitName="Query unit name" subOrgan="Branch name" queryUserID="Query operator login name" queryCount="Query number of requests" receiveTime="Query application time, format YYYYMMDD HH24:mm:ss"> <!-- The following are the query results for each query application 1..n --> <cisReport reportID="Report number" buildEndTime="Report generation end time, format YYYY-MM-DD HH24:mm:ss" queryReasonID="Query reason ID, see the data dictionary for details" subReportTypes="Query fee subreport ID, multiple fee subreport IDs are separated by commas" treatmentResult="Compact fee count times of fee subreport, corresponding to subReportTypes, is a set of values greater than or equal to 0, separated by commas" subReportTypesShortCaption="Query fee subreport Chinese name" refID="Query ID, is the reference ID in the query application condition" hasSystemError="Is there a system error, true: there is an error, false: no error" isFrozen="Whether the customer is frozen, true: frozen, false: not frozen"> <!-- 1Query condition information 1..1 --> <queryConditions> <!-- 1..n --> <item> <name>Query Condition English Name</name> <caption>Query Condition Chinese Name</caption> <value>Query Condition Value</value> </item> </queryConditions> <!--2Identity Authentication1..1 --> <policeCheckInfo subReportType="10602" subReportTypeCost="96040" treatmentResult="Subreport query status, 1: Find, 2: Not found, 3: Not found for other reasons ""ErrorCode="the error code when treatResult=3 is found for details, see the data dictionary when treatResult!=3, this property does not exist" errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this property is empty"> <item> <name>Name of the queryee</name> <documentNo>Name of the queryee</documentNo> <!--1, consistent 2, inconsistent treatmentResult is empty--> <result>Identity authentication result, 1, consistent 2, inconsistent</result> </item> </policeCheckInfo> <!-- 3 persons mobile number verification 1..1 --> <mobileCheckInfo subReportType="13612" subReportTypeCost="96040" treatmentResult="Subreport query status, 1: Find, 2: Not found, 3: Not found for other reasons" "Error Code="treatResult=3, see the data dictionary for details. When treatResult!=3, the attribute does not exist." errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this attribute is empty"> <!---treatresult is 2 and 3, there are no following nodes--> <item> <nameCheckResult> Name verification results, including: consistent, basically consistent, inconsistent, and inconsistent</nameCheckResult> <documentNoCheckResult> Document number verification results, including: consistent, inconsistent, and inconsistent</documentNoCheckResult> <phoneCheckResult>Mobile number verification results: consistent, uncheckable</phoneCheckResult> <areaInfo>Number Attribution</areaInfo> <operator>Operator 1: China Telecom 2: China Mobile 3: China Unicom</operator> </item> </mobileCheckInfo> <!--Summary of 4 personal anti-fraud risks 1..1 --> <personAntiSpoofingDescInfo subReportType="14225" subReportTypeCost="96040" treatmentResult="Subreport query status, 1: found, 2: not found, 3: not found for other reasons" The error code when treatErrorCode="treatResult=3 is available for details. When treatsult!=3, the attribute does not exist. "ErrorMessage="Error description information when treatResult!=3, the value of this attribute is empty"> <!-- When treatreatresult is 2, there is no following node--> <!-- Personal anti-fraud review information. As in the following example, it may be empty, and there may be 0 or n of them, which can be returned according to the specific result. 1. The anti-fraud risk score is 100 points, the risk level is high, and it is recommended to refuse. 2. Telecom mobile phone number 131****1542 has been used for less than 1 month. 3. Hit the list of wool parties. 4. List of hit fraud risks. 5. List of high-risk personnel. 6. There are 7 overdue credit records. 7. There are 40 personal risk summary information. 8. In the past two years, my personal information has been queried 23 times. --> <personAntiSpoofingDesc> Personal Anti-Fraud Review Information</personAntiSpoofingDesc> </personAntiSpoofingDesc> <!--5 Personal Anti-Fraud Risk Score Information 1..1 --> <personAntiSpoofingInfo subReportType="14224" subReportTypeCost="96040" treatmentResult="SubReport query status, 1: Find, 2: Not checked, 3: Not checked for other reasons "The error code when treatErrorCode="treatResult=3, see the data dictionary for details. When treatResult!=3, this property does not exist." errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this property is empty"> <!------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 6 Mobile phone number status information 1..1 --> <mobileStatusInfo subReportType="13611" subReportTypeCost="96040" treatmentResult="Subreport query status, 1: Find, 2: Not found, 3: Not found for other reasons "" error Code="treatResult=3, see the data dictionary, when treatResult!=3, the attribute does not exist" errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this attribute is empty"> <!--When treatreatresult is 2 or 3, there are no following nodes--> <item> <operator>Operator 1: China Telecom 2: China Mobile 3: China Unicom</operator> <areaInfo>Mobile number attribution</areaInfo> <phoneStatus>Mobile status 1: Normal use 2: Shutdown 3: Not enabled 4: Number cancelled 5-other 6: Pre-cancellation</phoneStatus> <timeLength>Mobile number on the Internet, such as: time on the Internet, less than 1 month, 1-2 months, 3-6 months, 7-12 months</timeLength> <cancelTime>Number cancellation time</cancelTime> </item> </mobileStatusInfo> <!--7 Whether to hit the list of wool parties 1..1--> <econnoisserurInfo subReportType="14228" subReportTypeCost="96040" treatmentResult="Subreport query status, 1: Find, 2: Not found, 3: Not found for other reasons" "Error Code="the error code when treatCode="treatResult=3, see the data dictionary for details. When treatResult!=3, the attribute does not exist" errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this attribute is empty"> <!------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- subReportType="14229" subReportTypeCost="96040" treatmentResult="SubReport query status, 1: Find, 2: Not found, 3: Not found for other reasons "" TreatErrorCode="treatResult=3 error code, see the data dictionary, when treatResult!=3, this property does not exist" errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this property is empty"> <!--When treatreatresult is 2 or 3, there are no following nodes--> <state>Whether to hit the fraud risk list, value: 0/1, 0 means missed the fraud risk list, 1 means hit the fraud risk list</state> </fraudRiskInfo> <!--9 Whether to hit the high-risk list 1..1 --> <personRiskAssess subReportType="14226" subReportTypeCost="96040" treatmentResult="Subreport query status, 1: Find, 2: Not checked, 3: Not found for other reasons "" TreatErrorCode="treatResult=3, see the data dictionary, when treatResult!=3, the attribute does not exist" errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this attribute is empty"> <!--When treatreatresult is 2 or 3, there are no following nodes--> <checkResult> Whether to hit the high-risk list 1: Yes, 2: No</checkResult> </personRiskAssess> <!-- 10 online loan overdue information 1..1 --> <microNearlyThreeYearsOverdueInfo subReportType="13204" subReportTypeCost="96040" treatmentResult="Subreport query status, 1: Find, 2: Not found, 3: Not found for other reasons "The error code when treatErrorCode="treatResult=3, see the data dictionary for details. When treatResult!=3, the attribute does not exist." errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this attribute is empty"> <!-- When treatreatresult is 2 or 3, there are no following nodes--> <!--Overdue summary information 0..1--> <stat> <overdueAmount>Overdue principal, unit: based on the currency of the basic information of the loan</overdueAmount> <overdueDays>Overdue days interval, value range: overdue one day (inclusive) or more</overdueDays> <overdueCount>Total number of transactions in the number of overdue days interval</overdueCount> </stat> <!--0..1--> <items> <!--Overdue summary information 1..5 Multiple records--> <item> <overdueAmount>Overdue principal, unit: based on the currency of the basic information of the loan</overdueAmount> <overdueDays>Overdue days interval, value range: 1-6 days overdue, 7-29 days overdue, 30-59 days overdue, 60-89 days overdue, more than 90 days overdue (inclusive)</overdueDays> <overdueCount>Number of transactions in the overdue days interval</overdueCount> </item> </item> </microNearlyThreeYearsOverdueInfo> <!-- 11 Risk Information 1..1 --> <personRiskInfo subReportType="14227" subReportTypeCost="96040" treatmentResult="SubReport query status, 1: found, 2: not found, 3: not found for other reasons" The error code when treatErrorCode="treatResult=3, see the data dictionary for details. When treatResult!=3, the attribute does not exist." errorMessage="treatResult=3, the error description information when treatResult!=3, the value of this attribute is empty"> <!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- <cqggCount>Number of information on hiring announcement</cqggCount> <wdyqCount>Number of information on overdue online loan</wdyqCount> </stat> <!-- Summary information end--> <!-- Summary information 0..1--> <!-- Summary information 0..1 --> <als> <!-- Summary information 0..1 --> <als> <!-- Summary information content of judicial case information 1..n --> <item> <recordId>Record number</recordId> <bt>Title</bt> <ajlx>Case type</ajlx> <sjnf>Year of review, format: YYYY</sjnf> <dsrlx>Type of party </dsrlx> </item> </als> <!-- Summary information of judicial execution information 0..1 --> <zxs> <!-- Summary information of judicial enforcement information 1..n --> <item> <recordId>Record number</recordId> <bt>Title</bt> <zxbd>Execution object, unit: currency shall prevail</zxbd> <larq>Filing date, format YYYY-MM-DD</larq> </item> </zxs> <!-- Summary information of judicial breach of trust 0..1 --> <sxs> <!-- Summary information of judicial breach of trust information 1..n --> <item> <recordId>Record number</recordId> <bt>Title</bt> <larq>Filing date, format YYYY-MM-DD</larq> <fbrq>Release date, format YYYY-MM-DD</fbrq> </item> </sxs> <!-- Tax Administrative Law Enforcement Information Summary Information 0..1 --> <sws> <!-- Tax Administrative Law Enforcement Information Summary Information Content 1..n --> <item> <recordId>Record Number</recordId> <bt>Title</bt> <ggrq>Announcement Date, format YYYY-MM-DD</ggrq> </item> </sws> <!-- >Authorization Announcement Information Summary Information 0..1 --> <cqs> <!-- Tax Administrative Law Enforcement Information Summary Information Content 1..n --> <item> <recordId>Record Number</recordId> <bt>Title</bt> <fbrq>Release date, format YYYY-MM-DD</fbrq> </item> </cqs> <!-- Overdue information summary information of online loans 0..1 --> <wdyqs> <!-- Overdue information summary information of online loans 1..n --> <item> <recordId>Record number</recordId> <bt>Title</bt> <fbrq>Release date, format YYYY-MM-DD</fbrq> </item> </wdyqs> </ summary> </personRiskInfo> <!--12 persons' historical query records in the past two years 1..1 --> <historySimpleQueryInfo subReportType="19902" subReportTypeCost="96040" treatmentResult="Subreport query status, 1: Check, 2: Not found, 3: Not found for other reasons" "Error Code="treatResult=3, see the data dictionary for details. When treatResult!=3, the property does not exist" errorMessage="Error description information when treatResult=3, when treatResult!=3, the value of this property is empty"> <!--- when treatreatresult is 2 and 3, there are no following nodes--> <!--0..1--> <items> <!-- 1..n --> <item> <unitMember> Unit type name</unitMember> <last1Month> Number of query records in the past month</last1Month> <last3Month> Number of query records in the past three months</last3Month> <last6Month>Number of query records in the past 6 months</last6Month> <last12Month>Number of query records in the past 12 months</last12Month> <last18Month>Number of query records in the past 18 months</last18Month> <last24Month>Number of query records in the past 24 months</last24Month> </item> </items> <!--0..1--> <count> <last1Month>Total number of query records in the past 1 month</last1Month> <last3Month>Total number of query records in the past 3 months</last3Month> <last6Month>Total number of query records in the past 6 months</last6Month> <last12Month>Total number of query records in the past 12 months</last12Month> <last18Month>Total number of query records of each unit type in the past 18 months</last18Month> <last24Month>Total number of query records of each unit type in the past 24 months</last24Month> </count> </historySimpleQueryInfo> </cisReport></cisReports>
2. Table structure design
1. Batch number: Each table is associated with the outermost batch number.
2. Main table: that is, all fields of each layer are stored in one table.
Three, physical design
It is divided into three layers: CisReportRoot, CisReportChild, ReportElement
public class CisReportRoot extends BasePojo implements Serializable { private String docId; private String batNo;//Query batch number @JSONField(serialize = false) private String xmlId; private CisReportChild cisReportChild;/** * 2017/7/21. * Report node properties and child nodes*/public class CisReportChild extends BasePojo { /** * Report generation end time**/ private String buildEndTime; /** * Is there a system error true that there is false that means there is no **/ private String hasSystemError; /** * Whether the customer is frozen**/ private String isFrozen; private ReportElement reportElement; public class ReportElement extends BasePojo { private String phone; private PoliceCheckInfo policeCheckInfo;//Identity authentication private MobileCheckInfo mobileCheckInfo;//Person mobile phone number verification private PersonAntiSpoofingDescInfo personAntiSpoofingDescInfo;//Personal Anti-fraud risk review information private PersonAntiSpoofingInfo personAntiSpoofingInfo;//Personal Anti-fraud risk score information private MobileStatusInfo mobileStatusInfo;//Mobile phone number status information private EconnoisserurInfo econnoisserurInfo;//Does hit the wool party list private FraudRiskInfo fraudRiskInfo;//Does hit the fraud risk list private PersonRiskAssess personRiskAssess;//Does hit the high-risk list private MicroNearlyThreeYearsOverdueInfo microNearlyThreeYearsOverdueInfo;//Online loan overdue information private PersonRiskInfo personRiskInfo;//Risk information private HistorySimpleQueryInfo historySimpleQueryInfo;//Personal history query record in the past two yearsFour, code
<1>Single transaction, no primary key required in batches
Data can be stored in maps in single transactions or batches, and data can be obtained through map keys in SQL.
like:
private void savePersonRiskInfo(String batNo, PersonRiskInfo personRiskInfo) throws Exception { Map<String, Object> map = new HashMap<>(); map.put("batNo", batNo); //Single-hand map.put("item", personRiskInfo); pyMapper.savePersonRiskInfo(map); if (!ListUtil.isEmpty(personRiskInfo.getAlList())) { //Batch map.put("list", personRiskInfo.getAlList()); pyMapper.saveAlInfoList(map); }sql:
<!--Personal Risk Record--> //Single<insert id="savePersonRiskInfo" parameterType="java.util.Map"> INSERT INTO TABLE_PERSON_RISK_INFO(BATNO,TOTLECOUNT,ALCOUNT,ZXCOUNT,SXCOUNT,SWCOUNT,CQGGCOUNT,WDYQCOUNT) VALUES (#{batNo,jdbcType=VARCHAR}, #{item.totleCount,jdbcType=NUMERIC}, #{item.alCount,jdbcType=NUMERIC},#{item.zxCount,jdbcType=NUMERIC},#{item.sxCount,jdbcType=NUMERIC},#{item.swCount,jdbcType=NUMERIC},#{item.cqggCount,jdbcType=NUMERIC},#{item.wdyqCount,jdbcType=NUMERIC}) </insert> <!--Detailed Record of Overdue--> //Batch <insert id="saveMicroNearlyThreeYearsOverdueInfoList" parameterType="java.util.Map"> INSERT INTO TABLE_MNTYOI (BATNO,OVERDUEAMOUNT,OVERDUEDAYS,OVERDUECOUNT) <foreach collection="list" item="item" separator="union all"> ( SELECT #{batNo,jdbcType=VARCHAR}, #{item.overdueAmount,jdbcType=VARCHAR}, #{item.overdueDays,jdbcType=VARCHAR}, #{item.overdueCount,jdbcType=NUMERIC} FROM DUAL ) </foreach> </insert> private CisReportRoot invokePy(PyQueryBean pyQueryBean) throws Exception { pyQueryBean.setQueryFromPy(QUERY_FROM_PY); //call py service CisReportRoot cisReportRoot = queryCisReportFromPyServer(pyQueryBean); cisReportRoot.getCisReportChild().getReportElement().setPhone(pyQueryBean.getPhone()); //cacheService.save(cisReportRoot); //(1) Save the data saveCisReport(cisReportRoot); return cisReportRoot; }(1) Save data
@Transactional(rollbackFor = Exception.class) @Override public CisReportRoot saveCisReport(CisReportRoot cisReportRoot) throws Exception { try { ReportElement reportElement = cisReportRoot.getCisReportChild().getReportElement(); PersonRiskInfo personRiskInfo = reportElement.getPersonRiskInfo(); //(2) Main table, save all node information of xml (excluding personal risk information), save single data pyMapper.saveCisReport(cisReportRoot); if (SUCCESS.equals(cisReportRoot.getCisReportChild().getReportElement().getPersonRiskInfo().getTreatResult())) { savePersonRiskInfo(cisReportRoot.getBatNo(), personRiskInfo); } if (cisReportRoot.getCisReportChild().getReportElement().getHistorySimpleQueryInfo().getTreatResult().equals(SUCCESS)) { Map<String, Object> map = new HashMap<>(); // (3) Save batch data map.put("batNo", cisReportRoot.getBatNo()); if (!ListUtil.isEmpty(cisReportRoot.getCisReportChild().getReportElement().getHistorySimpleQueryInfo().getItemList())) { map.put("list", cisReportRoot.getCisReportChild().getReportElement().getHistorySimpleQueryInfo().getItemList()); pyMapper.saveHistorySimpleQueryInfoList(map); } if (!ListUtil.isEmpty(cisReportRoot.getCisReportChild().getReportElement().getMicroNearlyThreeYearsOverdueInfo().getList())) { map.put("list", cisReportRoot.getCisReportChild().getReportElement().getMicroNearlyThreeYearsOverdueInfo().getList()); pyMapper.saveMicroNearlyThreeYearsOverdueInfoList(map); } } return cisReportRoot; } catch (Exception e) { logger.error("saveCisReport@PyserviceImpl_Exception", e); throw e; } }(2) Save the main table
<insert id="saveCisReport" parameterType="java.util.Map"> INSERT INTO TABLE_CISREPORT (BATNO,BUILDENDTIME,ISFROZEN, MCI_NAMECHECKRESULT,MCI_AREAINFO,MCI_DOCUMENTNOCHECKRESULT,MCI_OPERATOR,MCI_PHONECHECKRESULT,PCI_DOCUMENTNO,PCI_NAME,PCI_RESULT,PASDI_DESC, PASI_HITTYPES,PASI_RISKLEVEL,PASI_RISKSCORE,PASI_RISKSUGGEST, MS_AREAINFO,MS_CAnCELTIME,MS_OPERATOR,MS_PHONESTATUS,MS_TIMELENGTH, ECONNOISSERUR, FRAUDRISK, PRA_CHECKRESULT, MNTYOI_OVERDUEAMOUNT,MNTYOI_OVERDUECOUNT,MNTYOI_OVERDUECOUNT,MNTYOI_OVERDUEDAYS, HS_LAST1MONTH,HS_LAST3MONTH,HS_LAST6MONTH,HS_LAST12MONTH,HS_LAST18MONTH,HS_LAST24MONTH,PHONE,XMLID) VALUES (#{batNo,jdbcType=VARCHAR}, to_date(#{cisReportChild.buildEndTime},'yyyy-MM-dd hh24:mi:ss'), #{cisReportChild.isFrozen,jdbcType=VARCHAR}, #{cisReportChild.reportElement.mobileCheckInfo.nameCheckResult,jdbcType=VARCHAR}, #{cisReportChild.reportElement.mobileCheckInfo.areaInfo,jdbcType=VARCHAR}, #{cisReportChild.reportElement.mobileCheckInfo.documentNoCheckResult,jdbcType=VARCHAR}, #{cisReportChild.reportElement.mobileCheckInfo.operator,jdbcType=NUMERIC}, #{cisReportChild.reportElement.mobileCheckInfo.phoneCheckResult,jdbcType=VARCHAR}, #{cisReportChild.reportElement.policeCheckInfo.documentNo,jdbcType=VARCHAR}, #{cisReportChild.reportElement.policeCheckInfo.result,jdbcType=NUMERIC}, #{cisReportChild.reportElement.personAntiSpoofingDescInfo.personAntiSpoofingDesc,jdbcType=VARCHAR}, #{cisReportChild.reportElement.personAntiSpoofingInfo.hitTypes,jdbcType=VARCHAR}, #{cisReportChild.reportElement.personAntiSpoofingInfo.riskLevel,jdbcType=VARCHAR}, #{cisReportChild.reportElement.personAntiSpoofingInfo.riskScore,jdbcType=VARCHAR}, #{cisReportChild.reportElement.personAntiSpoofingInfo.suggest,jdbcType=VARCHAR}, #{cisReportChild.reportElement.mobileStatusInfo.areaInfo,jdbcType=VARCHAR}, #{cisReportChild.reportElement.mobileStatusInfo.cancelTime,jdbcType=VARCHAR}, #{cisReportChild.reportElement.mobileStatusInfo.operator,jdbcType=NUMERIC}, #{cisReportChild.reportElement.mobileStatusInfo.phoneStatus,jdbcType=NUMERIC}, #{cisReportChild.reportElement.mobileStatusInfo.timeLength,jdbcType=VARCHAR}, #{cisReportChild.reportElement.econnoisserurInfo.state,jdbcType=NUMERIC}, #{cisReportChild.reportElement.fraudRiskInfo.state,jdbcType=NUMERIC}, #{cisReportChild.reportElement.personRiskAssess.checkResult,jdbcType=NUMERIC}, #{cisReportChild.reportElement.microNearlyThreeYearsOverdueInfo.overdueAmount,jdbcType=VARCHAR}, #{cisReportChild.reportElement.microNearlyThreeYearsOverdueInfo.overdueCount,jdbcType=NUMERIC}, #{cisReportChild.reportElement.microNearlyThreeYearsOverdueInfo.overdueDays,jdbcType=VARCHAR}, #{cisReportChild.reportElement.historySimpleQueryInfo.totalCount.last1Month,jdbcType=NUMERIC}, #{cisReportChild.reportElement.historySimpleQueryInfo.totalCount.last3Month,jdbcType=NUMERIC}, #{cisReportChild.reportElement.historySimpleQueryInfo.totalCount.last6Month,jdbcType=NUMERIC}, #{cisReportChild.reportElement.historySimpleQueryInfo.totalCount.last12Month,jdbcType=NUMERIC}, #{cisReportChild.reportElement.historySimpleQueryInfo.totalCount.last18Month,jdbcType=NUMERIC}, #{cisReportChild.reportElement.historySimpleQueryInfo.totalCount.last24Month,jdbcType=NUMERIC}, #{cisReportChild.reportElement.phone,jdbcType=VARCHAR}, #{xmlId,jdbcType=VARCHAR})(3) Save batch data (no primary keys are generated automatically)
<!--Personal historical query record for the past two years--> <insert id="saveHistorySimpleQueryInfoList" parameterType="java.util.Map"> INSERT INTO TABLE_HISTORY_SIMPLE_QUERY (BATNO,UNIT_MEMBER,LAST1MONTH,LAST3MONTH,LAST6MONTH,LAST12MONTH,LAST18MONTH,LAST24MONTH) <foreach collection="list" item="item" separator="union all"> ( SELECT #{batNo,jdbcType=VARCHAR}, #{item.unitMember,jdbcType=VARCHAR}, #{item.last1Month,jdbcType=NUMERIC}, #{item.last3Month,jdbcType=NUMERIC}, #{item.last6Month,jdbcType=NUMERIC}, #{item.last12Month,jdbcType=NUMERIC}, #{item.last18Month,jdbcType=NUMERIC}, #{item.last24Month,jdbcType=NUMERIC} FROM DUAL ) </foreach> </insert> <2>Single stroke, batch needs to be inserted into the primary key
Single stroke contains primary key
DataServiceDetailResult dataServiceDetailResult = tdService.getDataServiceDetailResult(tdReportRoot); int n = tdDataServiceMapper.insertDataServiceDetailResult(dataServiceDetailResult); <!--Information Verification Interface--> <!--DATASERVICE--> <insert id="insertDataServiceDetailResult" parameterType="DataServiceDetailResult"> <selectKey keyProperty="id" resultType="BigDecimal" order="BEFORE"> select SEQ_ICS_TD_DATASERVICE.nextval as id from dual </selectKey> insert into ICS_TD_DATASERVICE (ID, RECORDID, REASON_DESC, REASON_CODE, SUCCESS) values (#{id,jdbcType=DECIMAL}, #{recordId,jdbcType=DECIMAL}, #{reasonDesc,jdbcType=VARCHAR}, #{reasonCode,jdbcType=VARCHAR}, #{success,jdbcType=DECIMAL}) </insert>Batch save contains primary key
if (!ListUtil.isEmpty(interfacesList)) { map.put("recordId", id); map.put("list", interfacesList); tdDataServiceMapper.addBatchInterfaces(map); }sql:
<!--Batch save interfaces--> <insert id="addBatchInterfaces" parameterType="java.util.List"> <!-- The comment is mysql insertion method. It can be inserted, but the data cannot be rolled back. The following is the oracle insertion method: Note that parameterType: java.util.List or java.util.Map can be BEGIN <foreach collection="list" item="item" index="index" separator=""> INSERT INTO ICS_TD_INTERFACES(ID, RECORDID, TYPE) VALUES ( BLOANCRDTDATA.SEQ_ICS_TD_INTERFACES.nextval, #{recordId,jdbcType=DECIMAL}, #{item.type,jdbcType=VARCHAR} ); </foreach> COMMIT; END;--> insert into ICS_TD_INTERFACES (ID,RECORDID, TYPE) SELECT SEQ_ICS_TD_INTERFACES.nextval ID, A.* FROM( <foreach collection="list" item="item" index="index" separator="union all"> SELECT #{recordId,jdbcType=DECIMAL}, #{item.type,jdbcType=VARCHAR} FROM DUAL </foreach> ) A </insert>Summarize
The above is the method of saving physical data in a single batch by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!