0
我有三個表:po_dtl和workbook_types。 每個採購訂單行(po_dtl)都會有「workbook_code」列來引用workbook_types。 基本上,po_dtl.workbook_code只是workbook_types.workbook_code的查找代碼。查找列的Hibernate註釋
簡化Java類的
@Entity
@Table(name="po_dtl")
public class PurchaseOrderDtl {
@Id
@Column(name = "po_dtl_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "po_dtl_s")
@SequenceGenerator(name = "po_dtl_s", sequenceName = "po_dtl_s", allocationSize = 1, initialValue = 1)
private long id;
@Column(name = "price_base", length = 7)
private int priceBase;
// ??? What is the annotation for workbook_Types?
private WorkbookType workbookType;
....
}
雖然workbook_types
@Entity
@Table(name = "workbook_types")
public class WorkbookType {
@Id
@Column(name = "workbook_code")
private String workbookCode;
@Column(name = "description", length = 255)
private String description;
@Column(name = "file_root_path", length = 255)
private String fileRootPath;
....
}
我ussualy使用(無休眠)是:
- workbook_types.workbook_code包含字符串 「wbook_finance」 , 「wbook_marketing」
- 每個po_dtl.workbook_code將包含「wbook_finance」或 「wbook_marketing」
- workbook_types將只包含2行具有獨特workbook_code,而po_dtl將包含許多行,但每行必須只包含「wbook_finance」或「wbook_marketing」
感謝
嘗試按照該鏈接的說明 - > http://stackoverflow.com/questions/18704474/annotations-for-hibernate-lookup-table-type –
請檢查您的問題,不可能理解你想要什麼=)你有2或3個表格嗎? order_detail或po_dtl? – Vovka
@Vovka對不起,應該是2表:po_dtl和workbook_types – Timothy