Master-Detail in JPAContainer


Its possible to have a form based on a item from a JPAContainer and onde of the properties be a editable table of another entity?

This is the classic Invoice - Invoice Line feature, right?

Is it possible to implement it with vaadin\JPAContainer?

/Luis Santos

Based on what you said, the impression I get is that you are looking for a table where you can add new items to a collection member. Can’t do it using the table directly. Still working on perfecting the approach, but I load the current “line items” into the table for viewing purposes and then have a simple text field that will be added when Form.commit() is called provided the text field actually has some text in it. So far, an issue I’m having right now is adding the new entity to the table and then trying to save it. If the List/Collection is not cleared out first, I get the dreaded “Detached entity passed to persist” error message. I know that this is not a complete answer, but it’s better than nothing, right?


If you are even bit adventurous, you could test the snapshot build of JPAContainer 2.0. It has a field factory that builds this kind of field automatically. Currently it needs a back reference from the child entity, but that might change too. Some (ugly) examples here:

The snapshot also has some helper classes to implement all reference fields (see SingleSelectTranslator and MultiSelectTranslator).

The snapshot is available in our snapshot repository with AGPL license:

Also note that the new features require latest Vaadin nightlybuild/6.7-SNAPSHOT to work.

Please, post me your feedback if you decide to test.

BTW. To get rid of various detached entity and lazy loading issues, I strongly suggest to try EclipseLink instead of Hibernate. It has got way better support for stateful apps like Vaadin.