Hibernate映射视图View

create or replace view v_memo as
select rownum as sadid,m.sadprf as sadprf,m.sadfrm as sadfrm,m.sadadm as sadadm,m.sadagt as sadagt,m.sadsty as sadsty,m.sadbde as sadbde,m.sadmch as sadmch,m.sadcur as sadcur,m.sadjmt as sadjmt,m.sadsta as sadsta,m.sadhmh as sadhmh,m.sadmfg as sadmfg,
h.smchmh as smchmh,h.smcseq as sadseq,h.smcdid as saddid,h.smcddt as sadddt,h.smcmdt as sadmdt,h.smcdcm as saddcm,h.smcdat as saddat,h.smcdmt as saddmt,h.smcdcr as saddcr,c.sdccdt as sadcdt
  from satadm m
  left join satmch h on m.sadprf = h.smcprf
                    and m.sadfrm = h.smcfrm
                    and m.sadadm = h.smcadm
  left join saldcm c on h.smcdsq=c.sdcseq
  with check option;

 

@Entity
@Table(name = "V_MEMO")
@IdClass(TestViewId.class)
public class TestView{

    /**  */
    private static final long serialVersionUID = -8873299808673480077L;

   
    @Id
    @Column(name = "SADPRF", nullable = false, length = 4)
    private String sadprf;

    @Id
    @Column(name = "SADFRM", nullable = false, length = 3)
    private String sadfrm;

    @Id
    @Column(name = "SADADM", nullable = false, length = 7)
    private String sadadm;

    @Id
    @Column(name = "SADID", columnDefinition = "number(22,0)")
    private BigDecimal sadid;

    @Column(name = "SADSEQ", unique = true, nullable = false, columnDefinition = "number(10,0)")
    private Long smcseq;

    @Column(name = "SADSTY", length = 1)
    private String sadsty;

    @Column(name = "SADJMT", columnDefinition = "number(15,4)")
    private Double sadjmt;

    @Column(name = "SADMCH", length = 1)
    private String sadmch;

    @Column(name = "SADAGT", length = 8)
    private String sadagt;

    @Column(name = "SADSTA", length = 4)
    private String sadsta;

    @Column(name = "SADBDE", columnDefinition = "number(8,0)")
    private Integer sadbde;

    @Column(name = "SADCUR", length = 3)
    private String sadcur;

    @Column(name = "SADHMH", length = 1)
    private String sadhmh;

    @Column(name = "SADMFG", length = 1)
    private String sadmfg;

   

    @Column(name = "SADDID", length = 20)
    private String smcdid;

    @Column(name = "SADDDT", columnDefinition = "number(8,0)")
    private Integer smcddt;

    @Column(name = "SADMDT", nullable = false, columnDefinition = "number(8,0)")
    private Integer smcmdt;

    @Column(name = "SADDCM", length = 8)
    private String smcdcm;

    @Column(name = "SADDAT", length = 8)
    private String smcdat;

    @Column(name = "SADDMT", columnDefinition = "number(15,4)")
    private Double smcdmt;

    @Column(name = "SADDCR", length = 3)
    private String saddcr;

    @Column(name = "SMCHMH", length = 1)
    private String smchmh;

    

    @Column(name = "SADCDT", columnDefinition = "number(14,0)")
    private Long sdccdt;

    /**
     * @return the sadprf
     */
    public String getSadprf() {
        return sadprf;
    }

    /**
     * @param sadprf the sadprf to set
     */
    public void setSadprf(String sadprf) {
        this.sadprf = sadprf;
    }

    /**
     * @return the sadfrm
     */
    public String getSadfrm() {
        return sadfrm;
    }

    /**
     * @param sadfrm the sadfrm to set
     */
    public void setSadfrm(String sadfrm) {
        this.sadfrm = sadfrm;
    }

    /**
     * @return the sadadm
     */
    public String getSadadm() {
        return sadadm;
    }

    /**
     * @param sadadm the sadadm to set
     */
    public void setSadadm(String sadadm) {
        this.sadadm = sadadm;
    }

    /**
     * @return the sadsty
     */
    public String getSadsty() {
        return sadsty;
    }

    /**
     * @param sadsty the sadsty to set
     */
    public void setSadsty(String sadsty) {
        this.sadsty = sadsty;
    }

    /**
     * @return the sadjmt
     */
    public Double getSadjmt() {
        return sadjmt;
    }

    /**
     * @param sadjmt the sadjmt to set
     */
    public void setSadjmt(Double sadjmt) {
        this.sadjmt = sadjmt;
    }

    /**
     * @return the sadmch
     */
    public String getSadmch() {
        return sadmch;
    }

    /**
     * @param sadmch the sadmch to set
     */
    public void setSadmch(String sadmch) {
        this.sadmch = sadmch;
    }

    /**
     * @return the sadagt
     */
    public String getSadagt() {
        return sadagt;
    }

    /**
     * @param sadagt the sadagt to set
     */
    public void setSadagt(String sadagt) {
        this.sadagt = sadagt;
    }

    /**
     * @return the sadsta
     */
    public String getSadsta() {
        return sadsta;
    }

    /**
     * @param sadsta the sadsta to set
     */
    public void setSadsta(String sadsta) {
        this.sadsta = sadsta;
    }

    /**
     * @return the sadbde
     */
    public Integer getSadbde() {
        return sadbde;
    }

    /**
     * @param sadbde the sadbde to set
     */
    public void setSadbde(Integer sadbde) {
        this.sadbde = sadbde;
    }

    /**
     * @return the sadcur
     */
    public String getSadcur() {
        return sadcur;
    }

    /**
     * @param sadcur the sadcur to set
     */
    public void setSadcur(String sadcur) {
        this.sadcur = sadcur;
    }

    /**
     * @return the sadhmh
     */
    public String getSadhmh() {
        return sadhmh;
    }

    /**
     * @param sadhmh the sadhmh to set
     */
    public void setSadhmh(String sadhmh) {
        this.sadhmh = sadhmh;
    }

    /**
     * @return the smcdid
     */
    public String getSmcdid() {
        return smcdid;
    }

    /**
     * @param smcdid the smcdid to set
     */
    public void setSmcdid(String smcdid) {
        this.smcdid = smcdid;
    }

    /**
     * @return the smcddt
     */
    public Integer getSmcddt() {
        return smcddt;
    }

    /**
     * @param smcddt the smcddt to set
     */
    public void setSmcddt(Integer smcddt) {
        this.smcddt = smcddt;
    }

    /**
     * @return the smcmdt
     */
    public Integer getSmcmdt() {
        return smcmdt;
    }

    /**
     * @param smcmdt the smcmdt to set
     */
    public void setSmcmdt(Integer smcmdt) {
        this.smcmdt = smcmdt;
    }

    /**
     * @return the smcdcm
     */
    public String getSmcdcm() {
        return smcdcm;
    }

    /**
     * @param smcdcm the smcdcm to set
     */
    public void setSmcdcm(String smcdcm) {
        this.smcdcm = smcdcm;
    }

    /**
     * @return the smcdat
     */
    public String getSmcdat() {
        return smcdat;
    }

    /**
     * @param smcdat the smcdat to set
     */
    public void setSmcdat(String smcdat) {
        this.smcdat = smcdat;
    }

    /**
     * @return the smcdmt
     */
    public Double getSmcdmt() {
        return smcdmt;
    }

    /**
     * @param smcdmt the smcdmt to set
     */
    public void setSmcdmt(Double smcdmt) {
        this.smcdmt = smcdmt;
    }

    /**
     * @return the sdccdt
     */
    public Long getSdccdt() {
        return sdccdt;
    }

    /**
     * @param sdccdt the sdccdt to set
     */
    public void setSdccdt(Long sdccdt) {
        this.sdccdt = sdccdt;
    }

    /**
     * @return the saddcr
     */
    public String getSaddcr() {
        return saddcr;
    }

    /**
     * @param saddcr the saddcr to set
     */
    public void setSaddcr(String saddcr) {
        this.saddcr = saddcr;
    }

    /**
     * @return the sadmfg
     */
    public String getSadmfg() {
        return sadmfg;
    }

    /**
     * @param sadmfg the sadmfg to set
     */
    public void setSadmfg(String sadmfg) {
        this.sadmfg = sadmfg;
    }

    /**
     * @return the smcseq
     */
    public Long getSmcseq() {
        return smcseq;
    }

    /**
     * @param smcseq the smcseq to set
     */
    public void setSmcseq(Long smcseq) {
        this.smcseq = smcseq;
    }

    /**
     * @return the smchmh
     */
    public String getSmchmh() {
        return smchmh;
    }

    /**
     * @param smchmh the smchmh to set
     */
    public void setSmchmh(String smchmh) {
        this.smchmh = smchmh;
    }

    /**
     * @return the sadid
     */
    public BigDecimal getSadid() {
        return sadid;
    }

    /**
     * @param sadid the sadid to set
     */
    public void setSadid(BigDecimal sadid) {
        this.sadid = sadid;
    }

}

 

@Embeddable
public class TestViewId implements Serializable {

    /**  */
    private static final long serialVersionUID = 8548042839147058314L;

    private String sadprf;
    private String sadfrm;
    private String sadadm;
    private BigDecimal sadid;

    /**
     * @return the sadprf
     */
    public String getSadprf() {
        return sadprf;
    }

    /**
     * @param sadprf the sadprf to set
     */
    public void setSadprf(String sadprf) {
        this.sadprf = sadprf;
    }

    /**
     * @return the sadfrm
     */
    public String getSadfrm() {
        return sadfrm;
    }

    /**
     * @param sadfrm the sadfrm to set
     */
    public void setSadfrm(String sadfrm) {
        this.sadfrm = sadfrm;
    }

    /**
     * @return the sadadm
     */
    public String getSadadm() {
        return sadadm;
    }

    /**
     * @param sadadm the sadadm to set
     */
    public void setSadadm(String sadadm) {
        this.sadadm = sadadm;
    }

    /**
     * @return the sadid
     */
    public BigDecimal getSadid() {
        return sadid;
    }

    /**
     * @param sadid the sadid to set
     */
    public void setSadid(BigDecimal sadid) {
        this.sadid = sadid;
    }

    /**
     * @return
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((sadadm == null) ? 0 : sadadm.hashCode());
        result = prime * result + ((sadfrm == null) ? 0 : sadfrm.hashCode());
        result = prime * result + ((sadid == null) ? 0 : sadid.hashCode());
        result = prime * result + ((sadprf == null) ? 0 : sadprf.hashCode());
        return result;
    }

    /**
     * @param obj
     * @return
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        MemoViewId other = (MemoViewId) obj;
        if (sadadm == null) {
            if (other.sadadm != null)
                return false;
        } else if (!sadadm.equals(other.sadadm))
            return false;
        if (sadfrm == null) {
            if (other.sadfrm != null)
                return false;
        } else if (!sadfrm.equals(other.sadfrm))
            return false;
        if (sadid == null) {
            if (other.sadid != null)
                return false;
        } else if (!sadid.equals(other.sadid))
            return false;
        if (sadprf == null) {
            if (other.sadprf != null)
                return false;
        } else if (!sadprf.equals(other.sadprf))
            return false;
        return true;
    }

    /**
     * @param sadprf
     * @param sadfrm
     * @param sadadm
     * @param sadid
     */
    public MemoViewId(String sadprf, String sadfrm, String sadadm, BigDecimal sadid) {
        super();
        this.sadprf = sadprf;
        this.sadfrm = sadfrm;
        this.sadadm = sadadm;
        this.sadid = sadid;
    }

    /**
     * 
     */
    public MemoViewId() {
        super();
        // TODO Auto-generated constructor stub
    }

}

 

视图是没有索引的,所以映射时可以使用复合主键来作为主键或者使用oracle中的关键字rownum作为主键。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值