Cannot find the type: Java Lang. Long’s verifier Post ID

What's wrong with my plan? I received an error

HTTP Status 500 - Request processing Failed; nested exception is javax.validation.UnexpectedTypeException: HV000030: No validator Could be found for type: java.lang.Long.

And I don't know how to solve it... In the stack trace, the only class I write is

myapp.spring.controllers.PostFormController.processForm(PostFormController.java:66)

This line is

validator.validate(p,result);

Post. java

// imports

@Entity
@Table(name="posts")
public class Post implements Serializable
{
        /* **********************************
         * ------------ fields ------------ *
         ************************************/
        /**
         *
         */
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        private long id;

        @Past
        @Column(name="date")
        private Date date;

        @NotBlank
        @Size(min=3,max=20)
        @Column(name="author")
        private String author;

        @NotBlank
        @Column(name="content")
        private String content;

        @NotBlank
        @Column(name="topic")
        private String topic;

        @NotBlank
        @Column(name="thread_id")
        private long thread_id;

        @ManyToOne
        @JoinColumn(name="name")
        @Valid
        private PostType type;



        /* ***************************************
         * ---------- getters setters ---------- *
         *****************************************/
       // cut // 

}

Blah blah blah cannot be added because there is too much code in the post: S

Solution

The problem may be this line:

@NotBlank
@Column(name="thread_id")
private long thread_id;

Notblank has no meaning for fields of type long Long cannot be blank or not blank Only one string can be used Therefore, the error message:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>