How to use custom type in JPA column?

后端 未结 2 1927
别那么骄傲
别那么骄傲 2021-01-18 02:54

I have a class:

public class Email {
  private String name;
  private String domain;
  public String toString() {
    return name + \"@\" + domain;
  }  
}
<         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-18 03:36

    Well, there are a number of ways:

    • annotate the Email class with @Embeddable, and have:

       @Embedded
       private Email email;
      
    • declare a custom value type - see here (using @Type)

提交回复
热议问题