爱吃青草的牛 2009-06-17 17:33
浏览 201
已采纳

ssh的一个问题 配置了多对一关联getHibernateTemplate为空

是这样的,加了配置关联关系出现异常信息,把关联关系删除了就没有了异常信息。
我用ssh的时候我有个
产品表实体映射文件,配置与产品类别了多对一,
下面是产品配置关联
[code="java"]
column="typeId"
class="com.wxb.cniny.product.model.ProtypeEntity">

[/code]
产品类别
[code="java"]





[/code]
dao类
[code="java"]
public List list(String hql) {
// TODO Auto-generated method stub
List list=null;
try{
list = getHibernateTemplate().find(hql);//配置关联关系出现null引用
logger.debug("ssuccess");
}catch(Exception e){
e.printStackTrace();
logger.error("select fail", e);
}
return list;
}[/code]
红色那出现了
NullPointerException:
信息如下:
Hibernate: select this_.proId as proId5_0_, this_.proName as proName5_0_, this_.price as price5_0_, this_.proImagepath as proImage4_5_0_, this_.proRemark as proRemark5_0_, this_.useMethod as useMethod5_0_, this_.producExcet as producEx7_5_0_, this_.facade as facade5_0_, this_.odor as odor5_0_, this_.PHValue as PHValue5_0_, this_.specific gravity as specific11_5_0_, this_.boiling point as boiling12_5_0_, this_.solubility index as solubility13_5_0_, this_.productInfo as product14_5_0_, this_.Packsize as Packsize5_0_, this_.fixedYear as fixedYear5_0_, this_.typeId as typeId5_0_ from kyldb.productinfo this_
2009-6-17 16:11:15 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.wxb.comm.impl.ComDAOImpl.createCriteria(ComDAOImpl.java:176)
at com.wxb.cniny.product.dao.impl.ProductDAOImpl.getAllRowCount(ProductDAOImpl.java:52)
at com.wxb.cniny.product.service.impl.ProductServiceImpl.queryForPage(ProductServiceImpl.java:40)
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:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:139)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy5.queryForPage(Unknown Source)
at com.wxb.struts.action.ProductAction.doGetAll(ProductAction.java:114)
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:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
....
我把配置的关联关系删除了,就不会出现问题。请问这是怎么回事?
[b]问题补充:[/b]
lazy="false"也试过,还是不行。
这是hql语句,String hql = " from ProductEntity";

  • 写回答

4条回答 默认 最新

  • wanghaolovezlq 2009-06-17 17:38
    关注

    我估计应该是你执行的hql被lazy="true"影响到了
    改成lazy="false"试看看

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程