-->
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: About Distinct using DetachedCriteria in Hibernate
PostPosted: Thu Jun 10, 2010 3:41 am 
Newbie

Joined: Thu Jun 10, 2010 3:08 am
Posts: 1
Can any solve this problem ? if possible plz give reply to me.

The problem is as follows:

I got a problem whenever i am using this query ,

DetachedCriteria query = DetachedCriteria.forClass(GoodsReturned.class)
.add(Property.forName("returnedDate").between(cal1.getTime(), cal2.getTime()))
.setProjection(Projections.distinct(Property.forName("GRTNo")));

List<GoodsReturned> results = (getHibernateTemplate().findByCriteria(query)); // Upto here it is working fine

for(GoodsReturned goodsReturned : results){ // But When iterating it is showing error the error i displayed as follows
System.out.println(" "+goodsReturned.getGRTNo());
}

whenever i am executing this query i am getting runtime error as follows:

java.lang.ClassCastException: java.lang.String cannot be cast to com.bcs.inv.dom
ain.purchase.GoodsReturned
at com.bcs.inv.service.purchase.PurchaseMgmtServiceImpl.findAllGoodsRetu
rnViewsByDate(PurchaseMgmtServiceImpl.java:2689)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
on(AopUtils.java:281)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:199)
at $Proxy25.findAllGoodsReturnViewsByDate(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.xfire.service.invoker.AbstractInvoker.invoke(AbstractInv
oker.java:54)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.sendMessa
ge(ServiceInvocationHandler.java:271)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler$1.run(Ser
viceInvocationHandler.java:84)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.execute(S
erviceInvocationHandler.java:132)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.invoke(Se
rviceInvocationHandler.java:107)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.jav
a:131)
at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoin
t.java:64)
at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.
java:38)
at org.codehaus.xfire.transport.http.XFireServletController.invoke(XFire
ServletController.java:301)
at org.codehaus.xfire.transport.http.XFireServletController.doService(XF
ireServletController.java:130)
at org.codehaus.xfire.spring.remoting.XFireServletControllerAdapter.hand
leRequest(XFireServletControllerAdapter.java:67)
at org.codehaus.xfire.spring.remoting.XFireExporter.handleRequest(XFireE
xporter.java:48)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.ha
ndle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(Dispatch
erServlet.java:820)
at org.springframework.web.servlet.DispatcherServlet.doService(Dispatche
rServlet.java:755)
at org.springframework.web.servlet.FrameworkServlet.processRequest(Frame
workServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServ
let.java:360)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at com.bcs.trs.domain.exceptions.ExceptionFilter.doFilter(ExceptionFilte
r.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:48
9)
at java.lang.Thread.run(Thread.java:619)


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.