此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【toraji】截止到2008-07-02 22:24:57的历史汇总数据(不包括此帖):
发帖的总数量:2 发帖的总分数:50
结贴的总数量:2 结贴的总分数:50
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
楼主【toraji】截止到2008-07-02 22:24:57的历史汇总数据(不包括此帖):
发帖的总数量:2 发帖的总分数:50
结贴的总数量:2 结贴的总分数:50
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
解决方案 »
- 怎么定义前台和后台?
- JAVA监听端口?
- 如何实现JAVA窗口的右下角出现
- tomcat的问题!急
- 请问个relationship和事务的问题
- 有光驱的朋友 ,访问一下这个连接 http://202.114.65.66/~zwxia/cdromeject.jpg,它会将你的光驱自动弹出来??有谁知道这是怎么来实现的
- jB7中,中文显示问题(在linux下)
- 我的j2ee(j2ee1.3+jdk1.3)中为何不能用session,cookie
- 大虾请指导EJB问题
- 有关 Mybatis 和 SpringJdbc 一些的问题
- Spring + hib ,为什么c3p0不自动释放连接,导致系统当机?
- 关于求职公司的问题
public Example{
private Integer id; private Knowledge knowledge;
......(get和set方法)
}那么查询Example的同时,查出和Example关联的knowledge如下:from Example e inner join fetch e.knowledge如果有多个就继续加 inner join fetch e.xxx
如:
from Example e inner join fetch e.knowledge inner join fetch e.xxx
章节:chapter(chid,chname,ch_cid)
知识点: knowledge(kid ,kname,k_chid)
知识点示例:example(eid,econtent,e_kid) 现在知道了某个示例的编号(eid=1),如何编写语句,得到知识点名、章节名、课程名? 比如要查知识点名,需要单独查到知识点bean对象,然后set到示例bean中吗(Example的bean中包含有知识点bean属性)? 根据示例id 获取示例对象 exa
exa.getKowlodge().getKname() 知识点名
exa.getKowlodge().getChapter().getChname() 章节名
以下是我的代码,根据课程编号获得所有章节的知识点的所有问题:
public List getAllQuestionByCid(int cid) {
Session session = super.getSession();
try {
String sql = "from Question as q inner join fetch q.users "+
"where q.knowledge.kid in( "+
"select k.kid from Knowledge as k "+
"where k.chapter.chid in( "+
"select ch.chid from Chapter as ch "+
"where ch.course.cid=?)) ";
Query q = session.createQuery(sql);
q.setInteger(0, cid);
return q.list();
}catch(Exception e) {
e.printStackTrace();
}finally {
session.close();
}
return null;
}
运行报错。
严重: Servlet.service() for servlet jsp threw exception
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:60)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at org.svse.entity.Users$$EnhancerByC..........................
这是什么问题??
sql语句写错了吗?
延迟加载问题还是以Example和Knowledge为例
查询时用 from Example ,然后关闭session,再然后取Knowledge的值,就会出现这种情况我知道的解决办法有两种:
1、配置文件里设置属性 fetch="join"
2、像我上面写的 inner join fetch ...
刚才试了一下
对hbm.xml的lazy的配置没有改变,因为我还没看这方面的资料
我写了代码如下
目的是要根据问题的编号,把提问人、问题所有回复 都找出来
from Question as q inner join fetch q.users left outer join fetch q.answers where q.qid=?
这样的话没有任何问题,页面正常显示但是,如果我想把对应的回复人也找出来,所以加了一点代码
from Question as q inner join fetch q.users left outer join fetch q.answers inner join q.answers.users where q.qid=?结果报错,如下.org.hibernate.QueryException: illegal attempt to dereference collection [question0_.qid.answers] with element property reference [users] [from org.svse.entity.Question as q inner join fetch q.users left outer join fetch q.answers inner join q.answers.users where q.qid=?]
at org.hibernate.hql.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:46)
a
这是什么问题呢?