当我加载父对象(DuaVO)对象时,如何加载子对象(RefAuthorizationVO)。
要加载的主要类方法
DuaVO dua = (DuaVO) session.get(DuaVO.class, "1");
RefAuthorization 儿童
@Entity
@Table(name = "RFRNC_AUTHRZTN")
public class RefAuthorizationVO implements Serializable
{
@Column(name = "SYS_CREAT_USER_ID")
private String sysCreatedUserId;
@Column(name = "SYS_CREAT_TS")
private Date sysCreatedTimestamp;
@Column(name = "SYS_UPDT_USER_ID")
private String sysUpdateUserId;
@Column(name = "SYS_UPDT_TS")
private Date sysUpdateTimestamp;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="AUTHRZTN_CD")
private String authorizationCode;
@Column(name="AUTHRZTN_DESC")
private String authorizationDescription;
DuaVO 家长
@Entity
@Table(name = "DUA")
public class DuaVO implements java.io.Serializable {
@Id
@Column(name= "DUA_NUM")
private String duaNumber;
// AuditDetails
@Column(name = "SYS_CREAT_USER_ID")
private String sysCreatedUserId;
@Column(name = "SYS_CREAT_TS")
private Date sysCreatedTimestamp;
@Column(name = "SYS_UPDT_USER_ID")
private String sysUpdateUserId;
@Column(name = "SYS_UPDT_TS")
private Date sysUpdateTimestamp;
@Column(name = "DUA_SHRT_DESC")
private String duaShortDesc;
@Column(name = "AUTHRZTN_CD")
private String authorizationCode;
@ManyToOne
private RefAuthorizationVO refAuthorizationVO;
}
但是,当我试图像这样接触孩子时..
System.out.println("Ref Auth: " + dua.getRefAuthorizationVO() );
我得到了空。
答案 0 :(得分:1)
认为你错过了@JoinColumn注释
@JoinColumn(name = "FK_ID", referencedColumnName = "ID")
@ManyToOne