When it's a new record it works quietly , the problem is in change .
I have a A object that is the master, another B object that is a ArrayList
tail and master A detail, and last , a C object that is ArrayList
and detail of the B object.
When I send the information to the server and the index
of the object B is equal to 0 and the detail that is the C object > is not null works correctly without complaining to convert String[]
to BigDecimal
.
But when I send the information and index
of the B object it is that 0 and the detail that is the C < strong> is not null is accused that it is trying to convert String[]
to BigDecimal
and returns error.
org.springframework.validation.BeanPropertyBindingResult: 3 errors Field error in object 'A' on field 'B [1] .C [0] .attribute': rejected value [190.67,190.67]; ... (Other errors not listed, but not different from what happened since it is a detail).
As the element in the JSP element I fill in using AngularJS when the user clicks to generate a new item in the C detail:
name='B[{{B.index}}].C[{{C.index}}].atributo'
As it is in the model:
@Column(name = "ATRIBUTO")
@NotNull(message = "{validate.required.atributo}")
@NumberFormat(pattern = "0.00")
private BigDecimal atributo;
Prints as is in JavaScript in form submit event:
Error that returns to user at client layer:
Failed to convert property value of type java.lang.String [] to required type java.math.BigDecimal for property B [1] .C [0]. attribute; nested exception is java.lang.NumberFormatException
Any solutions to this problem? Apparently I believe that the definition in the name attribute to correctly generate the objects at the server layer is correct, even though it is saved in the database when a new record is created, the problem occurs when we enter by changing and when the B object will have the C attribute that will not be null, it is in an index greater than 0 causing a String vector to appear in the attribute as you error message since it looks like it was multiplied by so many elements that exist in the B detail.
The question is, how to fix this being apparently correct?