Здравствуйте, выскакивает эта ошибка, не пойму почему.
public Country getCountry(int id) {
Session session = this.sessionFactory.getCurrentSession();
Country country = (Country) session.get(Country.class, id);
return country;
}
вот Контроллер которым вызываю
@RequestMapping(value = "/getCountry/{id}", method = RequestMethod.GET, headers = "Accept=application/json")
public Country getCountryById(@PathVariable int id) {
return countryService.getCountry(id);
}
Помогите понять в чем проблема. Stack Trace:
java.lang.ClassCastException: org.hibernate.internal.QueryImpl cannot be cast to org.arpit.java2blog.model.Country
at org.arpit.java2blog.dao.CountryDAO.getCountry(CountryDAO.java:32)
at org.arpit.java2blog.service.CountryService.getCountry(CountryService.java:23)
at org.arpit.java2blog.service.CountryService$$FastClassBySpringCGLIB$$cc30a22.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
at org.arpit.java2blog.service.CountryService$$EnhancerBySpringCGLIB$$faa92f2c.getCountry(<generated>)
at org.arpit.java2blog.controller.CountryController.getCountryById(CountryController.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)