public class Driver {
@OneToOne
private License license;
//.. getter setter
};
public class License {
@OneToOne(mappedBy='license')
private Driver driver;
//.. getter setter
}
我通过此映射在 Db 的驱动程序表中获得了一个连接列 license_id。问题是:
Driver driver = new Driver();
// save driver then get it etc...
License license = new License();
license.setDriver(driver);
// save license...
driver.getLicense();
虽然我从孩子设置了父母,但该列仍然是空的,我得到空值。如何避免这种情况?