-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to use filters and bind list to the session - namedQuery
PostPosted: Thu Sep 18, 2008 2:12 pm 
Newbie

Joined: Fri Dec 07, 2007 4:25 pm
Posts: 6
HIi all,
i want to use a filter so i added the filter def and the filter and set the parameter value as below.
but i am confused as if i apply the filter and then query using the hibernate template then the filter criteria is never applied.
Code:
Session session = getSession();
session.enableFilter("insertDateFilter").setParameter("insertDate", beginDate);

invoiceList.addAll(getHibernateTemplate().findByNamedQueryAndNamedParam("InvoiceForRebateBySeqId", "list", subList));



so to avoid doing that (considering hibernate do not understand the filter when queried using the template)
i changed the code in folowing way

Code:
Session session = getSession();
session.enableFilter("insertDateFilter").setParameter("insertDate", beginDate);
invoiceList.addAll(session.getNamedQuery("InvoiceForRebateBySeqId").setParameterList("list", new Object[]{subList}).list());


now here the problem is the subList parameter which is a list of long Ids is not recognized by hibernate and it thorows folowing exception

Code:

2008-09-18 12:45:23,849 [http-8090-1] DEBUG org.hibernate.jdbc.ConnectionManager  - opening JDBC connection
2008-09-18 12:45:23,864 [http-8090-1] DEBUG org.hibernate.SQL  - select invoice0_.ODS_CP_INV_TRAN_SEQID as ODS1_1_, invoice0_.ODS_CP_SEQID as ODS2_1_, invoice0_.BILL_TO_SEQID as BILL3_1_, invoice0_.SHP_TO_SEQID as SHP4_1_, invoice0_.SLD_TO_SEQID as SLD5_1_, invoice0_.INV_NUM as INV6_1_, invoice0_.INV_DT as INV7_1_, invoice0_.INSRT_DT as INSRT8_1_, invoice0_.INV_EXT_PRC_AMT as INV9_1_, invoice0_.INV_EXT_PRC_CRNCY_TYP_CD as INV10_1_, invoice0_.INV_TTL_AMT as INV11_1_, invoice0_.BS_CRNCY_TYP_CD as BS12_1_, invoice0_.INV_TTL_CHG_AMT as INV13_1_, invoice0_.INV_TTL_TAX_AMT as INV14_1_, invoice0_.INV_TYP_CD as INV15_1_, invoice0_.MKTG_PRGM_TYP_CD as MKTG16_1_, invoice0_.SHPMT_MTHD_TYP_CD as SHPMT17_1_, invoice0_.PMT_DESC_LANG_TYP_CD as PMT18_1_, invoice0_.PMT_DUE_DT as PMT19_1_, invoice0_.PMT_MTHD_CD_TXT as PMT20_1_, invoice0_.PMT_MTHD_DESC_TXT as PMT21_1_, invoice0_.SLS_ODR_DT as SLS22_1_, invoice0_.SLS_ODR_NUM as SLS23_1_, invoice0_.TXBL_FLG as TXBL24_1_, invoice0_.BOD_ID as BOD25_1_ from ODS.CP_INV_TRAN_HDR invoice0_ where (invoice0_.ODS_CP_INV_TRAN_SEQID in (?)) and (select channelpar1_.SHP_TO_CUST_TYP_CD from ODS.CP_SHP_TO_CUST channelpar1_, ODS.CHNL_PRTNR channelpar2_, ODS.CHNL_PRTNR_PRTY partnerpar3_, ODS.CHNL_PRTNR_PRTY partnerpar5_ where invoice0_.ODS_CP_SEQID=channelpar2_.ODS_CP_SEQID and invoice0_.SLD_TO_SEQID=partnerpar3_.ODS_CP_PRTY_SEQID and invoice0_.SHP_TO_SEQID=partnerpar5_.ODS_CP_PRTY_SEQID and channelpar1_.CHNL_PRTNR_ID=channelpar2_.CP_ID and channelpar1_.CP_SLD_TO_ID=partnerpar3_.CP_PRTY_ID and channelpar1_.CP_SLD_TO_CUST_NM=partnerpar3_.CP_PRTY_NM and channelpar1_.CP_SHP_TO_ID=partnerpar5_.CP_PRTY_ID and channelpar1_.CP_SHP_TO_NM=partnerpar5_.CP_PRTY_NM)<>'Non-Revenue' order by invoice0_.ODS_CP_INV_TRAN_SEQID
2008-09-18 12:45:23,880 [http-8090-1] INFO  org.hibernate.type.LongType  - could not bind value '[26936310, 26936520, 26950060, 26950070, 26950080, 26950090, 26950130, 26950140, 26950150, 26950180, 26950190, 26950200, 26950210, 26950230, 26950240, 26950260, 26950270, 26950290, 26950300, 26950320, 26950330, 26950350, 26950360, 26950370, 26950380, 26950390, 26950410, 26950420, 26950440, 26950460, 26950470, 26950480, 26950500, 26950520, 26950540, 26950550, 26950560, 26950570, 26950580, 26950590, 26950600, 26950610, 26950620, 26950650, 26950660, 26950680, 26950690, 26950720, 26950730, 26950740, 26950750, 26950760, 26950770, 26950780, 26950790, 26950810, 26950820, 26950830, 26950840, 26950850, 26950860, 26950870, 26950880, 26950900, 26950910, 26950920, 26950930, 26950940, 26950950, 26950960, 26950980, 26950990, 26951000, 26951010, 26951020, 26951030, 26951040, 26951050, 26951060, 26951070, 26951080, 26951090, 26951100, 26951110, 26951120, 26951130, 26951140, 26951150, 26951170, 26951180, 26951200, 26951210, 26951220, 26951230, 26951240, 26951250, 26951260, 26951270, 26951280, 26951290, 26951310, 26951320, 26951330, 26951340, 26951360, 26951370, 26951380, 26951390, 26951400, 26951410, 26951420, 26951430, 26951440, 26951450, 26951460, 26951470, 26951480, 26951490, 26951500, 26951510, 26951520, 26951530, 26951540, 26951550, 26951560, 26951570, 26951580, 26951590, 26951600, 26951610, 26951620, 26951630, 26951640, 26951650, 26951660, 26951670, 26951680, 26951690, 26951700, 26951710, 26951720, 26951730, 26951740, 26951750, 26951760, 26952140, 26952150, 26952160, 26952170, 26952180, 26952190, 26952200, 26952210, 26952220, 26952230, 26952240, 26952250, 26952260, 26952270, 26952280, 26952290, 26952300, 26952320, 26952330, 26952340, 26952370, 26952380, 26952390, 26952550, 26952600, 26952620, 26952640, 26952660, 26952680, 26952700, 26952720, 26952730, 26952750, 26952940, 26952950, 26952970, 26953020, 26953050, 26953090, 26953110, 26953130, 26953150, 26953170, 26953190, 26953240, 26953260, 26953280, 26953320, 26953340, 26953350, 26953360, 26953370, 26953380, 26953400, 26953410, 26953420, 26953430, 26953440, 26953450, 26953460, 26953470, 26953490, 26953510, 26953520, 26953530, 26953550, 26953560, 26953570, 26953580, 26953590, 26953600, 26953610, 26953620, 26953640, 26953650, 26953660, 26953670, 26953680, 26953690, 26953700, 26953710, 26953720, 26953730, 26953740, 26953750, 26953760, 26953770, 26953780, 26953790, 26953800, 26953810, 26953820, 26953830, 26953840, 26953850, 26953860, 26953870, 26953880, 26953890, 26953900, 26953910, 26953920, 26953930, 26953950, 26953960, 26953970, 26953980, 26953990, 26954000, 26954010, 26954020, 26954030, 26954040, 26954070, 26954090, 26954100, 26954110, 26954120, 26954140, 26954180, 26954190, 26954210, 26954260, 26954280, 26954290, 26954300, 26954310, 26954320, 26954330, 26954350, 26954360, 26954370, 26954380, 26954390, 26954400, 26954410, 26954420, 26954430, 26954440, 26954450, 26954500, 26954510, 26954520, 26954530, 26954540, 26954550, 26954560, 26954570, 26954580, 26954590, 26954600, 26954610, 26954630, 26954650, 26954670, 26954690, 26954700, 26954720, 26954740, 26954750, 26954760, 26954770, 26954780, 26954790, 26954800, 26954810, 26954820, 26954830, 26954860, 26954880, 26954900, 26954910, 26954920, 26954930, 26954940, 26954950, 26954960, 26954970, 26954980, 26954990, 26955000, 26955010, 26955020, 26955030, 26955050, 26955060, 26955070, 26955080, 26955090, 26955100, 26955110, 26955120, 26955130, 26955140, 26955160, 26955170, 26955180, 26955190, 26955200, 26955210, 26955220, 26956190, 26956730, 26956790, 26956800, 26956810, 26956820, 26956830, 26956840, 26956850, 26956870, 26956880, 26956890, 26956900, 26956910, 26956920, 26956930, 26956940, 26956950, 26956960]' to parameter: 1; java.util.RandomAccessSubList cannot be cast to java.lang.Long
2008-09-18 12:45:23,880 [http-8090-1] INFO  org.hibernate.type.LongType  - could not bind value '[26936310, 26936520, 26950060, 26950070, 26950080, 26950090, 26950130, 26950140, 26950150, 26950180, 26950190, 26950200, 26950210, 26950230, 26950240, 26950260, 26950270, 26950290, 26950300, 26950320, 26950330, 26950350, 26950360, 26950370, 26950380, 26950390, 26950410, 26950420, 26950440, 26950460, 26950470, 26950480, 26950500, 26950520, 26950540, 26950550, 26950560, 26950570, 26950580, 26950590, 26950600, 26950610, 26950620, 26950650, 26950660, 26950680, 26950690, 26950720, 26950730, 26950740, 26950750, 26950760, 26950770, 26950780, 26950790, 26950810, 26950820, 26950830, 26950840, 26950850, 26950860, 26950870, 26950880, 26950900, 26950910, 26950920, 26950930, 26950940, 26950950, 26950960, 26950980, 26950990, 26951000, 26951010, 26951020, 26951030, 26951040, 26951050, 26951060, 26951070, 26951080, 26951090, 26951100, 26951110, 26951120, 26951130, 26951140, 26951150, 26951170, 26951180, 26951200, 26951210, 26951220, 26951230, 26951240, 26951250, 26951260, 26951270, 26951280, 26951290, 26951310, 26951320, 26951330, 26951340, 26951360, 26951370, 26951380, 26951390, 26951400, 26951410, 26951420, 26951430, 26951440, 26951450, 26951460, 26951470, 26951480, 26951490, 26951500, 26951510, 26951520, 26951530, 26951540, 26951550, 26951560, 26951570, 26951580, 26951590, 26951600, 26951610, 26951620, 26951630, 26951640, 26951650, 26951660, 26951670, 26951680, 26951690, 26951700, 26951710, 26951720, 26951730, 26951740, 26951750, 26951760, 26952140, 26952150, 26952160, 26952170, 26952180, 26952190, 26952200, 26952210, 26952220, 26952230, 26952240, 26952250, 26952260, 26952270, 26952280, 26952290, 26952300, 26952320, 26952330, 26952340, 26952370, 26952380, 26952390, 26952550, 26952600, 26952620, 26952640, 26952660, 26952680, 26952700, 26952720, 26952730, 26952750, 26952940, 26952950, 26952970, 26953020, 26953050, 26953090, 26953110, 26953130, 26953150, 26953170, 26953190, 26953240, 26953260, 26953280, 26953320, 26953340, 26953350, 26953360, 26953370, 26953380, 26953400, 26953410, 26953420, 26953430, 26953440, 26953450, 26953460, 26953470, 26953490, 26953510, 26953520, 26953530, 26953550, 26953560, 26953570, 26953580, 26953590, 26953600, 26953610, 26953620, 26953640, 26953650, 26953660, 26953670, 26953680, 26953690, 26953700, 26953710, 26953720, 26953730, 26953740, 26953750, 26953760, 26953770, 26953780, 26953790, 26953800, 26953810, 26953820, 26953830, 26953840, 26953850, 26953860, 26953870, 26953880, 26953890, 26953900, 26953910, 26953920, 26953930, 26953950, 26953960, 26953970, 26953980, 26953990, 26954000, 26954010, 26954020, 26954030, 26954040, 26954070, 26954090, 26954100, 26954110, 26954120, 26954140, 26954180, 26954190, 26954210, 26954260, 26954280, 26954290, 26954300, 26954310, 26954320, 26954330, 26954350, 26954360, 26954370, 26954380, 26954390, 26954400, 26954410, 26954420, 26954430, 26954440, 26954450, 26954500, 26954510, 26954520, 26954530, 26954540, 26954550, 26954560, 26954570, 26954580, 26954590, 26954600, 26954610, 26954630, 26954650, 26954670, 26954690, 26954700, 26954720, 26954740, 26954750, 26954760, 26954770, 26954780, 26954790, 26954800, 26954810, 26954820, 26954830, 26954860, 26954880, 26954900, 26954910, 26954920, 26954930, 26954940, 26954950, 26954960, 26954970, 26954980, 26954990, 26955000, 26955010, 26955020, 26955030, 26955050, 26955060, 26955070, 26955080, 26955090, 26955100, 26955110, 26955120, 26955130, 26955140, 26955160, 26955170, 26955180, 26955190, 26955200, 26955210, 26955220, 26956190, 26956730, 26956790, 26956800, 26956810, 26956820, 26956830, 26956840, 26956850, 26956870, 26956880, 26956890, 26956900, 26956910, 26956920, 26956930, 26956940, 26956950, 26956960]' to parameter: 1; java.util.RandomAccessSubList cannot be cast to java.lang.Long
2008-09-18 12:45:23,895 [http-8090-1] DEBUG org.hibernate.jdbc.ConnectionManager  - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
2008-09-18 12:45:28,411 [http-8090-1] ERROR com.toro.service.invoice.dao.InvoiceDaoImpl  - There was an error retreiving invoices from DB
java.lang.ClassCastException: java.util.RandomAccessSubList cannot be cast to java.lang.Long
   at org.hibernate.type.LongType.set(LongType.java:42)
   at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
   at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
   at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:38)
   at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:503)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1554)
   at org.hibernate.loader.Loader.doQuery(Loader.java:661)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
   at org.hibernate.loader.Loader.doList(Loader.java:2211)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
   at org.hibernate.loader.Loader.list(Loader.java:2090)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
   at com.toro.service.invoice.dao.InvoiceDaoImpl.retrieveToroInvoicesByDateRange(InvoiceDaoImpl.java:67)
   at com.toro.service.invoice.InvoiceServiceImpl.retrieveToroInvoicesByDateRange(InvoiceServiceImpl.java:227)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.axis2.receivers.RawXMLINOutMessageReceiver.invokeBusinessLogic(RawXMLINOutMessageReceiver.java:97)
   at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)
   at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
   at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
   at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
   at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)


i dont understand how do i bind the list to the query.
I even tried using the
public Query setParameter(String name, Object val)
method inplace of the setParameterList but no luck.
can anybody help me here?

thanks
sush


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.