Float with null value Spring

0

I have an application with Spring Data. A Call the findAll () method of Spring, there are null values in the database. When doing the set of the object the field comes with null value by triggering the error message: Can not set float field br.com.pedidosweb.ws.model.Product.pro_estoqmax to null value.

Would you have any way to handle this?

    
asked by anonymous 29.12.2017 / 19:39

1 answer

0

From what I've described, I get the impression that you have an attribute of type float in your class, that is, a primitive type. In this case, you should be having an exception of type IllegalArgumentException: Can not set float field br.com.pedidosweb.ws.model.Produto.pro_estoqmax to null value .

Why this exception? Because float is a primitive type and does not work or accepts null value. So, if in the bank your column is null, it would have to get a null value which is not possible.

To resolve, change your attribute to Float or else, set your column to the default zero value, so instead of null will be 0.0 .

    
29.12.2017 / 20:07