使用 CollectionOfElements 映射休眠中的异常
我试图让这个映射工作,但我收到这个奇怪的异常消息
无法确定类型:foo.ProcessUser,表:ProcessUser_onetimeCodes,列:[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;
}
}
有人能发现这里出了什么问题吗? 我在 create
上有 hibernate.hbm2ddl.auto
I am trying to get this mapping to work, but I get this strange exception message
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;
}
}
Can anyone spot whats wrong here?
I have hibernate.hbm2ddl.auto
on create
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了错误。
您不能在一个类中的属性上进行映射,而在另一个类中的 getter 上进行映射。他们应该匹配。
所以我换成
了
中提琴。
如果你问我的话,我非常愚蠢。
I found the error.
You cannot have mapping on the attribute in one of the classes, and on getters on the other. They should match.
So I changed
to
and viola.
Very stupid if you ask me.