查询时出现错误
Spring+Hibernate+Struts在进行数据查找时出现的错误
org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException
(1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [$Proxy1] to required type [com.boyasi.service.MovieMonthService]
for property 'movieMonthService']
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:670)
at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:642)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1023)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:824)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:345)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:151)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:559)
at org.springframework.web.struts.DelegatingActionProxy.getDelegateAction(DelegatingActionProxy.java:122)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:105)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:99)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:259)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:363)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:490)
at com.caucho.util.ThreadPool.run(ThreadPool.java:423)
at java.lang.Thread.run(Thread.java:595)
MovieMonthServiceImp.java
public MovieMonth findMoveMonthByUserId(int userId) {
return this.getMovieMonthDAO().findMoveMonthByUserId(userId);
}
MovieMonthHibernateDAO.java
private static final String LOAD_BY_USERID ="from movie_Month where userID = ?";
/**
* 默认构造函数
*/
public MovieMonthHibernateDAO(){
super();
}
/**
* 根据UserId查找MoveMonth对象
* @param userId
* @return MovieMonth
*/
public MovieMonth findMoveMonthByUserId(int userId) {
Object[] o = {new Integer(userId)};
List l = this.getHibernateTemplate().find(LOAD_BY_USERID,o);
if(l == null || l.isEmpty()){
return null;
}else{
return (MovieMonth) l.get(0);
}
}