Grid with Object that contains another List

I’m having a problem when and I add some items that already contains other list. I’d say Grid is traying to show all the data creating new rows (empty) but with the same PK.


  1. Are you sure the equals and hashCode methods of your item class are implemented properly?
  2. Could you show us how you set up your grid and how you set the items?

Honestly I didn’t implemented equals or hashCode, but my problem has relation with “son” list not with the current one.
Do you think it could be related?, I have implemented other Grids with “easier” classes and I didn’t have this problem.
BookDay is the List that is showed wrongly to the grid

I dont know what BookDay is. and honestly, I don’t understand completely what you mean with when and I add some items that already contains other list.
I’m not going to assume or think anything before I can see your actual implementation.

@Table(name = "booking")  
public class Booking {

	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	private Employee bookedBy;
	private String reason = "";
	private LocalDateTime firstDay;
	private LocalDateTime lastDay;
	private Room room;
	@OneToMany(fetch = FetchType.EAGER)
	private List<BookDay> bookDays = new ArrayList<BookDay>(); 
public class BookingGrid extends Grid<Booking>{

	private static final long serialVersionUID = -6303470678550544041L;
	private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");

	public BookingGrid() {
	private void createGrid() {
		addComponentColumn(item -> getBookedBy(item)).setHeader("Reservado por");
		addComponentColumn(item -> getStartDate(item)).setHeader("Desde");
		addComponentColumn(item -> getEndDate(item)).setHeader("Hasta");

Sorry, I just saw my error, I tried to attach a piece of code.
For each object inside the son list(bookDay) a new row empty is created in the Grid.
This grid should be showing just Booking

Okay, but can you show the code where you call grid.setItems(..) or grid.setDataProvider(..)

	public void setParameter(BeforeEvent event, Integer parameter) {
		Optional<Room> optionalRoom = roomService.findById(parameter);
		if (parameter == null || !optionalRoom.isPresent()) {
		} else {
			this.currentRoom = optionalRoom.get();
			name.setText("Sala " + currentRoom.getName());

Yes, of course, in this case I didn’t use a data provider.

Here are your next steps:

  1. implement equals and hashCode methods on your Booking class. Check if this solved it
  2. look for other calls of grid.setItems(..) or grid.setDataProvider(..)
  3. Debug the returned list of currentRoom.getBookings() and check if this list is correct

You were right, I never saw that before but it’s a problem with my jpa implementation.
Thanks a lot I’m sorry for the inconveniences.