table 複合主鍵 同時使用 JAXB annotation設定

  • 主pojo set @Id@IdClass(xxx.class)、並設定@XmlElement
/**
 *主檔
 */
@Entity
@lombok.Data
@lombok.ToString
@Table(name="STORE_INFO")
@XmlAccessorType(XmlAccessType.FIELD)
@IdClass(StoreInfoPK.class)
public class StoreInfo implements Serializable {

  private static final long serialVersionUID = 1L;
  
  @Id
  @XmlElement(name = "StoreId")
  private String storeId;
  
  @Id
  @XmlElement(name = "CreateTime")
  private Date createTime;

  /**
   * 店鋪店名
   */
  @XmlElement(name = "StoreName")
  @Column(name = "STORE_NAME")
  private String storeName;

  public SupStoreInfo() {}

}

table 複合主鍵 並用 JAXB annotation設定

  • PK pojo set @Column
/**
 *PK
 */

@lombok.Data
@lombok.ToString
public class StoreInfoPK implements Serializable {

  private static final long serialVersionUID = 1L;

    @Column(name="STORE_ID")
    private String storeId;

    @Column(name="CREATE_TIME")
    @Temporal(TemporalType.DATE)
    private Date createTime;
    
    public StoreInfoPK() {
    }
}

    文章標籤

    JAVA JAXB @Id 複合主鍵

    全站熱搜

    咪卡恰比 發表在 痞客邦 留言(0) 人氣()