beanio
beanio copied to clipboard
BeanReaderContext does not take into account bean nesting
What steps will reproduce the problem? If applicable, please provide a
mapping configuration and sample record input to recreate the problem.
1. Create a mapping with a nested bean
2. Try to read a file with a field error on one of the nested bean fields
3. The field errors returned do not take into account the bean nesting.
What is the expected output? What do you see instead?
Given a record with a bean inside such as:
<record name="bigBean" class="example.BigBean">
<bean name="myBean" class="example.MyBean">
<field name="num" type="integer" />
</bean>
<bean name="yourBean" class="example.MyBean">
<field name="num" type="integer" />
</bean>
</record>
If there is a field error on 'num' I would expect field errors to be created
under the key "myBean.num" or "yourBean.num", giving the full property path.
Instead, we are seeing field errors created under the key "num".
What version of BeanIO are you using?
BeanIO 1.2.3
Please provide any additional information below.
This is a problem because our error handler needs to know the full path to the
invalid field in order to generate the correct error message. Also, the
fieldErrorMap within the BeanReaderContext maintains a map of field names to
values. In the example above, this map might look like "num" -> "5" So when
interpolating field values into error messages you might get the wrong value
(ie, if one field was "A" and one field was "B" the two field errors generated
would interpolate the same field value because the fieldErrorMap only has one
entry for "num" rather than having two entries, such as "myBean.num" -> "A",
"yourBean.num" -> "B"). I don't know if this is resolved in BeanIO 2.0.
Original issue reported on code.google.com by [email protected] on 7 Jun 2012 at 4:30