使用hibernate标准连接多个表(实体)

时间:2018-03-19 12:58:33

标签: hibernate hibernate-criteria

我正在尝试在hibernate中加入多个enties /表,我发现这很困难,因为我试图不使用HQL。

这是我的查询

select * from tax_payer_certificate,tcc_issuance where tax_payer_certificate.certficate_fk = tcc_issuance.certficate_fk and tcc_issuance.year_fk = 95657 
and tcc_issuance.issue_date >= '2017-07-26' and 
tcc_issuance.issue_date <= '2017-08-28' and 
tcc_issuance.portal_user_fk != 101460

表格是单独的实体。

public class TaxPayerCertificate implements Serializable {
    private static final long serialVersionUID = -2818762098412687298L;
    private Timestamp dateCreated;
    private Boolean isConfirmed = false;
    private Timestamp dateConfirmed;
    private Long id;
    private TaxOffice originatingTaxOffice;
    private PortalUser confirmedBy;
    private Year year;
    private TaxPayer taxPayer;

}

证书实体

public class Certficate implements Serializable {
    private static final long serialVersionUID = -7947523303129657154L;
    private String certificateNumber;
    private Date issueDate;
    private Date expiryDate;
    private CertificateTypeConstant type;
    private Long id;
}

TccIssuance实体

 public class TccIssuance implements Serializable {
        private static final long serialVersionUID;
        private Timestamp dateGenerated;
        private String certificateNumber;
        private Date issueDate;
        private Date expiryDate;
        private Long id;
        private Year year;
        private PortalUser portalUser;
        private TaxOffice originatingTaxOffice;
        private Certficate certficate;
    }

这是一个从UML生成的实体类

0 个答案:

没有答案