could not read column value from result set - oracle

1)my hibernate not work when upgrade from Jboss5.1.0 to Jboss5.2.0, so Hibernate get upgrade as well.
before upgrade:
hibernate-core.jar: 3.3.1.GA
hibernate-entitymanager.jar: 3.4.0.GA
hibernate-annotation.jar: 3.4.0.GA
after upgrade:
hibernate-core.jar: 3.3.2.GA_CP05
hibernate-entitymanager.jar: 3.4.0.GA_CP05
hibernate-annotation.jar: 3.4.0.GA_CP05
2)from the server, I found hibernate using a none-exist column alias(agreeme17_69_17_) to get value from resultset.
3)and I found exactly the same issue :https://forum.hibernate.org/viewtopic.php?f=1&t=968677 ---from which, the issue is caused by not specify all the columns explicitly in the select clause in the native sql.
4)but I'm using annotation not native sql in the mapping file, all columns should be included in the select clause.
5)When I replace all hibernate*jar with the old ones, It's works again.
/error log/
2013-12-04 13:34:48,415 TRACE [org.hibernate.type.BooleanType] (http-0.0.0.0-8080-2:) returning 'true' as column: useIss118_69_15_
2013-12-04 13:34:48,415 SEVERE [oracle.jdbc.driver] (http-0.0.0.0-8080-2:) Throwing SQLException: 6
2013-12-04 13:34:48,423 INFO [org.hibernate.type.LongType] (http-0.0.0.0-8080-2:) could not read column value from result set: agreeme17_69_17_; Invalid column name
2013-12-04 13:34:48,423 DEBUG [org.hibernate.jdbc.AbstractBatcher] (http-0.0.0.0-8080-2:) about to close ResultSet (open ResultSets: 1, globally: 1)
2013-12-04 13:34:48,423 DEBUG [org.hibernate.jdbc.AbstractBatcher] (http-0.0.0.0-8080-2:) about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2013-12-04 13:34:48,423 TRACE [org.hibernate.jdbc.AbstractBatcher] (http-0.0.0.0-8080-2:) closing statement
/sql/
/* Formatted on 12/4/2013 4:01:46 PM (QP5 v5.114.809.3010) */
SELECT *
FROM ( SELECT this_.id AS id69_15_,
this_.agreementName AS agreemen2_69_15_,
this_.agreementType AS agreemen3_69_15_,
this_.allowNegEffRate AS allowNeg4_69_15_,
this_.annexes AS annexes69_15_,
this_.autoBookApplicability AS autoBook6_69_15_,
this_.autoBooking AS autoBook7_69_15_,
this_.baseCurrency AS baseCurr8_69_15_,
this_.businessLine AS business9_69_15_,
this_.calcAgentCpty AS calcAge10_69_15_,
this_.calcAgentPrinc AS calcAge11_69_15_,
this_.calcRule AS calcRule69_15_,
this_.calculationDate AS calcula13_69_15_,
this_.callReturnBucketId AS callRet14_69_15_,
this_.category AS category69_15_,
this_.ccp AS ccp69_15_,
this_.cobValuationDateId AS cobValu17_69_15_,
this_.colManager AS colManager69_15_,
this_.colType AS colType69_15_,
this_.umbrellaRule AS umbrel115_69_15_,
this_.comments AS comments69_15_,
this_.compoundInterestCalc AS compoun21_69_15_,
this_.concLimitTrigger AS concLim22_69_15_,
this_.conditionRule AS conditi23_69_15_,
this_.confirmationLetterTarget AS confirm24_69_15_,
this_.cptyCCContact AS cptyCCC25_69_15_,
this_.cptyCollatralNetValuation AS cptyCol26_69_15_,
this_.cptyIMSeg AS cptyIMSeg69_15_,
this_.cptyInterestCCContact AS cptyInt28_69_15_,
this_.cptyInterestContact AS cptyIn119_69_15_,
this_.cptyContact AS cptyCo120_69_15_,
this_.counterpartyHQ AS counte121_69_15_,
this_.cptySettleMethod AS cptySet29_69_15_,
this_.cptyVMSeg AS cptyVMSeg69_15_,
this_.creationDate AS creatio31_69_15_,
this_.custodianId AS custodi34_69_15_,
this_.custodianCCContact AS custodi32_69_15_,
this_.custodianContact AS custodi33_69_15_,
this_.description AS descrip35_69_15_,
this_.disablecomment AS disable36_69_15_,
this_.disableinfo AS disable37_69_15_,
this_.distMedium AS distMedium69_15_,
this_.creditsupportdoc AS credit122_69_15_,
this_.edittingCompleted AS edittin39_69_15_,
this_.effectiveDate AS effecti40_69_15_,
this_.eligRulesTemplateId AS eligRul41_69_15_,
this_.enableInterestCalc AS enableI42_69_15_,
this_.exposureProfile AS exposur43_69_15_,
this_.exposureStatementTemplateType AS exposur44_69_15_,
this_.extId AS extId69_15_,
this_.genLock AS genLock69_15_,
this_.groupId AS groupId69_15_,
this_.imCalcRule AS imCalcRule69_15_,
this_.IMCallReturnBucketId AS IMCallR49_69_15_,
this_.imCompInterestCalc AS imCompI50_69_15_,
this_.imCptySettleMethod AS imCptyS51_69_15_,
this_.imEnableInterestCalc AS imEnabl52_69_15_,
this_.IMPaymentBucketId AS IMPayme53_69_15_,
this_.imPrinSettleMethod AS imPrinS54_69_15_,
this_.IMRecallDeliveryBucketId AS IMRecal55_69_15_,
this_.IMReceiveBucketId AS IMRecei56_69_15_,
this_.imRoundingDelivery AS imRound57_69_15_,
this_.imRoundingRecall AS imRound58_69_15_,
this_.imStd AS imStd69_15_,
this_.includeFailTradeValueCloseLeg AS include60_69_15_,
this_.includeFailTradeValueOpenLeg AS include61_69_15_,
this_.isMultiModel AS isMulti62_69_15_,
this_.jurisdiction AS jurisdi63_69_15_,
this_.lastModifiedBy AS lastMod64_69_15_,
this_.letterTemplateType AS letterT65_69_15_,
this_.marketDataId AS marketD66_69_15_,
this_.navCpty AS navCpty69_15_,
this_.navCptyCur AS navCptyCur69_15_,
this_.navPrincipal AS navPrin69_69_15_,
this_.navPrincipalCur AS navPrin70_69_15_,
this_.netEvent AS netEvent69_15_,
this_.netInterest AS netInte72_69_15_,
this_.nettingCalc AS netting73_69_15_,
this_.nettingInterest AS netting74_69_15_,
this_.nettingMTMAndIA AS netting75_69_15_,
this_.notes AS notes69_15_,
this_.notificationLetterType AS notific77_69_15_,
this_.owner AS owner69_15_,
this_.parentId AS parentId69_15_,
this_.paymentBucketId AS payment80_69_15_,
this_.priceSource AS priceSo81_69_15_,
this_.principalInterestContact AS princi123_69_15_,
this_.principalContact AS princi124_69_15_,
this_.principal AS principal69_15_,
this_.princIMSeg AS princIMSeg69_15_,
this_.princVmSeg AS princVmSeg69_15_,
this_.principalCCContact AS princip84_69_15_,
this_.principalInterestCCContact AS princip85_69_15_,
this_.principalSettleMethod AS princip86_69_15_,
this_.recallDeliveryBucketId AS recallD87_69_15_,
this_.receiveBucketId AS receive88_69_15_,
this_.reciprocity AS recipro89_69_15_,
this_.region AS region69_15_,
this_.regulatory AS regulatory69_15_,
this_.rehypoRights AS rehypoR92_69_15_,
this_.rehypoType AS rehypoType69_15_,
this_.reviewDate AS reviewDate69_15_,
this_.roundingDelivery AS roundin95_69_15_,
this_.roundingRecall AS roundin96_69_15_,
this_.settlementId AS settlem97_69_15_,
this_.settlementLevel AS settlem98_69_15_,
this_.signoffBy AS signoffBy69_15_,
this_.signoffDate AS signof100_69_15_,
this_.signoffNotes AS signof101_69_15_,
this_.statementSet AS statem102_69_15_,
this_.statusId AS statusId69_15_,
this_.std AS std69_15_,
this_.stdType AS stdType69_15_,
this_.terminationDate AS termin106_69_15_,
this_.tradeModelDeterminedByFeed AS tradeM107_69_15_,
this_.tradeValuationRule AS tradeV108_69_15_,
this_.triPartyIA AS triPartyIA69_15_,
this_.tsa AS tsa69_15_,
this_.tsaLevel AS tsaLevel69_15_,
this_.tsaPayBucketId AS tsaPay112_69_15_,
this_.tsaReceiveBucketId AS tsaRec113_69_15_,
this_.tsaRule AS tsaRule69_15_,
this_.umbrellaType AS umbrel116_69_15_,
this_.useIssueRating AS useIss117_69_15_,
this_.useIssuerRating AS useIss118_69_15_,
colagreeme1_.agreementId AS agreemen2_69_17_,
colagreeme1_.id AS id17_,
colagreeme1_.id AS id19_0_,
colagreeme1_.agreementId AS agreemen2_19_0_,
colagreeme1_.genLock AS genLock19_0_,
colagreeme1_.linkageId AS linkageId19_0_,
orgaddress4_.Id AS Id96_1_,
orgaddress4_.Address AS Address96_1_,
orgaddress4_.ContactName AS ContactN3_96_1_,
orgaddress4_.Email AS Email96_1_,
orgaddress4_.enabled AS enabled96_1_,
orgaddress4_.FaxNumber AS FaxNumber96_1_,
orgaddress4_.Ftp AS Ftp96_1_,
orgaddress4_.genLock AS genLock96_1_,
orgaddress4_.Label AS Label96_1_,
orgaddress4_.Notes AS Notes96_1_,
orgaddress4_.OrgHeaderId AS OrgHead11_96_1_,
orgaddress4_.sigId AS sigId96_1_,
orgaddress4_.TelephoneNumber AS Telepho13_96_1_,
orgaddress4_.Title AS Title96_1_,
orgaddress5_.Id AS Id96_2_,
orgaddress5_.Address AS Address96_2_,
orgaddress5_.ContactName AS ContactN3_96_2_,
orgaddress5_.Email AS Email96_2_,
orgaddress5_.enabled AS enabled96_2_,
orgaddress5_.FaxNumber AS FaxNumber96_2_,
orgaddress5_.Ftp AS Ftp96_2_,
orgaddress5_.genLock AS genLock96_2_,
orgaddress5_.Label AS Label96_2_,
orgaddress5_.Notes AS Notes96_2_,
orgaddress5_.OrgHeaderId AS OrgHead11_96_2_,
orgaddress5_.sigId AS sigId96_2_,
orgaddress5_.TelephoneNumber AS Telepho13_96_2_,
orgaddress5_.Title AS Title96_2_,
orgheadere6_.id AS id16_3_,
orgheadere6_.genLock AS genLock16_3_,
orgheadere6_.LastUpdateBy AS LastUpda3_16_3_,
orgheadere6_.LastUpdateTime AS LastUpda4_16_3_,
orgheadere6_.lei AS lei16_3_,
orgheadere6_.longName AS longName16_3_,
orgheadere6_.orgCode AS orgCode16_3_,
orgheadere6_.orgStatusId AS orgStatu8_16_3_,
orgheadere6_.shortName AS shortName16_3_,
orgheadere6_.status AS status16_3_,
orgudfejb3x7_.id AS id3_4_,
orgudfejb3x7_.genLock AS genLock3_4_,
orgudfejb3x7_.UDF1 AS UDF3_3_4_,
orgudfejb3x7_.UDF10 AS UDF4_3_4_,
orgudfejb3x7_.UDF11 AS UDF5_3_4_,
orgudfejb3x7_.UDF12 AS UDF6_3_4_,
orgudfejb3x7_.UDF13 AS UDF7_3_4_,
orgudfejb3x7_.UDF14 AS UDF8_3_4_,
orgudfejb3x7_.UDF15 AS UDF9_3_4_,
orgudfejb3x7_.UDF16 AS UDF10_3_4_,
orgudfejb3x7_.UDF17 AS UDF11_3_4_,
orgudfejb3x7_.UDF18 AS UDF12_3_4_,
orgudfejb3x7_.UDF19 AS UDF13_3_4_,
orgudfejb3x7_.UDF2 AS UDF14_3_4_,
orgudfejb3x7_.UDF20 AS UDF15_3_4_,
orgudfejb3x7_.UDF21 AS UDF16_3_4_,
orgudfejb3x7_.UDF22 AS UDF17_3_4_,
orgudfejb3x7_.UDF23 AS UDF18_3_4_,
orgudfejb3x7_.UDF24 AS UDF19_3_4_,
orgudfejb3x7_.UDF25 AS UDF20_3_4_,
orgudfejb3x7_.UDF26 AS UDF21_3_4_,
orgudfejb3x7_.UDF27 AS UDF22_3_4_,
orgudfejb3x7_.UDF28 AS UDF23_3_4_,
orgudfejb3x7_.UDF29 AS UDF24_3_4_,
orgudfejb3x7_.UDF3 AS UDF25_3_4_,
orgudfejb3x7_.UDF30 AS UDF26_3_4_,
orgudfejb3x7_.UDF4 AS UDF27_3_4_,
orgudfejb3x7_.UDF5 AS UDF28_3_4_,
orgudfejb3x7_.UDF6 AS UDF29_3_4_,
orgudfejb3x7_.UDF7 AS UDF30_3_4_,
orgudfejb3x7_.UDF8 AS UDF31_3_4_,
orgudfejb3x7_.UDF9 AS UDF32_3_4_,
orgheadere8_.id AS id16_5_,
orgheadere8_.genLock AS genLock16_5_,
orgheadere8_.LastUpdateBy AS LastUpda3_16_5_,
orgheadere8_.LastUpdateTime AS LastUpda4_16_5_,
orgheadere8_.lei AS lei16_5_,
orgheadere8_.longName AS longName16_5_,
orgheadere8_.orgCode AS orgCode16_5_,
orgheadere8_.orgStatusId AS orgStatu8_16_5_,
orgheadere8_.shortName AS shortName16_5_,
orgheadere8_.status AS status16_5_,
orgaddress9_.Id AS Id96_6_,
orgaddress9_.Address AS Address96_6_,
orgaddress9_.ContactName AS ContactN3_96_6_,
orgaddress9_.Email AS Email96_6_,
orgaddress9_.enabled AS enabled96_6_,
orgaddress9_.FaxNumber AS FaxNumber96_6_,
orgaddress9_.Ftp AS Ftp96_6_,
orgaddress9_.genLock AS genLock96_6_,
orgaddress9_.Label AS Label96_6_,
orgaddress9_.Notes AS Notes96_6_,
orgaddress9_.OrgHeaderId AS OrgHead11_96_6_,
orgaddress9_.sigId AS sigId96_6_,
orgaddress9_.TelephoneNumber AS Telepho13_96_6_,
orgaddress9_.Title AS Title96_6_,
colrefdata10_.id AS id94_7_,
colrefdata10_.category AS category94_7_,
colrefdata10_.description AS descript3_94_7_,
colrefdata10_.scheme AS scheme94_7_,
colrefdata10_.status AS status94_7_,
colrefdata10_.refdatavalue AS refdatav6_94_7_,
orgaddress11_.Id AS Id96_8_,
orgaddress11_.Address AS Address96_8_,
orgaddress11_.ContactName AS ContactN3_96_8_,
orgaddress11_.Email AS Email96_8_,
orgaddress11_.enabled AS enabled96_8_,
orgaddress11_.FaxNumber AS FaxNumber96_8_,
orgaddress11_.Ftp AS Ftp96_8_,
orgaddress11_.genLock AS genLock96_8_,
orgaddress11_.Label AS Label96_8_,
orgaddress11_.Notes AS Notes96_8_,
orgaddress11_.OrgHeaderId AS OrgHead11_96_8_,
orgaddress11_.sigId AS sigId96_8_,
orgaddress11_.TelephoneNumber AS Telepho13_96_8_,
orgaddress11_.Title AS Title96_8_,
orgaddress12_.Id AS Id96_9_,
orgaddress12_.Address AS Address96_9_,
orgaddress12_.ContactName AS ContactN3_96_9_,
orgaddress12_.Email AS Email96_9_,
orgaddress12_.enabled AS enabled96_9_,
orgaddress12_.FaxNumber AS FaxNumber96_9_,
orgaddress12_.Ftp AS Ftp96_9_,
orgaddress12_.genLock AS genLock96_9_,
orgaddress12_.Label AS Label96_9_,
orgaddress12_.Notes AS Notes96_9_,
orgaddress12_.OrgHeaderId AS OrgHead11_96_9_,
orgaddress12_.sigId AS sigId96_9_,
orgaddress12_.TelephoneNumber AS Telepho13_96_9_,
orgaddress12_.Title AS Title96_9_,
orgheadere13_.id AS id16_10_,
orgheadere13_.genLock AS genLock16_10_,
orgheadere13_.LastUpdateBy AS LastUpda3_16_10_,
orgheadere13_.LastUpdateTime AS LastUpda4_16_10_,
orgheadere13_.lei AS lei16_10_,
orgheadere13_.longName AS longName16_10_,
orgheadere13_.orgCode AS orgCode16_10_,
orgheadere13_.orgStatusId AS orgStatu8_16_10_,
orgheadere13_.shortName AS shortName16_10_,
orgheadere13_.status AS status16_10_,
statement14_.agreementId AS agreeme17_69_18_,
statement14_.id AS id18_,
statement14_.id AS id1_11_,
statement14_.ITMExposure AS ITMExpos2_1_11_,
statement14_.ITMMarginReq AS ITMMargi3_1_11_,
statement14_.OTMExposure AS OTMExpos4_1_11_,
statement14_.OTMMarginReq AS OTMMargi5_1_11_,
statement14_.accruedCoupon AS accruedC6_1_11_,
statement14_.adjCtpyColVal AS adjCtpyC7_1_11_,
statement14_.adjExposureAmnt AS adjExpos8_1_11_,
statement14_.adjITMExposureAmnt AS adjITMEx9_1_11_,
statement14_.adjIaExpAmt AS adjIaEx10_1_11_,
statement14_.adjMtmExpAmt AS adjMtmE11_1_11_,
statement14_.adjMtmItmExpAmt AS adjMtmI12_1_11_,
statement14_.adjMtmOtmExpAmt AS adjMtmO13_1_11_,
statement14_.adjOTMExposureAmnt AS adjOTME14_1_11_,
statement14_.adjPrincColVal AS adjPrin15_1_11_,
statement14_.agreementExposureAdj AS agreeme16_1_11_,
statement14_.agreementId AS agreeme17_1_11_,
statement14_.agreementType AS agreeme18_1_11_,
statement14_.cashAvailable AS cashAva19_1_11_,
statement14_.confirmedColDelivered AS confirm20_1_11_,
statement14_.confirmedColHeld AS confirm21_1_11_,
statement14_.counterpartyId AS counter25_1_11_,
statement14_.counterpartyCalExtIA AS counter22_1_11_,
statement14_.counterpartyExtIA AS counter23_1_11_,
statement14_.counterpartyIA AS counter24_1_11_,
statement14_.CptyExtIAModifyTime AS CptyExt26_1_11_,
statement14_.ctpyIMThreshold AS ctpyIMT27_1_11_,
statement14_.ctpyImMinTransAmnt AS ctpyImM28_1_11_,
statement14_.ctpyImRoundingAmnt AS ctpyImR29_1_11_,
statement14_.ctpyMinTransAmnt AS ctpyMin30_1_11_,
statement14_.ctpyRoundingAmnt AS ctpyRou31_1_11_,
statement14_.ctpyThreshold AS ctpyThr32_1_11_,
statement14_.curLockupMarginCpty AS curLock33_1_11_,
statement14_.curLockupMarginPrinc AS curLock34_1_11_,
statement14_.dateMissMatchFxRate AS dateMis35_1_11_,
statement14_.dateMissMatchSecurity AS dateMis36_1_11_,
statement14_.deliveryAmnt AS deliver37_1_11_,
statement14_.excludeCollateral AS exclude38_1_11_,
statement14_.ExtIACurrencyId AS ExtIACu39_1_11_,
statement14_.genLock AS genLock1_11_,
statement14_.iaConflict AS iaConflict1_11_,
statement14_.iaDeliveryAmnt AS iaDeliv42_1_11_,
statement14_.iaRecallAmnt AS iaRecal43_1_11_,
statement14_.imCashBalance AS imCashB44_1_11_,
statement14_.imED AS imED1_11_,
statement14_.imMktCashBalance AS imMktCa46_1_11_,
statement14_.imMktSecuritiesCol AS imMktSe47_1_11_,
statement14_.imRequirement AS imRequi48_1_11_,
statement14_.imSecuritiesCol AS imSecur49_1_11_,
statement14_.inTotalExposure AS inTotal50_1_11_,
statement14_.lastUpdated AS lastUpd51_1_11_,
statement14_.lockupDelvCtpy AS lockupD52_1_11_,
statement14_.lockupDelvPrinc AS lockupD53_1_11_,
statement14_.lockupMarginCallCpty AS lockupM54_1_11_,
statement14_.lockupMarginCallPrinc AS lockupM55_1_11_,
statement14_.lockupMarginReqCpty AS lockupM56_1_11_,
statement14_.lockupMarginReqPrinc AS lockupM57_1_11_,
statement14_.lockupRetunPrinc AS lockupR58_1_11_,
statement14_.lockupReturnCtpy AS lockupR59_1_11_,
statement14_.marginCtpyIA AS marginC60_1_11_,
statement14_.marginDelvCtpy AS marginD61_1_11_,
statement14_.marginDelvPrinc AS marginD62_1_11_,
statement14_.marginPrincipalIA AS marginP63_1_11_,
statement14_.marginReturnCtpy AS marginR64_1_11_,
statement14_.marginReturnPrinc AS marginR65_1_11_,
statement14_.marginTotalExpAmnt AS marginT66_1_11_,
statement14_.mktValAssetCtpy AS mktValA67_1_11_,
statement14_.mktValAssetPrinc AS mktValA68_1_11_,
statement14_.mtmExposure AS mtmExpo69_1_11_,
statement14_.netCashValue AS netCash70_1_11_,
statement14_.netED AS netED1_11_,
statement14_.netMarginReq AS netMarg72_1_11_,
statement14_.netNonSysCalValue AS netNonS73_1_11_,
statement14_.netSecurityValue AS netSecu74_1_11_,
statement14_.notes AS notes1_11_,
statement14_.notifTime AS notifTime1_11_,
statement14_.outTotalExposure AS outTota77_1_11_,
statement14_.overwriteIAWithExtIA AS overwri78_1_11_,
statement14_.pendingColDelivered AS pending79_1_11_,
statement14_.pendingColHeld AS pending80_1_11_,
statement14_.portfolioChangedPerc AS portfol81_1_11_,
statement14_.previousTotalExposure AS previou82_1_11_,
statement14_.priceMissed AS priceMi83_1_11_,
statement14_.priceMissedRepoTrade AS priceMi84_1_11_,
statement14_.PrincExtIAModifyTime AS PrincEx85_1_11_,
statement14_.princIMThreshold AS princIM86_1_11_,
statement14_.princImMinTransAmnt AS princIm87_1_11_,
statement14_.princImRoundingAmnt AS princIm88_1_11_,
statement14_.princMinTransAmnt AS princMi89_1_11_,
statement14_.princRoundingAmnt AS princRo90_1_11_,
statement14_.princThreshold AS princTh91_1_11_,
statement14_.principalCalExtIA AS princip92_1_11_,
statement14_.principalExtIA AS princip93_1_11_,
statement14_.principalIA AS princip94_1_11_,
statement14_.ratingContigentIdCpty AS ratingC95_1_11_,
statement14_.ratingContigentIdPrin AS ratingC96_1_11_,
statement14_.recallAmnt AS recallAmnt1_11_,
statement14_.reciprocity AS recipro98_1_11_,
statement14_.relationship AS relatio99_1_11_,
statement14_.reportingCur AS report100_1_11_,
statement14_.resolutionTime AS resolu101_1_11_,
statement14_.sameDay AS sameDay1_11_,
statement14_.specialReminder AS specia103_1_11_,
statement14_.systemCalcCounterpartyExtIA
AS system104_1_11_,
statement14_.systemCalcPrincipalExtIA AS system105_1_11_,
statement14_.timeZone AS timeZone1_11_,
statement14_.totalExposure AS totalE107_1_11_,
statement14_.totalNotional AS totalN108_1_11_,
statement14_.totalSettlementAmt AS totalS109_1_11_,
statement14_.tradeConflict AS tradeC110_1_11_,
statement14_.tradeIneligible AS tradeI111_1_11_,
statement14_.tradesCount AS trades112_1_11_,
statement14_.tsaConflict AS tsaCon113_1_11_,
statement14_.valuationDate AS valuat114_1_11_,
statement14_.valuationFreqPeriod AS valuat115_1_11_,
statement14_.valueIAColDelivered AS valueI116_1_11_,
statement14_.valueIAColHeld AS valueI117_1_11_,
statement14_.variationMargin AS variat118_1_11_,
statement14_.vmCashBalance AS vmCash119_1_11_,
statement14_.vmED AS vmED1_11_,
statement14_.vmMktCashBalance AS vmMktC121_1_11_,
statement14_.vmMktSecuritiesCol AS vmMktS122_1_11_,
statement14_.vmSecuritiesCol AS vmSecu123_1_11_,
statement14_.wrongFxCol AS wrongFxCol1_11_,
statement14_.wrongFxExp AS wrongFxExp1_11_,
statement14_.wrongPriceExp AS wrongP126_1_11_,
colstateme15_.id AS id43_12_,
colstateme15_.agreementId AS agreemen2_43_12_,
colstateme15_.lastApproved AS lastAppr3_43_12_,
colstateme15_.statusId AS statusId43_12_,
stmteligib16_.agreementId AS agreemen2_69_,
stmteligib16_.id AS id,
stmteligib16_.id AS id44_13_,
stmteligib16_.agreementId AS agreemen2_44_13_,
stmteligib16_.calcTime AS calcTime44_13_,
stmteligib16_.clBreached AS clBreached44_13_,
stmteligib16_.ineligible AS ineligible44_13_,
colagreeme17_.agreementId AS agreemen1_7_14_,
colagreeme17_.messageAttachmentMedium AS messageA2_7_14_,
colagreeme17_.interfaceSystem AS interfac3_7_14_,
colagreeme17_.messageAgreementId AS messageA4_7_14_,
colagreeme17_.messageWorkflowType AS messageW5_7_14_,
colagreeme17_.responseToleranceAmount AS response6_7_14_,
colagreeme17_.responseToleranceCurrency AS response7_7_14_
FROM ColAgreementHeader this_
LEFT OUTER JOIN
COLAGREEMENTLINKAGE colagreeme1_
ON this_.id =
colagreeme1_.agreementId
LEFT OUTER JOIN
OrgAddress orgaddress4_
ON this_.cptyInterestContact =
orgaddress4_.Id
LEFT OUTER JOIN
OrgAddress orgaddress5_
ON this_.cptyContact =
orgaddress5_.Id
INNER JOIN
OrgHeader orgheadere6_
ON this_.counterpartyHQ =
orgheadere6_.id
LEFT OUTER JOIN
OrgUDF orgudfejb3x7_
ON orgheadere6_.id =
orgudfejb3x7_.id
LEFT OUTER JOIN
OrgHeader orgheadere8_
ON this_.custodianId =
orgheadere8_.id
LEFT OUTER JOIN
OrgAddress orgaddress9_
ON this_.custodianContact =
orgaddress9_.Id
INNER JOIN
ColRefData colrefdata10_
ON this_.creditsupportdoc =
colrefdata10_.id
LEFT OUTER JOIN
OrgAddress orgaddress11_
ON this_.principalInterestContact =
orgaddress11_.Id
LEFT OUTER JOIN
OrgAddress orgaddress12_
ON this_.principalContact =
orgaddress12_.Id
INNER JOIN
OrgHeader orgheadere13_
ON this_.principal = orgheadere13_.id
LEFT OUTER JOIN
ColStatement statement14_
ON this_.id = statement14_.agreementId
LEFT OUTER JOIN
ColStatementStatus colstateme15_
ON statement14_.id = colstateme15_.id
LEFT OUTER JOIN
ColStmtEligibleCalc stmteligib16_
ON this_.id = stmteligib16_.agreementId
LEFT OUTER JOIN
ColAgreementHeaderDetails colagreeme17_
ON this_.id = colagreeme17_.agreementId
WHERE this_.umbrellaType <> ?
AND this_.businessLine IN (?, ?, ?)
AND colagreeme1_.linkageId LIKE ?
ORDER BY this_.id ASC)
WHERE ROWNUM <= ?
/colstatement schema //
//the association of the 2 entity beans causing the error

Why not try turning the association around and define it as a #ManyToOne association in ColAgreementLinkageEJB3, and then define the #OneToMany as a 'mappedBy' relationship?
So your ColAgreementLinkageEJB3 would contain:
#Column(name = "AGREEMENT_ID")
private Long agreementId;
#ManyToOne(fetch = FetchType.LAZY, optional = true)
#JoinColumn(name = "AGREEMENT_ID", referencedColumnName = "ID", insertable = false, updatable = false)
private ColAgreementHeaderEJB3 header;
Note, you don't need to put the insertable/updatable parameters on the column definition.
And your ColAgreementHeaderEJB3 Entity would contain:
#OneToMany(mappedBy = "header", fetch = FetchType.LAZY)
private Set<ColAgreementLinkageEJB3> linkageSet;
Also, you do not need the #NotFound annotation as a one-to-many relationship is essentially one-to-zero-or-many.
If you want to always load the set of linkages, you would make the FetchType EAGER.

you will get this exception if you have data in table with this format Value '0000-00-00' can not be represented as java.sql.Date.hence you have delete these data and insert proper Date format in DB..!!

Related

The name 'devicetypes' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'

I am trying to get data out of my db but i am getting the above mentioned error on this line. Please HELP!!!!
join specvalue in db.Types on devicespecifications.DeviceTypeFKID equals devicetypes.DeviceTypeID
I have Tried switching the equals but it doesn't work. Please Help
List<DeviceDetails> devicedetails = (
from devices in db.Device
join devicespecifications in db.DeviceSpecifications on devices.DeviceID equals devicespecifications.DeviceFKID
join devicetypes in db.Types on devices.DeviceTypeFKID equals devicetypes.DeviceTypeID
join specvalue in db.Types on devicespecifications.DeviceTypeFKID equals devicetypes.DeviceTypeID // This Line is giving me the above mentioned error
join devicehistories in db.DeviceHistory on devices.DeviceID equals devicehistories.DeviceFKID
join locations in db.Locations on devices.LocationFKID equals locations.LocationID
join ips in db.IP on devices.DeviceID equals ips.DeviceFKID
where devices.DeviceID == id
select new DeviceDetails()
{
DeviceID = devices.DeviceID,
DeviceName = devices.DeviceName,
EntryDate = devices.EntryDate,
AssignDate = devices.AssignDate,
DeviceStatus = devices.DeviceStatus.ToString(),
MACAddress = devices.MACAddress,
DateRepaired= devicehistories.DateRepaired,
Remarks= devicehistories.Remarks,
SpecificationType = devicespecifications.DeviceTypeFKID,
devicetypes.DeviceTypeID,
SpecificationValue = devicespecifications.SpecificationValue,
FamilyIP = ips.FamilyIP,
ChildIP = ips.ChildIP,
LocationTypeValue = locations.LocationTypeValue,
DeviceTypeValue = devicetypes.DeviceTypeValue
}).ToList<DeviceDetails>();
return devicedetails;
}
In the mentioned row:
join specvalue in db.Types on devicespecifications.DeviceTypeFKID equals devicetypes.DeviceTypeID
you use devicetypes name again but you should use specvalue in this line.

Query Optimization - Suggestions?

I am hoping someone can help me understand this XML Showplan for a long running query. This query comes from a Crystal Report developed by the software vendor that is very slow running, and I'm trying to convert it to an SSRS report while speeding the query up.
Here is a link to the Execution Plan - File hosted on File Dropper.
And here is the actual query itself:
Select Distinct
CD.desclong [Center],
CD.CenterType,
Sub.Description [SubCenter],
Org.Description [OrgCenter],
CO.CodeID [CenterC],
Sub.CodeID [SubCenterC],
Org.CodeID [OrgCenterC],
Reg.Description [Region],
Reg.CodeID [RegionC],
Rec.CodeID [RecID],
Rec.Description [RecName],
Rec.NickName [RecNickName],
Acct.AccountID [AcctCharCode],
DM.DriveID,
DM.ExternalID [DriveExtID],
DM.FromDateTime [DriveDate],
dbo.getShiftProductProjectionList(DSD.shiftid) [ProductProjections],
dbo.getShiftProcedureProjectionList(DSD.shiftid) [ProcedureProjections],
dbo.getShiftMobileList(DSD.shiftid, '1,2,3') [MobileSetups],
LD.LocationName [LocationName],
Case DM.OwnerType
When 1 Then FSM.DisplayName
When 0 Then Acct.InternalName
End [OwnerName], Acct.ExternalID [AcctExtID], SM.ExternalID [SiteExtID],
Stat.StatusText [DriveStatus],
DSD.ShiftID,
DSD.ShiftStart,
DSD.ShiftEnd,
DT.EarlyShiftStart,
DT.LateShiftEnd,
Changes.*,
dbo.getOriginalProcedureProjection(Changes.dsprocshiftid, Changes.dsprocprocedureid) [OriginalProjection],
(Select Top 1 DescMed From Production.[dbo].QuickCodes where CodeValue = 'ACTEXTIDTAG') [ActExtIDTag],
(Select Top 1 DescMed From Production.[dbo].QuickCodes where CodeValue = 'SITEEXTIDTAG') [SiteExtIDTag],
(Select Top 1 DescMed From Production.[dbo].QuickCodes where CodeValue = 'DRVEXTIDTAG') [DrvExtIDTag],
Case When (Changes.TableName = 'DriveShiftProcedureDetail') Then (Select Top 1 projectionid From driveshiftproceduredetail where uniquekey = Changes.owneruniquekey) else null end as ProjectionID
From
Production.[dbo].rpt_DriveMaster DM
Join Production.[dbo].rpt_DriveShiftDetail DSD on DSD.DriveID = DM.DriveID
Join Production.[dbo].CriticalDriveChanges Changes on (Changes.SourceDriveID = DM.DriveID and Changes.SourceShiftID = DSD.ShiftID and
Production.[dbo].returnDateTime(year(Changes.ChangeWhen),month(Changes.ChangeWhen),day(Changes.ChangeWhen)) between '01/04/2015' and '01/04/2015')
And
(
(
(Changes.TableName='DriveShiftProcedureDetail' and Changes.ColumnName='projection')
or
(Changes.TableName='DriveShiftDetail' and (Changes.ColumnName='ShiftStart' or Changes.ColumnName='ShiftEnd'))
or
(Changes.TableName='DriveShiftDetail' and Changes.ColumnName='StaffRequested')
or
(Changes.TableName='DriveShiftDetail' and Changes.changetype='Delete')
or
(Changes.TableName='DriveMaster' and Changes.ColumnName='StatusID' and Changes.NewValue='5')
or
(Changes.TableName='DriveMaster' and Changes.ColumnName='FromDateTime')
or
(Changes.TableName='DriveShiftRoleTimeDetail' and Changes.ColumnName='Lead')
or
(Changes.TableName='DriveShiftRoleTimeDetail' and Changes.ColumnName='TravelTo')
or
(Changes.TableName='DriveShiftRoleTimeDetail' and Changes.ColumnName='Setup')
or
(Changes.TableName='DriveShiftRoleTimeDetail' and Changes.ColumnName='Breakdown')
or
(Changes.TableName='DriveShiftRoleTimeDetail' and Changes.ColumnName='TravelFrom')
or
(Changes.TableName='DriveShiftRoleTimeDetail' and Changes.ColumnName='WrapUp')
)
and
(Changes.ChangeWho<>'RMADMIN')
)
Join Production.[dbo].rpt_DriveStatusDef Stat on Stat.StatusID = DM.StatusID
Join Production.[dbo].DriveTimes DT on DT.DriveID = DM.DriveID
Left Outer Join Production.[dbo].rpt_CenterDetail CD on CD.CenterID = DM.centerid
Left Outer Join Production.[dbo].IDViewRegion Reg on CD.Region = Reg.CodeID
Left Outer Join Production.[dbo].IDViewOrgCenter Org on CD.OrgCenter = Org.CodeID
Left Outer Join Production.[dbo].IDViewOrgSubCenter Sub on CD.OrgSubcenter = Sub.CodeID
Left Outer Join Production.[dbo].IDViewCollectionOp CO on cd.centerid = CO.CodeID
Left Outer Join Production.[dbo].IDViewRecruiter Rec on Rec.CodeID = DM.RecruiterID
Left Outer Join Production.[dbo].rpt_Accounts Acct on Acct.AccountID = DM.AccountID
Left Outer Join Production.[dbo].rpt_FixedSiteScheduleMaster FSM on FSM.DrawID = DM.DrawID
Left Outer Join Production.[dbo].rpt_LocationDetail LD on LD.LocationID = DM.LocationID
Join Production.[dbo].rpt_SiteMaster SM on SM.SiteID = DM.SiteID
Where
(dbo.returnDateTime(year(DM.Fromdatetime),month(DM.Fromdatetime),day(DM.Fromdatetime)) between '01/04/2015' and '01/04/2015')
or (dbo.returnDateTime(year(Changes.previousdrivedate),month(Changes.previousdrivedate),day(Changes.previousdrivedate)) between '01/04/2015' and '01/04/2015')
Here is the actual execution plan using Set Statistics XML On
Execution Plan
Thanks!
I removed the functions for returnDateTime and used the following instead:
-- In the FROM statement
Join Hemasphere_Dev.[dbo].CriticalDriveChanges Changes on (Changes.SourceDriveID = DM.DriveID And Changes.SourceShiftID = DSD.ShiftID And Changes.ChangeWhen Between '01/01/2015' And '01/15/2015')
--Hemasphere_Dev.[dbo].returnDateTime(year(Changes.ChangeWhen),month(Changes.ChangeWhen),day(Changes.ChangeWhen)) between '01/01/2015' And '01/15/2015')
-- In the WHERE statement
DM.FromDateTime Between '01/01/2015' And '01/15/2015'
Or Changes.PreviousDriveDate Between '01/01/2015' and '01/15/2015'
--(dbo.returnDateTime(year(DM.FromDateTime),month(DM.FromDateTime),day(DM.FromDateTime)) Between '01/01/2015' And '01/15/2015')
--Or (dbo.returnDateTime(year(Changes.previousdrivedate),month(Changes.previousdrivedate),day(Changes.previousdrivedate)) Between '01/01/2015' And '01/15/2015')
The query actually ran slower this way.

Using Spring Data JPA with QueryDsl, paginated queries break sorting

Given the following query, my results are sorted by the order number in descending order. While attempting to return paginated results, the sorting seems to break. I've tried it without the .orderBy() expression and adding a QSort instance to my QPageRequest. I've tried calling the applySorting() method directly and passing a QSort, but for all intensive purposes, the pagination call breaks any kind of sorting I try.
I'm using QueryDsl 3.3.4 and Spring Data JPA 1.6.4. as imported by the Spring IO BOM 1.0.3.
public List<Object[]> findAll(PersonProfile personProfile) {
QOrderStop shipper = new QOrderStop("shipper");
QOrderStop consignee = new QOrderStop("consignee");
JPQLQuery query = this.from(order)
.leftJoin(order.orderStops, shipper).on(shipper.originalStopSequence.eq(BigDecimal.valueOf(1)))
.leftJoin(order.orderStops, consignee).on(consignee.originalStopSequence.intValue().eq(order.orderStops.size()))
.where(order.company.eq(company).and(OrderExpressions.customerCodePredicate(order, personProfile)))
.orderBy(order.number.desc());
//this.getQuerydsl().applyPagination(new QPageRequest(0, 10), query);
return query
.list(
order.number, order.status, order.shipperReferenceNumber, order.consigneeReferenceNumber,
order.shipperCustomer.billingCity, order.shipperCustomer.state,
shipper.latestScheduleDate, shipper.latestScheduleTime,
order.consigneeCustomer.billingCity, order.consigneeCustomer.state,
consignee.latestScheduleDate, consignee.latestScheduleTime
).stream()
.map(Tuple::toArray)
.collect(toList());
}
EDIT - Using .limit(20) for pagination instead of .applyPagination()
query.toString() before query.limit(20)
select order1
from Order order1
left join order1.orderStops as shipper on shipper.originalStopSequence = ?1
left join order1.orderStops as consignee on cast(consignee.originalStopSequence integer) = size(order1.orderStops)
where order1.company = ?2 and (order1.customer = ?3 or order1.billTo in ?4 or order1.shipper in ?5 or order1.consignee in ?5)
order by order1.number desc
query.toString() after query.limit(20) - no change
select order1
from Order order1
left join order1.orderStops as shipper on shipper.originalStopSequence = ?1
left join order1.orderStops as consignee on cast(consignee.originalStopSequence integer) = size(order1.orderStops)
where order1.company = ?2 and (order1.customer = ?3 or order1.billTo in ?4 or order1.shipper in ?5 or order1.consignee in ?5)
order by order1.number desc
Final query output by EclipseLink
SELECT * FROM (SELECT * FROM (SELECT EL_TEMP.*, ROWNUMBER() OVER() AS EL_ROWNM FROM (SELECT t0.OHOR# AS a1, t0.OHORST AS a2, t0.OHSRF# AS a3, t0.OHCRF# AS a4, t1.CUBCTY AS a5, t1.CUBST AS a6, t2.BSLSDT AS a7, t2.BSLSTM AS a8, t3.CUBCTY AS a9, t3.CUBST AS a10, t4.BSLSDT AS a11, t4.BSLSTM AS a12 FROM LIB.DPORDHP t0 LEFT OUTER JOIN LIB.DPORDSP t2 ON (((t2.BSOR# = t0.OHOR#) AND ((t2.BSOL# = t0.OHORS#) AND (t2.BSCM = t0.OHCM))) AND (t2.BSRSQS = ?)) LEFT OUTER JOIN LIB.DPORDSP t4 ON (((t4.BSOR# = t0.OHOR#) AND ((t4.BSOL# = t0.OHORS#) AND (t4.BSCM = t0.OHCM))) AND (CAST(t4.BSRSQS AS integer) = (SELECT COUNT(t5.BSOR#) FROM LIB.DPORDSP t5 WHERE ((t5.BSOR# = t0.OHOR#) AND ((t5.BSOL# = t0.OHORS#) AND (t5.BSCM = t0.OHCM)))))), LIB.SWCUSTP t3, LIB.SWCUSTP t1 WHERE (((t0.OHCM = ?) AND ((((t0.OHCUST = ?) OR (t0.OHBID IN (?,?))) OR (t0.OHSID IN (?,?,?,?,?,?,?,?,?,?))) OR (t0.OHCID IN (?,?,?,?,?,?,?,?,?,?)))) AND (((t1.CUCID = t0.OHSID) AND (t1.CUCM = t0.OHCM)) AND ((t3.CUCID = t0.OHCID) AND (t3.CUCM = t0.OHCM)))) ORDER BY t0.OHOR# DESC) AS EL_TEMP) AS EL_TEMP2 WHERE EL_ROWNM <= ?) AS EL_TEMP3 WHERE EL_ROWNM > ?
I don't know how applyPagination breaks the ordering, but it might be more intuitive to use query.limit and query.offset here, since you are inside a repository method.
...
.orderBy(order.number.desc()).
.limit(pageSize)
.offset((page-1) * pageSize);

How can I make this big nasty query more efficient?

This is for a PostgreSQL database. I have a view where I am joining a table to itself 15 times to create what we call levels, from there I am doing a COALESCE function on the 'levels'- then a little manipulation on that field, as well. I am also pulling what is a description field for each of the 15 levels. This is where my query became sluggishly slow. I am joining the SETHEADERT table to the multiple levels to get the description field for each level. As you can see I only have 3 description fields and it is currently taking very long to run. When I had 2 it took a little bit but wasn't bad. I hope this makes sense. My code is below. Any help on how to make this more efficient is greatly appreciated.
SELECT
subset_cls,
prctr1,
CASE
WHEN prctr1 LIKE 'PC%' THEN split_part( overlay(prctr1 placing '00000' from 1 for 2 ),'.',1)
ELSE prctr1 end as pctrl2,
LVL01,
desc01,
LVL02,
desc02
FROM
( SELECT
SRC.SAP_SETNODE.SUBSET_CLS AS SUBSET_CLS,
SRC.SAP_SETHEADERT.DESCRIPTION AS desc01,
DESC_02.DESCRIPTION AS desc02,
DESC_03.DESCRIPTION AS desc03,
SRC.SAP_SETNODE.SET_NAME AS LVL01,
SRC.SAP_SETNODE.SUBSET_NAME AS LVL02,
SETNODE_1.SUBSET_NAME AS LVL03,
SETNODE_2.SUBSET_NAME AS LVL04,
SETNODE_3.SUBSET_NAME AS LVL05,
SETNODE_4.SUBSET_NAME AS LVL06,
SETNODE_5.SUBSET_NAME AS LVL07,
SETNODE_6.SUBSET_NAME AS LVL08,
SETNODE_7.SUBSET_NAME AS LVL09,
SETNODE_8.SUBSET_NAME AS LVL10,
SETNODE_9.SUBSET_NAME AS LVL11,
SETNODE_10.SUBSET_NAME AS LVL12,
SETNODE_11.SUBSET_NAME AS LVL13,
SETNODE_12.SUBSET_NAME AS LVL14,
SETNODE_13.SUBSET_NAME AS LVL15,
COALESCE(
SETNODE_13.SUBSET_NAME,
SETNODE_12.SUBSET_NAME,
SETNODE_11.SUBSET_NAME,
SETNODE_10.SUBSET_NAME,
SETNODE_9.SUBSET_NAME,
SETNODE_8.SUBSET_NAME,
SETNODE_7.SUBSET_NAME,
SETNODE_6.SUBSET_NAME,
SETNODE_5.SUBSET_NAME,
SETNODE_4.SUBSET_NAME,
SETNODE_3.SUBSET_NAME,
SETNODE_2.SUBSET_NAME,
SETNODE_1.SUBSET_NAME,
SRC.SAP_SETNODE.SUBSET_NAME,
SRC.SAP_SETNODE.SET_NAME)
AS prctr1
FROM SRC.SAP_SETNODE
LEFT JOIN SRC.SAP_SETHEADERT ON SRC.SAP_SETHEADERT.SET_NAME = SRC.SAP_SETNODE.SET_NAME
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_1 ON SRC.SAP_SETNODE.SUBSET_NAME = SETNODE_1.SET_NAME
AND SRC.SAP_SETNODE.SUBSET_CLS = SETNODE_1.SUBSET_CLS
LEFT JOIN SRC.SAP_SETHEADERT as DESC_02 ON DESC_02.SET_NAME = SETNODE_1.SET_NAME
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_2 ON SETNODE_1.SUBSET_NAME = SETNODE_2.SET_NAME
AND SETNODE_1.SUBSET_CLS = SETNODE_2.SUBSET_CLS
LEFT JOIN SRC.SAP_SETHEADERT as DESC_03 ON DESC_03.SET_NAME = SETNODE_2.SET_NAME
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_3 ON SETNODE_2.SUBSET_NAME = SETNODE_3.SET_NAME
AND SETNODE_2.SUBSET_CLS = SETNODE_3.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_4 ON SETNODE_3.SUBSET_NAME = SETNODE_4.SET_NAME
AND SETNODE_3.SUBSET_CLS = SETNODE_4.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_5 ON SETNODE_4.SUBSET_NAME = SETNODE_5.SET_NAME
AND SETNODE_4.SUBSET_CLS = SETNODE_5.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_6 ON SETNODE_5.SUBSET_NAME = SETNODE_6.SET_NAME
AND SETNODE_5.SUBSET_CLS = SETNODE_6.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_7 ON SETNODE_6.SUBSET_NAME = SETNODE_7.SET_NAME
AND SETNODE_6.SUBSET_CLS = SETNODE_7.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_8 ON SETNODE_7.SUBSET_NAME = SETNODE_8.SET_NAME
AND SETNODE_7.SUBSET_CLS = SETNODE_8.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_9 ON SETNODE_8.SUBSET_NAME = SETNODE_9.SET_NAME
AND SETNODE_8.SUBSET_CLS = SETNODE_9.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_10 ON SETNODE_9.SUBSET_NAME = SETNODE_10.SET_NAME
AND SETNODE_9.SUBSET_CLS = SETNODE_10.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_11 ON SETNODE_10.SUBSET_NAME = SETNODE_11.SET_NAME
AND SETNODE_10.SUBSET_CLS = SETNODE_11.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_12 ON SETNODE_11.SUBSET_NAME = SETNODE_12.SET_NAME
AND SETNODE_11.SUBSET_CLS = SETNODE_12.SUBSET_CLS
LEFT JOIN SRC.SAP_SETNODE AS SETNODE_13 ON SETNODE_12.SUBSET_NAME = SETNODE_13.SET_NAME
AND SETNODE_12.SUBSET_CLS = SETNODE_13.SUBSET_CLS
GROUP BY SRC.SAP_SETNODE.SUBSET_CLS, SRC.SAP_SETHEADERT.DESCRIPTION, DESC_02.DESCRIPTION,
DESC_03.DESCRIPTION, SRC.SAP_SETNODE.SET_NAME,
SRC.SAP_SETNODE.SUBSET_NAME, SETNODE_1.SUBSET_NAME, SETNODE_2.SUBSET_NAME,
SETNODE_3.SUBSET_NAME, SETNODE_4.SUBSET_NAME, SETNODE_5.SUBSET_NAME,
SETNODE_6.SUBSET_NAME, SETNODE_7.SUBSET_NAME, SETNODE_8.SUBSET_NAME,
SETNODE_9.SUBSET_NAME, SETNODE_10.SUBSET_NAME, SETNODE_11.SUBSET_NAME,
SETNODE_12.SUBSET_NAME, SETNODE_13.SUBSET_NAME
HAVING SRC.SAP_SETNODE.SUBSET_CLS='0101' AND SRC.SAP_SETNODE.SET_NAME='SISW.'
||get_fy_part('YEAR', clock_timestamp())
ORDER BY SRC.SAP_SETNODE.SET_NAME, SRC.SAP_SETNODE.SUBSET_NAME, SETNODE_1.SUBSET_NAME,
SETNODE_2.SUBSET_NAME, SETNODE_3.SUBSET_NAME, SETNODE_4.SUBSET_NAME, SETNODE_5.SUBSET_NAME,
SETNODE_6.SUBSET_NAME, SETNODE_7.SUBSET_NAME
) foo
If you move the filtering to the where clause there will be less rows to be joined. Change this:
group by ...
HAVING
SRC.SAP_SETNODE.SUBSET_CLS = '0101' AND
SRC.SAP_SETNODE.SET_NAME = 'SISW.' || get_fy_part('YEAR', clock_timestamp())
to
where
SRC.SAP_SETNODE.SUBSET_CLS = '0101' AND
SRC.SAP_SETNODE.SET_NAME = 'SISW.' || get_fy_part('YEAR', clock_timestamp())
group by ...

Parameters in NamedQuery

I am working with JSF 2.0, Primefaces 3.4, Oracle, NetBeans 7.2.1, and i got the following error:
ADVERTENCIA: Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00936: missing expression
Error Code: 936
Call: SELECT t1.OPT_ID, t1.OPT_ANT_FM_DET FROM SAE_PACIENTE t0, SAE_OPTOMETRIA t1 WHERE ((((t0.P_ID = ) AND (t0.P_IDENTIFICACION = ?)) AND (t0.P_TIPO_IDENTIFICACION = ?)) AND (t0.P_ID = t1.OPT_P_ID))
i have two beans SaeOptometria and SaePaciente; in SaeOPtometria i have this atribute that is the relationship with the SaePaciente bean:
#JoinColumn(name = "OPT_P_ID", referencedColumnName = "P_ID")
#ManyToOne
private SaePaciente optPId;
And also have the following namedquery:
#NamedQuery(name = "SaeOptometria.findByPaciente", query = "SELECT s FROM SaeOptometria s INNER JOIN s.optPId d WHERE d.pId=s.optPId AND d.pIdentificacion = :pIdentificacion AND d.pTipoIdentificacion = :pTIdentificacion"),
I am passing the parameters :pIdentificacion and :pTIdentificacion in the SaeOptometriaFacade file with the following code:
public List<SaeOptometria> consultaporIdYTI(String UIpIdentificacion, String UIpTipoIdentificacion){
Query query= em.createNamedQuery("SaeOptometria.findByPaciente");
query.setParameter("pIdentificacion", UIpIdentificacion);
query.setParameter("pTIdentificacion", UIpTipoIdentificacion);
List<SaeOptometria> SaeOptometriaList= query.getResultList();
return SaeOptometriaList;
}
I clarified that the parameters pIdentificacion and pTipoIdentificacion in the NamedQuery belong to SaePaciente bean:
#Id
#SequenceGenerator(name="SEQ1",sequenceName = "SAE_AINCR_PACIENTE",allocationSize=1)
#GeneratedValue(strategy=GenerationType.IDENTITY, generator="SEQ1")
#Basic(optional = false)
#NotNull
#Column(name = "P_ID")
private Integer pId;
#Size(max = 15)
#Column(name = "P_IDENTIFICACION")
private String pIdentificacion;
#Size(max = 20)
#Column(name = "P_TIPO_IDENTIFICACION")
private String pTipoIdentificacion;
why doesnt work?
thanks.
Your query seems wrong:
SELECT s FROM SaeOptometria s INNER JOIN s.optPId d WHERE d.pId=s.optPId AND d.pIdentificacion = :pIdentificacion AND d.pTipoIdentificacion = :pTIdentificacion
FROM SaeOptometria s INNER JOIN TO_WHAT
After your comment, I decided that my first understanding is wrong.
You both join in FROM clause and in the from WHERE clause. Try to do only one of them.
Can you try following queries and report results:
First one: Join is provided by JPA. No explicitly providing Ids. This information should be given in your JPA mapping
SELECT s FROM SaeOptometria s INNER JOIN s.optPId d WHERE d.pIdentificacion = :pIdentificacion AND d.pTipoIdentificacion = :pTIdentificacion
Second one: you join explicitly. We give tables and join giving ID values explicitly.
SELECT s FROM SaeOptometria s WHERE s.optPId.pId=s.optPId and s.optPId.pIdentificacion = :pIdentificacion AND s.optPId.pTipoIdentificacion = :pTIdentificacion

Resources