yeg*_*256 7 java hibernate jpa
我有一节课:
public class Email {
private String name;
private String domain;
public String toString() {
return name + "@" + domain;
}
}
Run Code Online (Sandbox Code Playgroud)
我想在JPA专栏中使用它:
@Entity
public class User {
@Id private Integer id;
private Email email;
}
Run Code Online (Sandbox Code Playgroud)
这就是Hibernate所说的:
org.hibernate.MappingException: Could not determine type for: com.XXX.Email
Run Code Online (Sandbox Code Playgroud)
如何让它了解我的自定义类型.我认为这很简单,但在文档中找不到.
Boz*_*zho 12
嗯,有很多方法:
使用和注释Email类@Embeddable,并具有:
@Embedded
private Email email;
Run Code Online (Sandbox Code Playgroud)声明自定义值类型 - 请参阅此处(使用@Type)
| 归档时间: |
|
| 查看次数: |
15701 次 |
| 最近记录: |