2011-05-25 73 views
1

我有懒惰提取问题。这是我的。我有一个名为channel的实体类。另一个实体类叫show。每个频道都有很多节目。我已经实现了hibernate与lazy fetching.But继承人的问题,当我从数据库中获得一个通道,然后尝试访问程序列表我得到一个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 PROGRAMM类:http://pastebin.com/ws57uGg2 Telekanal类:http://pastebin.com/MZB7KgT1 或者,也许我在SQL安装有问题:http://pastebin.com/AVBM8882 并且还我使用opensessioninview保持开放 My code 真希望有人能帮助会话

回答

4
<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原因的错误?我不知道这将如何工作。

+0

Thx,我不知道映射一个列表需要额外的索引列 – karq 2011-05-25 19:55:37