failed to convert from String to type Long when field is LOB

failed to convert from String to type Long when field is LOB

in the spring MVC application, I have Question entity class

in the spring MVC application, I have Question entity class

@Entity
public class Question {

@Lob
@Column(name="QUESTION_TITLE")
private String question;

... }

I use Thymeleaf. for this field my view is bellow

<input type="text" class="form-control" id="question" 
th:field="*{question}" th:value="${question}" placeholder="">

my controller save method is

@PostMapping("/save")
    public String saveQuestion(Question question, BindingResult bindingResult){
        questionService.save(question);

    return "redirect:/admin/questions/all/";
}

but when I submit, I have got error

Failed to bind request element: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'com.sendit.security.model.Question'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.lang.Long] for value 'what'; nested exception is java.lang.NumberFormatException: For input string: "what"

when I add @Convert(converter = QuestionConverter.class) attribute to the question field and implemented QuestionConverter method like bellow.

@Converter
public static class QuestionConverter implements AttributeConverter<String, Integer> {

@Override
public Integer convertToDatabaseColumn(String attribute) {
    return attribute.length();
}

@Override
public String convertToEntityAttribute(Integer dbData) {
    return "";
}

}

I got the error again.

java spring hibernate

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Java Spring Boot First App

Step by Step to your First Spring App

Spring | Spring JDBC Tutorial | Java Spring Tutorial Spring Training

Spring | Spring JDBC Tutorial | Java Spring Tutorial Spring Training . Spring Framework Certification Training This post Spring JDBC Tutorial video will help you

Data Persistence with Hibernate and Spring

Data Persistence with Hibernate and Spring

How to use Spring, Hibernate, and EhCache Caching Features

In this Spring Boot project tutorial to help you understand how to use Spring, Hibernate, and EhCache caching features. we are going to demonstrate the Spring cache + EhCache feature on an example Spring Boot project. Caching will be defined as data queried from a relational database (example configurations prepared for H2 and PostgreSQL database engines).

How to Create Spring App using Hibernate/JPA with JNDI Data Source

Spring Persistence (Hibernate and JPA) with a JNDI datasource, we'll create a Spring application using Hibernate/JPA with a JNDI data source.