Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql java.sql.SQLException:字段';密码确认';不';没有默认值_Mysql_Sql_Hibernate - Fatal编程技术网

Mysql java.sql.SQLException:字段';密码确认';不';没有默认值

Mysql java.sql.SQLException:字段';密码确认';不';没有默认值,mysql,sql,hibernate,Mysql,Sql,Hibernate,我已经为这个错误绞尽脑汁好一阵子了,但还是解决不了。我一直在使用Hibernate 3来持久化用户实体。但是我得到了java.sql.SQLException:当我尝试这样做时,字段“passwordConfirmation”没有默认值 以下是我的用户实体: User.java @Entity public class User implements Serializable { private Long id; private String email; privat

我已经为这个错误绞尽脑汁好一阵子了,但还是解决不了。我一直在使用Hibernate 3来持久化用户实体。但是我得到了java.sql.SQLException:当我尝试这样做时,字段“passwordConfirmation”没有默认值

以下是我的用户实体: 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;
    }

}

有人能帮我理解为什么会出现此错误吗?

passwordConfirmation
属性在您的类中被标记为
@Transient
,尽管错误表明该字段的列存在于数据库架构中


如果您的数据库模式是由Hibenrate自动生成的,那么可能是在添加
@Transient
注释之前完成的。如果是这样,您需要重新生成模式。

我错误地使用了与使用Hibernate生成的模式不同的模式。这两个模式在用户实体中都有
passwordConfirmation
字段,因此混淆了


我现在让它工作了。谢谢:)

Oracle告诉您没有为
passwordConfirmation
字段提供值。您是如何/在哪里填充
用户
对象的?@Nivas:我使用spring mvc 3表示表单,然后填写表单,但当我提交表单时,出现此错误。我不知道spring mvc。但问题是当数据持久化到数据库时,passwordConfirmation字段没有填充。你能试着看看应该更新但没有更新的地方吗…@Nivas:我的数据库中没有
passwordConfirmation
的任何列,当我提交表单时,我看到
passwordConfirmation
的值填充在用于验证
密码
密码确认
字段。你的意思是更新密码确认字段吗?是的,我使用hibernate创建模式,但即使在删除并重新创建模式后,它也会给我相同的结果。@skip:你确定
@Transient
javax.persistence.Transient
?甚至我也怀疑了一会儿,但是的,它只是
javax.persistence.Transient
。然后请将axtavt的答案标记为正确其他读过他的答案的人马上知道它解决了你的问题。谢谢