CriteriaContainer, addEntity and nested properties

Hello,

CC (with JPA) works perfectly for simple beans - I can show, edit, add,…

But when I try to prepare bean with nested property,

[font=Courier New]
class CarOption{
CarOptionType carOptionType;
}

class CarOptionType{
String name
}

[/font]
the ‘addEntity’ method (myCriteriaContainer.addEntity():wink: raises an exception:


java.lang.RuntimeException: Error in bean construction or property population with default values.
(…)
Caused by: org.apache.commons.beanutils.NestedNullException: Null property value for ‘carOptionType.name’ on bean class ‘class model.CarOption’
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:755)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:846)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426)
at org.vaadin.addons.criteriacontainer.NestedBeanItem.getItemProperty(NestedBeanItem.java:59)

Maybe it is a wrong way to create a new entity.
How should i do it properly?

Regards,
Tomasz

I do not use addEntity() much. Because I often want things such as tables to rearrange themselves after inclusion, I tend to add things directly with JPA persist(), and refresh the container with myCriteriaContainer.refresh(). That way the new item shows up in the proper sorting order, etc.

From the trace, the first thing that comes to mind is to set a default value (other than null) to your car option type. As you can see from the trace, the CriteriaContainer doesn’t do much itself for nested properties – it pretty much delegates everything to Apache BeanUtils.

Please raise an issue on the GoogleCode site listed for the source on the add-on page. I am hoping to release version 1.0 soon, and I will take a peek when I do my pre-release fall clean-up.

Hi Jean-François,

Thank you for response, i have checked - it works with JPA’s “persist” method as I expect.

I’ve just raised this issue on GoogleCode.

Tomasz