Hi after read all posts about JPAContainer, FieldFactory and SingleSelectTranslator and lost days I found what didn’t work on my code.
My Model is like (details are left outside):
public class Foo {
@NotNull
@Size(max = 255)
private String caption;
@ManyToOne(fetch = FetchType.EAGER)
private FooOwner fooOwner;
and
public class FooOwner {
@Id//pay attention to this, I think it is the problem
private String uniqueKey;
@NotNull
@Size(max = 255)
private String caption;
Then I have a vaadin table of Foo instances where I need to shows also Foo caption, and Foo uniqueKey, so on the Foo container I added a nestedProperty,
fooContainer.addNestedContainerProperty("fooOwner.caption");
fooContainer.addNestedContainerProperty("fooOwner.uniqueKey");
and the table columns are:
table.setVisibleColumns(new String[] { "id", "fooOwner.caption", "fooOwner.uniqueKey", "start", "end", "caption" });
On the Foo vaadin Form I pass the EntityItem,
fooForm.setItemDataSource(fooItem, Arrays.asList(new String[] { "start", "end", "caption", "fooOwner" }));
I use the JPAContainer instance of FieldFactory and on the fooOwner I see a ComboBox (SingleSelectTranslator is used)
on update item all is ok, but if I create a new Item and save I got the following exception
If I remove the addNestedContainerProperty declaration and consequently the related table columns all works well.
Debugging the JPAContainerItem
public void commit() throws SourceException, InvalidValueException {
if (!isWriteThrough()) {
try {
/*
* Commit all properties. The commit() operation will check if
* the property is read only and ignore it if that is the case.
*/
for (ItemProperty prop : propertyMap.values()) {
prop.commit();
}
it gets the fooOwner properties and it seems to me as it confuse the fooOwner instence coming from comboBox with others fooOwner properties.
Could someone get me a rigth direction?
Does anyone did the same scenarious?
Regards