hibernate 映射视图

hibernate映射视图,

    但是这时由于视图没有主键,user.hbm.xml在配置时会出现把所有的字段都当成主键,也就是联合主键,但是主键不能为空,可我这里面的字段有的是可以为空的,这应该怎么办??

    下面这样配置就可以。

 

TzChaobiaoInfoView .java   

 

public class TzChaobiaoInfoView  implements java.io.Serializable {


    // Fields   

     private TzChaobiaoInfoViewId id;

     private String khbh;
  //  private String sbbh;//主键
  //  private Date cbrq;//主键
    private Long dsdm;
    private Long ds;
    private Long sjys;
    private String cby;
    private Long cbqk;
    private String gsdz;
    private String khmc;
    private String cbqkmc;
    private String dsdmmc;
  
    // Constructors

    /** default constructor */
    public TzChaobiaoInfoView() {
    }

   
    /** full constructor */
    public TzChaobiaoInfoView(TzChaobiaoInfoViewId id) {
        this.id = id;
    }

  
    // Property accessors

    public TzChaobiaoInfoViewId getId() {
        return this.id;
    }
   
    public void setId(TzChaobiaoInfoViewId id) {
        this.id = id;
    }
  

 
 public String getKhbh() {
  return khbh;
 }
 public void setKhbh(String khbh) {
  this.khbh = khbh;
 }
 
 public Long getDsdm() {
  return dsdm;
 }
 public void setDsdm(Long dsdm) {
  this.dsdm = dsdm;
 }
 public Long getDs() {
  return ds;
 }
 public void setDs(Long ds) {
  this.ds = ds;
 }
 public Long getSjys() {
  return sjys;
 }
 public void setSjys(Long sjys) {
  this.sjys = sjys;
 }
 public String getCby() {
  return cby;
 }
 public void setCby(String cby) {
  this.cby = cby;
 }
 public Long getCbqk() {
  return cbqk;
 }
 public void setCbqk(Long cbqk) {
  this.cbqk = cbqk;
 }
 public String getGsdz() {
  return gsdz;
 }
 public void setGsdz(String gsdz) {
  this.gsdz = gsdz;
 }
 public String getKhmc() {
  return khmc;
 }
 public void setKhmc(String khmc) {
  this.khmc = khmc;
 }
 public String getCbqkmc() {
  return cbqkmc;
 }
 public void setCbqkmc(String cbqkmc) {
  this.cbqkmc = cbqkmc;
 }
 public String getDsdmmc() {
  return dsdmmc;
 }
 public void setDsdmmc(String dsdmmc) {
  this.dsdmmc = dsdmmc;
 }

}       

 

              

TzChaobiaoInfoViewId  .java

 

public class TzChaobiaoInfoViewId  implements java.io.Serializable {


    // Fields   

     private String sbbh;
     private Date cbrq;


    // Constructors

    /** default constructor */
    public TzChaobiaoInfoViewId() {
    }


 public String getSbbh() {
  return sbbh;
 }


 public void setSbbh(String sbbh) {
  this.sbbh = sbbh;
 }


 public Date getCbrq() {
  return cbrq;
 }


 public void setCbrq(Date cbrq) {
  this.cbrq = cbrq;
 }
}

 

TzChaobiaoInfoView.hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="cc.dfsoft.ranqi.bo.view.TzChaobiaoInfoView" table="TZCHAOBIAOINFO_VIEW" schema="TZWATERDFSOFT">
   
 <composite-id name="id" class="cc.dfsoft.ranqi.bo.view.TzChaobiaoInfoViewId">
            <key-property name="sbbh" type="java.lang.String">
     <column name="SBBH" />
    </key-property>
    <key-property name="cbrq" type="java.util.Date">
     <column name="CBRQ" />
    </key-property>
        </composite-id>
   
   
    <property name="khbh" type="java.lang.String">
          <column name="KHBH" length="6" />
          </property>
            <property name="dsdm" type="java.lang.Long">
                <column name="DSDM" precision="22" scale="0" />
            </property>
            <property name="ds" type="java.lang.Long">
                <column name="DS" precision="22" scale="0" />
            </property>
            <property name="sjys" type="java.lang.Long">
                <column name="SJYS" precision="22" scale="0" />
            </property>
            <property name="cby" type="java.lang.String">
                <column name="CBY" length="6" />
            </property>
            <property name="cbqk" type="java.lang.Long">
                <column name="CBQK" precision="22" scale="0" />
            </property>
            <property name="gsdz" type="java.lang.String">
                <column name="GSDZ" length="254" />
            </property>
            <property name="khmc" type="java.lang.String">
                <column name="KHMC" length="40" />
            </property>
            <property name="cbqkmc" type="java.lang.String">
                <column name="CBQKMC" length="30" />
            </property>
            <property name="dsdmmc" type="java.lang.String">
                <column name="DSDMMC" length="30" />
            </property>
    </class>
</hibernate-mapping>

         

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值