【问题标题】:lazy fetching problem偷懒问题
【发布时间】:2011-05-25 18:32:39
【问题描述】:

我遇到了延迟获取的问题。这就是我所拥有的。我有一个名为通道的实体类。和另一个名为 show 的实体类。每个频道都有很多节目。我已经通过延迟获取实现了休眠。但是问题是,当我从数据库中获取一个频道并尝试访问程序列表时,我得到了一个 nullpointerException。 这是一些代码:

 telekanalService.findAllTelekanal(new AsyncCallback<List<Telekanal>>() {
          public void onFailure(Throwable caught) {
            // Show the RPC error message to the user
           errorLabel.setText(caught.getMessage());

          }

      public void onSuccess(List<Telekanal> result) {
       //Programm tel = result.get(1);
       List<Programm> prog = result.get(0).getProgrammid(); //problem with this
       //Telekanal tell = tel.getTelekanal();
       errorLabel.setText("tehtud:" + prog.size()); //returns Nullpointerexception
      }
});

也许我有一些映射错误,这是我的映射文件 Programm.hbm.xml:http://pastebin.com/Q639HreT Telekanal.hbm.xml:http://pastebin.com/4c3h0fZj 程序班:http://pastebin.com/ws57uGg2 电话班:http://pastebin.com/MZB7KgT1 或者我的 sql 设置有问题:http://pastebin.com/AVBM8882 而且我正在使用 opensessioninview 来保持会话打开 My code 真心希望有人能帮忙

【问题讨论】:

    标签: java hibernate spring lazy-evaluation


    【解决方案1】:
    <list name="programmid" inverse="false" table="programm" lazy="true">
        <key>
            <column name="t_id" />
        </key>
        <list-index></list-index>
        <one-to-many class="com.tvkava.shared.model.Programm" />
    </list>
    

    不应该声明一个空的list-index 导致错误吗?我不确定这会如何工作。

    【讨论】:

    • 谢谢,我不知道映射列表需要一个额外的索引列
    猜你喜欢
    • 2012-01-19
    • 1970-01-01
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    • 2017-08-27
    • 1970-01-01
    • 1970-01-01
    • 2011-03-14
    相关资源
    最近更新 更多