Hello,
I need to add items form local DB, with I get using hibernate, into table. Problem is quite simple I have one object with contains join field with fetch = FetchType.LAZY and when I try to add item collection from DB response into vaadin table, get hibernate error (org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role).
Collection<ItemInfoCollection> collection = itemInfoService.fetch(code);
BeanItemContainer<ItemInfoCollection> containerDataSource = (BeanItemContainer<ItemInfoCollection>) this.getContainerDataSource();
containerDataSource.addAll(collection);
public class TimetableInfo {
private String id;
private Set<Item> items = new LinkedHashSet<Item>(0);
...
}
public class Item{
...
@ManyToOne(fetch = FetchType.LAZY, optional = true)
@JoinColumn(name = "execution_info_id", nullable = true)
public ExecutionInfo getExecutionInfo() {
return executionInfo;
}
}
public class ExecutionInfo{
...
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "executionInfo")
@OrderBy("startAt")
public Set<Item> getExecutedItems() {
return executedItems;
}
}
I want to know it is possible to solve this issue by using any of vaadin add-ons, or only creating extra object with will be mapped from original DB object and already contains all data without lazy loading can solve it.