0
<one-to-one name="employee" class="com.test.study.model.employee" 
cascade="save-update"> </one-to-one> 

我在想:這是什麼等效的休眠註釋?

OneToOne(fetch = FetchType.LAZY, mappedBy = "com.test.study.model.employee", cascade = CascadeType.All) 

但後來,我做同樣的事情在其他表呢?

回答

0

這將是這樣的:

class Other{ 
    @OneToOne 
    Employee employe; 
} 

class Employee { 
    @OneToOne(mappedBy = "empolyee", cascade = CascadeType.SAVE_UPDATE) 
    Other other; 
} 
0
import com.test.study.model.employee; 

@OneToOne(mappedBy="employee", cascade=CascadeType.ALL) 
private employee emp;