Hello,
So I tried to pizzashop example with Spring Roo and Vaadin. But I am not using the default scaffolding UI generated by Vaadin plugin.
So I have a table with the data source of BeanItemContainer. I directly call addBean to add persisted Topping object to it.
My question is, how do I correctly update the Topping object, especially a series of updates?
Here’s some pseudo code:
Topping t = new Topping();
t.setName(“Pineapple”);
t.persist();
beanItemContainer.addBean(t);//so far so good
t.setName(“Ham”);
t.merge(); //Should I explicitly call merge here?
t.setName(“Mushroom”);
t.merge(); //this merge will throw an exception of “cannot be merged because it has changed or been deleted since it was last read.”
//alternatively I can do this
Topping t2 = t.setName(“Mushroom”);
t2.merge();
Now my question is, I assume I should update the reference in beanItemContainer to t2. How do I do that? I don’t think I am using the best practice here.
Could anybody enlighten me on the persistence / entity manage / transaction manage in vaadin and spring roo?