我有一個類:如何在JPA列中使用自定義類型?
public class Email {
private String name;
private String domain;
public String toString() {
return name + "@" + domain;
}
}
我想用它在JPA列:
@Entity
public class User {
@Id private Integer id;
private Email email;
}
這是Hibernate的說:
org.hibernate.MappingException: Could not determine type for: com.XXX.Email
如何使它明白我的自定義類型。我認爲這非常簡單,但無法在文檔中找到。
@Bozho我想知道提出的第二種方法可能只有JPA(沒有Hibernate特定的註釋)? – yegor256 2010-09-30 07:50:28
@Vincenzo no。看到這個答案http://stackoverflow.com/questions/3628344/jpa2-0-support-of-custom-user-types-and-second-level-cache – Bozho 2010-09-30 07:59:32
@Bozho我不能通過setters /干將? – yegor256 2010-09-30 08:12:28