Problem with table getItemIds and getItem

Hi,

i have a quite strange problem , may be i’m missing something (i’m not a vaadin expert) but this piece of code sometime don’t work and i could not understand why:

[b]
Vaadin version 6.8.13

Method with bug:
[/b]

    public List<LemmaEntry> getEntriesList() {
        //table.commit();
        List<LemmaEntry> list = new ArrayList<LemmaEntry>();
        [b]
Collection itemsId = table.getItemIds();
[/b]
        for (Object item : itemsId) {
            LemmaTableEntry elem = ((BeanItem<LemmaTableEntry>) [b]
table.getItem(item)
[/b]).getBean();
            list.add(elem.toLemmaEntry());
        }
        return list;
    }

Some times this code dos’nt work, i.e the getItem(item) return null.

Particulary i add dinamically a Row to the table(see method below) ,
save
the data taking value from table (Read value not changing the value), and then try to execute this code , and i receive a null from the item i have added
i.e. getItem(item) is null.
But
item
are being taken from Collection itemsId = table.getItemIds(); so how could it be null? so i’m missing something but i need some help to found it.


Row are added with this code

    public void addRowToTable() {
        table.commit();
        LemmaEntry campo = entityFactory.newLemmaEntry();
        campo.setName("");
        table.addItem(new LemmaTableEntry(campo));
        table.commit();
        table.requestRepaintAll();
    }


Table data source is as:

      table.setContainerDataSource(new BeanItemContainer<LemmaTableEntry>(
                LemmaTableEntry.class));


LemmaTableEntry

public class LemmaTableEntry {
    private final LemmaEntry lemmaEntry;

    public LemmaTableEntry(LemmaEntry lemmaEntry) {
        this.lemmaEntry = lemmaEntry;
    }

    public String getName() {
        return lemmaEntry.getName();
    }

    public void setName(String name) {
        lemmaEntry.setName(name);
    }

    public LemmaEntry toLemmaEntry() {
        return lemmaEntry;
    }

    @Override
    public boolean equals(Object o) {
        return this == o || (o instanceof LemmaTableEntry && lemmaEntry == ((LemmaTableEntry) o).lemmaEntry);
    }

    @Override
    public int hashCode() {
        return lemmaEntry != null ? lemmaEntry.hashCode() : 0;
    }
}

LemmaEntry extends some other class and is CGLIB enanched and instanced using CDI, may be this could create some problem?
Save operation apparently did not modified the object reference, anyway the object contained in itemdIs is the same as the item i.e. :
********.vaadin.custom.lemmariEditor.tab.LemmaTableEntry@1539

Should i check some other thing?
Any hint is appreciated.

Note that BeanItemContainer store itemids in a List and BeanItems in a Map, so if the hascode of your LemmaEntry changes after adding it, you will get a null when looking for it later.