Hola,
Desde una ventana de FIT 20.3 estoy lanzando secuencialmente dos batches C que se ejecutan en paralelo y tengo un error relacionado con la gestión de claves con sequence.
En el batch que se lanza, hay un momento que se lanza un maintain que realiza inserciones múltiples usando sequence y en el log del tomcat stderr se ve:
01-Oct-2020 06:57:40.358 GRAVE [https-openssl-nio-443-exec-7] com.almis.fmb.bo.services.manager.BoNetAssetValueBatchCalculationManager.launchBatchTask The maintain operation of multiple statement has failed. [BoSaveNetAssetValueAccountItem]^M
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK__FndNavIt__009EF8E4C10BA998'. Cannot insert duplicate key in object 'dbo.FndNavItmAcc'. The duplicate key value is (339469).
El maintain se lanza con:
ctx.setParameter("NetAssetValueDate", DateUtil.dat2WebDate(accountDate));
ctx.setParameter("FundCode", fundCode);
ctx.setParameter("Phase", JsonNodeFactory.instance.numberNode(phase));
ctx.setParameter("AccountItemConfiguration", listIdes);
ctx.setParameter("Amount", listAmounts);
ctx.setParameter("AmountByItem", listAmountByItem);
ctx.setParameter("ItemAccount", listItemAccounts);
serviceData = launchMaintain(BoConstants.MAINTAIN_SAVE_NET_ASSET_VALUE_ACCOUNT_ITEM);
y el maintain es:
<target name="BoSaveNetAssetValueAccountItem" public="true">
<delete audit="HISFndNavItmAcc">
<table id="FndNavItmAcc"/>
<field id="FndNavItmAccDat" variable="NetAssetValueDate" audit="true"/>
<field id="FndNavItmAccFnd" variable="FundCode" audit="true"/>
<field id="FndNavItmAccPha" variable="Phase" audit="true"/>
<where>
<and>
<filter condition="=" field="FndNavItmAccDat" variable="NetAssetValueDate"/>
<filter condition="=" field="FndNavItmAccFnd" variable="FundCode"/>
<filter condition="=" field="FndNavItmAccPha" variable="Phase"/>
</and>
</where>
<variable id="NetAssetValueDate" type="DATE" name="NetAssetValueDate"/>
<variable id="FundCode" type="STRING" name="FundCode"/>
<variable id="Phase" type="INTEGER" name="Phase"/>
</delete>
<delete audit="HISFndNavItm">
<table id="FndNavItm"/>
<field id="FndNavItmDat" variable="NetAssetValueDate" audit="true"/>
<field id="FndNavItmFnd" variable="FundCode" audit="true"/>
<field id="FndNavItmPha" variable="Phase" audit="true"/>
<where>
<and>
<filter condition="=" field="FndNavItmDat" variable="NetAssetValueDate"/>
<filter condition="=" field="FndNavItmFnd" variable="FundCode"/>
<filter condition="=" field="FndNavItmPha" variable="Phase"/>
</and>
</where>
<variable id="NetAssetValueDate" type="DATE" name="NetAssetValueDate"/>
<variable id="FundCode" type="STRING" name="FundCode"/>
<variable id="Phase" type="INTEGER" name="Phase"/>
</delete>
<insert multiple="true" audit="HISFndNavItmAcc">
<table id="FndNavItmAcc"/>
<field id="FndNavItmAccNum" sequence="FndNavItmAcc" variable="FndNavItmAccNum"/>
<field id="FndNavItmAccDat" variable="NetAssetValueDate"/>
<field id="FndNavItmAccFnd" variable="FundCode"/>
<field id="FndNavItmAccPha" variable="Phase"/>
<field id="FndNavItmAccCfgNum" variable="AccountItemConfiguration"/>
<field id="FndNavItmAccAmn" variable="Amount"/>
<variable id="FndNavItmAccNum" type="INTEGER" name="FndNavItmAccNum"/>
<variable id="NetAssetValueDate" type="DATE" name="NetAssetValueDate"/>
<variable id="FundCode" type="STRING" name="FundCode"/>
<variable id="Phase" type="INTEGER" name="Phase"/>
<variable id="AccountItemConfiguration" type="INTEGER" name="AccountItemConfiguration"/>
<variable id="Amount" type="DOUBLE" name="Amount"/>
</insert>
<insert multiple="true" audit="HISFndNavItm">
<table id="FndNavItm"/>
<field id="FndNavItmNum" sequence="FndNavItm" variable="FndNavItmNum"/>
<field id="FndNavItmDat" variable="NetAssetValueDate"/>
<field id="FndNavItmFnd" variable="FundCode"/>
<field id="FndNavItmPha" variable="Phase"/>
<field id="FndNavItmIde" variable="ItemAccount"/>
<field id="FndNavItmAggAmn" variable="AmountByItem"/>
<variable id="FndNavItmNum" type="INTEGER" name="FndNavItmNum"/>
<variable id="NetAssetValueDate" type="DATE" name="NetAssetValueDate"/>
<variable id="FundCode" type="STRING" name="FundCode"/>
<variable id="Phase" type="INTEGER" name="Phase"/>
<variable id="ItemAccount" type="INTEGER" name="ItemAccount"/>
<variable id="AmountByItem" type="DOUBLE" name="AmountByItem"/>
</insert>
</target>
Saludos, Jesus