我试图让这个映射工作,但我得到了这个奇怪的异常消息
Could not determine type for: foo.ProcessUser, at table: ProcessUser_onetimeCodes, for columns: [org.hibernate.mapping.Column(processUser)]
@Entity
public class ProcessUser {
@Setter
private List<OnetimeCodes> onetimeCodes;
@CollectionOfElements
public List<OnetimeCodes> getOnetimeCodes() {
return onetimeCodes;
}
}
@Embeddable
@Data
public class OnetimeCodes {
@Parent
private ProcessUser processUser;
@Column(nullable=false)
@NotEmpty
private String password;
public OnetimeCodes(ProcessUser processUser, String password) {
this.processUser = processUser;
this.password = password;
}
}
有人能在这里发现什么错误吗?
我在hibernate.hbm2ddl.auto
create
答案 0 :(得分:2)
我发现了错误。
您不能在其中一个类中使用该属性,而在另一个类中使用getter。他们应该匹配。
所以我改变了
@Embeddable
@Data
public class OnetimeCodes {
@Parent
private ProcessUser processUser;
@Column(nullable=false)
@NotEmpty
private String password;
public OnetimeCodes(ProcessUser processUser, String password) {
this.processUser = processUser;
this.password = password;
}
}
到
@Embeddable
public class OnetimeCodes {
private ProcessUser processUser;
private String password;
public OnetimeCodes(ProcessUser processUser, String password) {
this.processUser = processUser;
this.password = password;
}
@Parent
public ProcessUser getProcessUser() {
return processUser;
}
public void setProcessUser(ProcessUser processUser) {
this.processUser = processUser;
}
@Column(nullable=false)
@NotEmpty
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
和中提琴。 如果你问我就很蠢。