in the attachment i put the screenshot of one problem , when i bind the table with the entity Item , the foreign key from other entity in a relationship oneTomany the field USERDB shows this “model.userdb@5ee5…” that’s not the real data
I assume that you’re using JPAContainer and the table is in non-editable mode. I think you need a Converter in this case.
Displaying a list of something in a Table cell is a bit problematic, as you can’t really have variable-height rows in a Table - in the following we just make it a comma-separated list:
// Have a persistent container
final JPAContainer<Country> countries =
JPAContainerFactory.make(Country.class, "book-examples");
Table table = new Table(null, countries);
table.setVisibleColumns(new Object[]{"name", "people"});
table.setColumnHeaders("Country", "People");
table.setPageLength(table.size());
// Use converter to convert a Person set to a string
class PersonSetConverter implements Converter<String, Set<Person>> {
@Override
public Set<Person> convertToModel(String value,
Class<? extends Set<Person>> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return null; // Unused
}
@Override
public String convertToPresentation(Set<Person> value,
Class<? extends String> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return value.stream().map(x->x.getName()).reduce((a,b) -> a+", "+b).orElse(""); // Java 8
}
@Override
public Class<Set<Person>> getModelType() {
return (Class<Set<Person>>) new HashSet<Person>().getClass().getSuperclass();
}
@Override
public Class<String> getPresentationType() {
return String.class;
}
}
table.setConverter("people", new PersonSetConverter());