Question

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

I'm thinking:

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

But then, do I do the same thing in the other table as well?

Was it helpful?

Solution

It would be something like this:

class Other{
    @OneToOne
    Employee employe;
}

class Employee {
    @OneToOne(mappedBy = "empolyee", cascade = CascadeType.SAVE_UPDATE)
    Other other;
}

OTHER TIPS

import com.test.study.model.employee; 

@OneToOne(mappedBy="employee", cascade=CascadeType.ALL)
private employee emp;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top