1
是可以聲明一個變量Long documentID
爲外鍵,而不是自然Document document
下面的例子:休眠:如何映射變量外鍵
@Entity
@Table("document")
class Document{
...
@Id
Long id;
...
}
@Entity
@Table("something")
class Something{
....
//instead of
@ManyToOne
Document document;
// this one with the appropriate annotations
Long documentID;
...
}
在此先感謝....
在ORM上使用的目的是將對象的邏輯表示轉換爲能夠存儲在數據庫中的關係表單。如果你想直接處理外鍵,爲什麼要使用像Hibernate這樣的ORM呢? – FFL
我想這樣做是因爲我無法修改Document類,因此無法映射爲Hibernate首選方式的雙向映射!另一個問題是性能...我需要改善其他方法的性能,這裏不寫... – user1617013
順便說一句,我將解決我的問題,使用不同的策略,不涉及休眠......謝謝你們...... – user1617013