No data from object displayed in grid

Hello folks

I have a problem with an Object which i can not set as item in an Grid.
If i use just an List with Objectives like that it works (not via JPA)
dummy ObjectiveList (not generated

//ObjectiveList oModel = new ObjectiveList(); //oModel.createObj("Hausarzt besuchen", "blabla", 3); //oModel.createObj("Einkaufen gehen", "hihihi", 5); But if i readout object via JPA as objectiveList.getObjectives i can’t display it. But the sysout below is working fine.

View

    private Grid<Objective> grid = new Grid<>();
    
    /**
     * Constructor creates a new grid for viewing the object list as a table and adds some formatting.
     */
    public PatientObjectiveListViewImpl() {

     ...
     ...   
     ... 
        
        grid.setSelectionMode(SelectionMode.SINGLE);
        hLayout2.addComponent(grid);   
        grid.addColumn(Objective::getName).setCaption("Ziel"); 
        grid.addColumn(Objective::isComplete).setCaption("Status");
                
        this.setContent(vLayout);
    }
  
 @Override
    public void fillObjectiveList(ObjectiveList objectiveList) {
        grid.setItems(objectiveList.getObjectives());
        
        System.out.println(objectiveList.getObjectives().get(0).getName());
    }

Objective Model

@Entity
public class Objective {
    
    @Id
    @GeneratedValue
    private int oid;
    private String name;
    private String description;
    private int difficulty;
    private boolean isComplete;

    @ManyToOne
    private ObjectiveList objList;

Its just showed nothing (look at the attachement)

Where is the problem? Why i cant access on jpa objects? or is it an other fail?
If you need more code, just mention it.

Thanks, kind regards,
Mike

39101.jpg

I found the solution yesterday. It’s like you said because of the lazy loading. I had to attach this to the ObjectiveList
fetch=FetchType.EAGER

Now it works. Thanks for your response anyway. :slight_smile:

It really shouldn’t matter how the list is populated, as long as it is populated. A shot in the dark as I’ve never actually tried JPA with Vaadin 8 Grid, but is it possible that some lazy query does not in fact populate the list until the sysout?