一个典型的Hibernate多对一关联配置

<? xml version="1.0" ?>
<! DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" 
>
    
< hibernate-mapping >
<!--  
    Created by the Middlegen Hibernate plugin 2.1

    http://boss.bekk.no/boss/middlegen/
    http://www.hibernate.org/
-->

< class 
    
name ="cn.hand.kmoa.persistence.UserInfo"  
    table
="user_info"
    schema
="test"
    dynamic-update
="true"
    dynamic-insert
="true"
>
    
< meta  attribute ="class-description"  inherit ="false" >
       @hibernate.class
        table="user_info"
        schema="test"
        dynamic-update="true"
        dynamic-insert="true"
    
</ meta >

    
< id
        
name ="id"
        type
="java.lang.Integer"
        column
="ID"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.id
            generator-class="assigned"
            type="java.lang.Integer"
            column="ID"


        
</ meta >
        
< generator  class ="assigned"   />
    
</ id >

    
< property
        
name ="loginName"
        type
="java.lang.String"
        column
="LoginName"
        not-null
="true"
        length
="20"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.property
            column="LoginName"
            length="20"
            not-null="true"
        
</ meta >     
    
</ property >
    
< property
        
name ="password"
        type
="java.lang.String"
        column
="Password"
        not-null
="true"
        length
="20"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.property
            column="Password"
            length="20"
            not-null="true"
        
</ meta >     
    
</ property >
    
< property
        
name ="trueName"
        type
="java.lang.String"
        column
="TrueName"
        not-null
="true"
        length
="10"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.property
            column="TrueName"
            length="10"
            not-null="true"
        
</ meta >     
    
</ property >
    
< many-to-one  name ="departId"  class ="cn.hand.kmoa.persistence.DeptInfo"  column ="DepartID"  cascade ="all"   />
    
< many-to-one  name ="position"  class ="cn.hand.kmoa.persistence.PostInfo"  column ="Position"  cascade ="all"   />
    
    
< property
        
name ="sex"
        type
="int"
        column
="Sex"
        not-null
="true"
        length
="2"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.property
            column="Sex"
            length="2"
            not-null="true"
        
</ meta >     
    
</ property >
    
< property
        
name ="phone"
        type
="java.lang.String"
        column
="Phone"
        length
="12"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.property
            column="Phone"
            length="12"
        
</ meta >     
    
</ property >
    
< property
        
name ="mobile"
        type
="java.lang.String"
        column
="Mobile"
        length
="11"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.property
            column="Mobile"
            length="11"
        
</ meta >     
    
</ property >
    
< property
        
name ="mail"
        type
="java.lang.String"
        column
="Mail"
        length
="50"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.property
            column="Mail"
            length="50"
        
</ meta >     
    
</ property >
    
< property
        
name ="remark"
        type
="java.lang.String"
        column
="Remark"
        length
="255"
    
>
        
< meta  attribute ="field-description" >
           @hibernate.property
            column="Remark"
            length="255"
        
</ meta >     
    
</ property >

    
<!--  Associations  -->

</ class >
</ hibernate-mapping >
User表与Dept和Post表的主键的一队多关联
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值