I have a problem with lazy fetching. here’s what I have. I have a entity class called channel. and another entity class called show. Each channel has many show’s. I’ve implemented hibernate with lazy fetching.But heres the problem, when I get a channel from database and after that try to access the programm list I get a nullpointerException.
Here’s some code:
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
}
});
Maybe I have some mapping errors, here are my mapping files
Programm.hbm.xml:http://pastebin.com/Q639HreT
Telekanal.hbm.xml: http://pastebin.com/4c3h0fZj
Programm class:http://pastebin.com/ws57uGg2
Telekanal class:http://pastebin.com/MZB7KgT1
Or maybe I have problem in my sql setup: http://pastebin.com/AVBM8882
And also I’m using opensessioninview for keeping the session open
My code
Really hope that someone can help
Shouldn’t declaring an empty
list-indexcause an error? I’m not sure how this would work.