I don't have any strong opinion.
I'd be tempted to say you are right. It seems to be somebody expecting a non indexable
path would not be hurt if the Path structure returned an indexable version. Can you also
create a BVAL issue so that the spec gets clarified.
On 21 avr. 2011, at 00:11, Gunnar Morling wrote:
Hi guys,
there was an interesting question on the Validator forum
(
https://forum.hibernate.org/viewtopic.php?f=9&t=1010626&start=0)
which IMO boils down to the question whether the static or the runtime
type of an association should be considered when creating property
paths in case of cascading validations.
An example:
class Foo {
private Collection<Bar> bar1 = new ArrayList<Bar>();
private List<Bar> bar2 = new ArrayList<Bar>();
}
When validating an instance of Foo (which has invalid elements in
bar1/bar2) with HV, the resulting property path node for bar1 would be
iterable but not indexable ("bar1[]"), while the property path node
for bar2 would be iterable and indexable ("bar2[123]"). This is that
way because the static type of bar1/bar2 (Collection vs. List) is
considered when building the nodes, and not the runtime type
(ArrayList in both cases).
That said, basing the path on the runtime type instead would seem
reasonable to me, too (as for instance the constraints to validate are
also determined based on the runtime type of references). I scanned
through the BV spec. (section 4.5) but didn't find a clear answer
which approach should be followed. Are there any opinions on that?
Thanks,
Gunnar