MsSql到HQL的转换

时间:2015-08-21 07:35:36

标签: hibernate hql

select CONVERT(DATE, cpi.ComputeDate) 'Date', SUM(cpi.Principal) 'FundedAmount'
from CasePrincipalAndInterest cpi
join CaseInfo ci on ci.CaseId = cpi.CaseId and ci.InvestmentFirmId = '2'

group by CONVERT(DATE, cpi.ComputeDate)
order by CONVERT(DATE, cpi.ComputeDate)

CasePrincipalAndInterest

public class CasePrincipalAndInterest implements java.io.Serializable {

    private CasePrincipalAndInterestId id;
    private CaseInfo caseInfo;

    public CasePrincipalAndInterest() {
    }

    public CasePrincipalAndInterest(CasePrincipalAndInterestId id,
            CaseInfo caseInfo) {
        this.id = id;
        this.caseInfo = caseInfo;
    }

    @EmbeddedId
    @AttributeOverrides({
            @AttributeOverride(name = "caseId", column = @Column(name = "CaseId", nullable = false)),
            @AttributeOverride(name = "principal", column = @Column(name = "Principal", nullable = false, precision = 53, scale = 0)),
            @AttributeOverride(name = "interest", column = @Column(name = "Interest", nullable = false, precision = 53, scale = 0)),
            @AttributeOverride(name = "computeDate", column = @Column(name = "ComputeDate", nullable = false, length = 23)) })
    public CasePrincipalAndInterestId getId() {
        return this.id;
    }

    public void setId(CasePrincipalAndInterestId id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CaseId", nullable = false, insertable = false, updatable = false)
    public CaseInfo getCaseInfo() {
        return this.caseInfo;
    }

    public void setCaseInfo(CaseInfo caseInfo) {
        this.caseInfo = caseInfo;
    }

}

CasePrincipalAndInterestId

@Embeddable
public class CasePrincipalAndInterestId implements java.io.Serializable {

    private int caseId;
    private double principal;
    private double interest;
    private Date computeDate;

    public CasePrincipalAndInterestId() {
    }

    public CasePrincipalAndInterestId(int caseId, double principal,
            double interest, Date computeDate) {
        this.caseId = caseId;
        this.principal = principal;
        this.interest = interest;
        this.computeDate = computeDate;
    }

    @Column(name = "CaseId", nullable = false)
    public int getCaseId() {
        return this.caseId;
    }

    public void setCaseId(int caseId) {
        this.caseId = caseId;
    }

    @Column(name = "Principal", nullable = false, precision = 53, scale = 0)
    public double getPrincipal() {
        return this.principal;
    }

    public void setPrincipal(double principal) {
        this.principal = principal;
    }

    @Column(name = "Interest", nullable = false, precision = 53, scale = 0)
    public double getInterest() {
        return this.interest;
    }

    public void setInterest(double interest) {
        this.interest = interest;
    }

    @Column(name = "ComputeDate", nullable = false, length = 23)
    public Date getComputeDate() {
        return this.computeDate;
    }

    public void setComputeDate(Date computeDate) {
        this.computeDate = computeDate;
    }

实体和pojo 在hql中没有转换我需要转换

的备用选项

0 个答案:

没有答案