关于hibernate联级操作的问题,我建了三张表:blog(博文信息),category(博文分类),users(博主信息),毫无疑问,blog——>users是多对一的关系,category——>blog是一对多的关系,主外键弄好后,我在.hbm.xml文件里配置了双向一对多关联,
可是我在查询blog表信息的时候,出来的只有 这几条查询语句:
ibernate: select top 10 blog0_.id as id0_, blog0_.title as title0_, blog0_.contents as contents0_, blog0_.readcount as readcount0_, blog0_.create_time as create5_0_, blog0_.user_id as user6_0_, blog0_.category_id as category7_0_ from webblog.dbo.blog blog0_ order by blog0_.create_time desc
Hibernate: select category0_.id as id1_0_, category0_.name as name1_0_ from webblog.dbo.category category0_ where category0_.id=?
Hibernate: select category0_.id as id1_0_, category0_.name as name1_0_ from webblog.dbo.category category0_ where category0_.id=?
Hibernate: select category0_.id as id1_0_, category0_.name as name1_0_ from webblog.dbo.category category0_ where category0_.id=?没有users表的查询内容,为什么呢,还有一个问题就是我将查询出来的一个List集合存入session 的时候竟然没存进去(我在页面显示时调用session里存的集合为空,打断点看过,也为空)很郁闷,
高手啊,高手,来帮帮忙咯,感谢了,感激了,加我qq735948069

解决方案 »

  1.   

    1、blog中把User设成懒加载了吧?
    2、session中集合为空。就放先没一下list是否为空。再测一下session对象是否为空
      

  2.   

    没有 User.hbm.xml里:
     <set name="blogs" inverse="false" cascade="all" lazy="true">
             <key column="user_id" />
             <one-to-many class="edu.myblog.ssh.entity.Blog"/>
      </set>我打断点测试过,List集合里是有对象的,但放入session后,转入页面显示的时候,session里取出的对象为空,你qq多少,我加你,我们再讨论下把
      

  3.   

    session存放的是引用。你是否在存入session以后,对list还做过操作,使list=null了,或者是事务失败回滚所致?楼主给出的信息太少,要多帖点代码。