我正在使用hibernate OneToOne映射(使用外键)将USER(userName(pk),firstName,LastName)与Address(addressId(PK,autogenerated),street,city,state)连接起来。 此操作在USER表中创建addressId列。 现在登录时,我想使用userName获取地址详细信息,我应该怎么做。 非常感谢你
答案 0 :(得分:0)
这只是粗略的想法,但必须以这种方式完成,试试吧
public class User{
//other field
Address address= new Address();
// getter and setter here
}
public class Address{
//address field
// getter and setter here
}
//To get address
User user = getUserByName('xyz');
Address address = user.getAddress();
//use your address object