Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 6 days ago
Help BeanItemContainer and JPA many to one
Hi all:
I need you on the table vaadin show me the name of the city is realacionado field with the user table ... thanks
I'm using BeanItemContainer
In my model Ciudad:
....
@OneToMany(mappedBy="ciudad")
private List<Usuario> usuario=new ArrayList<Usuario>();
public List<Usuario> getUsuario() {
return usuario;
}
public void setUsuario(List<Usuario> usuario) {
this.usuario = usuario;
}
...
In my model Usuario:
@ManyToOne
@JoinColumn(name="ciudad_id")
private Ciudad ciudad;
public Ciudad getCiudad() {
return ciudad;
}
public void setCiudad(Ciudad ciudad) {
this.ciudad = ciudad;
}
My table in vaadin:
UsuarioDAO cDAO=new UsuarioDAO();
BeanItemContainer bic = new BeanItemContainer<Usuario>(Usuario.class, cDAO.mostrarTodo());
tabla.setContainerDataSource(bic);
But the result in my table is:
BARRIA
TOLEDO
988378
com.ricardo.proyecto.model.Ciudad@4591fa8e <--- is My city
ACTIVO
232323
1
RICARDO
I need :
BARRIA
TOLEDO
9883378
PUNTA ARENAS <-- name of the table Ciudad
ACTIVO
232323
1
RICARDO
Thanks all.
Last updated on
The solution are this:
UsuarioDAO cDAO=new UsuarioDAO();
BeanItemContainer bic = new BeanItemContainer<Usuario>(Usuario.class, cDAO.mostrarTodo());
bic.addNestedContainerProperty("ciudad.nombre");
tabla.setContainerDataSource(bic);
//tabla.setVisibleColumns(new Object[]{"id","nombre", "apepat","apemat","fono","celular","estado"},new Object[]{"ciudad.ciudad_id"});
tabla.setVisibleColumns(new String[]{"nombre","apepat","apemat","ciudad.nombre"});
Last updated on
You cannot reply to this thread.