这是相关异常代码:
javax.servlet.ServletException: java.lang.NullPointerException
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
root cause
java.lang.NullPointerException
org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
org.hibernate.type.EntityType.resolve(EntityType.java:303)
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
org.hibernate.loader.Loader.doQuery(Loader.java:717)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.doList(Loader.java:2145)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:849)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:832)
com.song.dao.AlbumDAO.findAllByUser(AlbumDAO.java:65)
com.song.service.AlbumService.findAllAlbum(AlbumService.java:90)
com.song.action.AlbumAction.findAllAlbum(AlbumAction.java:130)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
在实现类中是的代码:
public List findAllByUser(int userId){
log.debug("find all album instance");
try{
String hql = "from Album as a where a.user.userId="+userId;
//System.out.println(hql);
List result = this.getHibernateTemplate().find(hql);
System.out.println(result);
return result;
}catch(RuntimeException re){
log.error("find all Album error", re);
throw re;
}
}
求解决啊。。。。。
ssh
public List findAllByUser(int userId){
log.debug("find all album instance");
try{
String hql = "from Album as a where a.user.userId="+userId;
//System.out.println(hql);
List result = this.getHibernateTemplate().find(hql);