是否有可能有一個領域的對象引用非主在另一個對象上的密鑰(我正在使用遺留數據庫)。在GORM中使用非主鍵作爲對象屬性?
我所擁有的是flea_name
而不是flea_id
(這是主鍵)。有沒有辦法讓GORM自動從跳蚤桌上拉出正確的跳蚤對象,而非基於非主要的鑰匙(如姓名,代碼等)而不是其ID? 如:
class Flea {
def id //This is the primary key in the table
def name //This is a unique key
}
class Puppy {
def flea //This is stored as the flea's unique, but non-primary,
// name in the puppy table
//The puppy table has a flea_name, not a flea_id, as would be expected
static mapping = {
flea column: 'flea_name'//This will point to the flea's name,
//but I want to hydrate it to be a Flea
}
}
在此先感謝
啊,所以你'正在處理傳統數據庫......這個我沒有理解你的問題。也許一個自定義的hibernate映射將會訣竅。但是,老實說,idk和我不想谷歌它... sry。 – 2011-02-02 17:54:02