What's wrong with my program? I get 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 don't know how to solve it... On the stack trace the only class written by me is
myapp.spring.controllers.PostFormController.processForm(PostFormController.java:66)
And 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 can't add because of too much code in post :S
The problem probably is this line:
@NotBlank
@Column(name="thread_id")
private long thread_id;
NotBlank
has no sense on a field of type long. A long can't be blank or not blanked. Only a String can. Hence the error message:
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.lang.Long
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With