I try to use indexed mapping together with arrays and get an ArrayStoreException at the following example. What's wrong here? When I replace Double[] with List<Double> all is working fine.
Thanks for the comprehensive explanation - it makes it so much easier :)
This is a quirk with Dozer (see bug 39), where it needs a few hints to do the mapping.
You'll notice that beanReader.configureBeanMapping() is overloaded and one method accepts an array of hint types - this is passed to Dozer as a hint to the type of each column.
So you can simply set up the hints (both of your columns are Doubles):
I try to use indexed mapping together with arrays and get an ArrayStoreException at the following example. What's wrong here? When I replace Double[] with List<Double> all is working fine.
1) Bean:
2) Main:
3) csv file:
Hi Andy,
Thanks for the comprehensive explanation - it makes it so much easier :)
This is a quirk with Dozer (see bug 39), where it needs a few hints to do the mapping.
You'll notice that
beanReader.configureBeanMapping()
is overloaded and one method accepts an array of hint types - this is passed to Dozer as a hint to the type of each column.So you can simply set up the hints (both of your columns are
Double
s):And then pass those hints in when configuring the bean mapping:
That should get you up and running again. Also, you probably don't want the bean mapping in the first row of your CSV file and in your code...