开发者

java.sql.SQLException: Field 'passwordConfirmation' doesn't have a default value

I've been scratching my head over this error for sometime now but can't work it out. I've been using Hibernate 3 to persist User entity. But I am getting java.sql.SQLException: Field 'passwordConfirmation' doesn't have a default value error when I try to do that.

Following is my User entity: User.java

@Entity
public class User implements Serializable {

    private Long id;
    private String email;
    private String password;
    private String passwordConfirmation;    
    private String captcha; 

    @Id @GeneratedValue
   开发者_如何学编程 public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }

    @NotEmpty
    @Email
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }

    @NotEmpty   
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }

    @NotEmpty
    @Transient
    public String getPasswordConfirmation() {
        return passwordConfirmation;
    }
    public void setPasswordConfirmation(String passwordConfirmation) {
        this.passwordConfirmation = passwordConfirmation;
    }

}

Could someone help me understand that why am I getting this error?


passwordConfirmation property in your class is marked as @Transient, although error indicates that column for that field exists in the database schema.

If your database schema was generated automatically by Hibenrate, perhaps it had been done before you added a @Transient annotation. If so, you need to regenerate your schema.


I was mistakenly using a different schema than the one I was generating using Hibernate. Both the schema had passwordConfirmation field in the User entity so got confused.

I've got it working now. Thanks :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜