how to resolve Failed to Convert from type [java.lang.String] to type [@javax.persistence.Manytoone co.mz.Cth.model.Owner]

Asked

Viewed 293 times

0

Greetings I’m doing a springboot+Thymeleaf application (I’m still new to this), I have the following case: There are two related objects Owner and Car In the Car registration form. they contain a combobox that has a dynamic Owner(s list)
when clicking to save I encounter the following error: Failed to convert from type [java.lang.String] to type [@javax.persistence.ManyToOne co.mz.cth.model.Owner] for value '4'; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Provided id of the wrong type for class co.mz.cth.model.Owner. Expected: class java.lang.Long, got class java.lang.String; nested Exception is java.lang.Illegalargumentexception: Provided id of the Wrong type for class co.mz.Cth.model.Owner. Expected: class java.lang.Long, got class java.lang.String]]

below the screenshot(s): class Carinserir a descrição da imagem aqui

class owner inserir a descrição da imagem aqui

Car controller

inserir a descrição da imagem aqui

Car registration form inserir a descrição da imagem aqui

1 answer

0

[Solved] should change the name of select to any other for example: id_owner since it is different from the attributes of the class and object, and in relation to the objects the Owner should be mapped this way: @Onetomany(mappedBy="nameClasseMinusculo")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.