-2

我正在使用休眠 OneToOne 映射(使用外键)将 USER(userName(pk),firstName,LastName)与 Address(addressId(PK,autogenerated),street,city,state)连接起来。此操作在 USER 表中创建 addressId 列。现在登录时,我想使用用户名获取地址详细信息,我应该怎么做。非常感谢你

4

1 回答 1

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
于 2013-10-08T06:29:17.443 回答