我在我的项目中使用了hibernatetemplates,我与一对一关系如下所述
public class address {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "raq_pr_seq")
@SequenceGenerator(name="raq_pr_seq", sequenceName="PR_TRANS_ID_SEQ")
@Column(name = "PR_TRANS_ID")
private Long prTranId;
@OneToOne(fetch=FetchType.LAZY,cascade=CascadeType.ALL)
@JoinColumn(name = "RAQ_ID")
private Employee master;
}
public class employee {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "raq_master_seq")
@SequenceGenerator(name="raq_master_seq", sequenceName="RAQ_ID_SEQ")
@Column(name = "RAQ_ID")
private Long Id;
}
DAOImpl
List<Address> address = Utility.getHibernateTemplate().findByCriteria(criteria);
RAQPRDTO prDto = new RAQPRDTO();
//convert from Entity to DTO
prDto.setMppfId(address.get(0).getMaster().getId());//getting error
我在Google上搜索了很多,但是在使用hibernatetemplates时如何处理此问题没有任何解决办法。