Hibernate Lazy Loading Exception In A Grid

Hello,

I’ve come across some strange behaviour with the Grid component. Basically, if I do this:

    Grid<Actor> grid = new Grid<>(Actor.class);
    grid.setColumns("firstName");

my code works perfectly. However, if I do this:

    Grid<Actor> grid = new Grid<>(Actor.class);
    grid.addColumn(Actor::getFirstName);

my app crashes with a lazy loading exception. I think the two techniques are equivalent so, theoretically, the second should work as well.

The second technique must be trying to access an unrelated property and load a list outside the Hibernate transaction.

I find this strange. Does anyone have any suggestions?

Thanks in advance.

JB

Hello again,

I just resolved it:

    Grid<Actor> grid = new Grid<>();
    grid.addColumn(Actor::getFirstName);

this works.

JB