Request for JPAContainer testers

Brian, all fields already comparable (String:s)…

Petter:

addressTable.setSizeFull();
addressTable.setContainerDataSource(addressContainer);
addressTable.setVisibleColumns(new Object[] { "street", "city", "county", "area", "code" });
addressTable.setColumnHeaders(new String[] { "street", "city", "county", "area", "code" });
addressTable.setSortContainerPropertyId("iCode");
addressTable.setSortAscending(true);
addressTable.setColumnCollapsingAllowed(true);
addressTable.setSelectable(true);
addressTable.setImmediate(true);
addressTable.setSortDisabled(false);
mainLayout.addComponent(addressTable);

I have a form to edit an entity named “Store”. Store.comments is of type List. When I load the Store Item into a form, I load Store.comments into a read-only table (which also receives the Property datasource) and provide a comment TextField. When I click “Save” on the form, I check to see if the TextField is non-empty. If it is non-empty, then I add it to the list and then call commit() using the table. If the list contains detached entities, then I get the “detached entity passed to persist” error. If the list is empty, then it works. Seems like something should check for detached entities and call merge() if the entity has been updated. What is the correct way to implement such functionality using JPAContainer?

Hello,

Currently, master-detail views are not supported by JPAContainer, which is probably why you are receiving that error. However, this feature will be added in the future, see ticket http://dev.vaadin.com/ticket/4297. If you have any additional information, such as code snippets or stack traces, then please add them as comments to the ticket.

Best regards,

-Petter-

Thanks. Looking at the code, it seems like it might be a provider-specific issue/config. In this case, I’m using hibernate and I figured hibernate would iterate thru the collection and do what it needs to do (create/update/nothing) on each collection element.

So, after googling, and reading, I think I have a better grasp on the master/detail issue. If the pre-existing detail items are editable, and you want the ability to add a new detail item, then you have some options…
[font=Courier New]

Add | Edit
X | X - You will need to persist the new detail, add it to the list, then commit
X | ___ - You can create the detail using “new”, add it to an empty list, and commit
___ | X - Commit the list

[/font]

In my case, the pre-existing detail items (comments), are not editable, so I can just create the comment, add it to an empty list, and commit. Seems that w/ JPA, you can’t feed it a list of detached + new entities and let it figure out which operation to call on per-item basis. I might be wrong on some of this, but perhaps it will shed some light.